Skip to content

Commit

Permalink
feat: init config
Browse files Browse the repository at this point in the history
  • Loading branch information
wwei-github committed Oct 11, 2023
1 parent 7d070b9 commit bd0e831
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env copy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WEB3LOGO_DB_URL=''
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# compiled output
/dist
/node_modules
.env.*

# Logs
logs
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
},
"dependencies": {
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
"@nestjs/mapped-types": "*",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^7.1.13",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.8.1"
},
Expand Down
138 changes: 130 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { ApiTags } from '@nestjs/swagger';

@ApiTags('Hello world')
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
Expand Down
4 changes: 3 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import { TestModule } from './test/test.module';

@Module({
imports: [],
imports: [ConfigModule.forRoot({ isGlobal: true }), TestModule],
controllers: [AppController],
providers: [AppService],
})
Expand Down
13 changes: 13 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common/pipes';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

async function bootstrap() {
const app = await NestFactory.create(AppModule);

app.useGlobalPipes(new ValidationPipe());

const config = new DocumentBuilder()
.setTitle('Web3logo API')
.setDescription('The Web3logo API description')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api', app, document);

await app.listen(3000);
}
bootstrap();
1 change: 1 addition & 0 deletions src/test/dto/create-test.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class CreateTestDto {}
4 changes: 4 additions & 0 deletions src/test/dto/update-test.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateTestDto } from './create-test.dto';

export class UpdateTestDto extends PartialType(CreateTestDto) {}
1 change: 1 addition & 0 deletions src/test/entities/test.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Test {}
20 changes: 20 additions & 0 deletions src/test/test.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TestController } from './test.controller';
import { TestService } from './test.service';

describe('TestController', () => {
let controller: TestController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [TestController],
providers: [TestService],
}).compile();

controller = module.get<TestController>(TestController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
Loading

0 comments on commit bd0e831

Please sign in to comment.