Ajout Swagger
This commit is contained in:
@ -1,22 +0,0 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
import { AppController } from './app.controller'
|
||||
import { AppService } from './app.service'
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile()
|
||||
|
||||
appController = app.get<AppController>(AppController)
|
||||
})
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!')
|
||||
})
|
||||
})
|
||||
})
|
@ -1,12 +0,0 @@
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
import { AppService } from './app.service'
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello()
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { AppController } from './app.controller'
|
||||
import { AppService } from './app.service'
|
||||
import { PrismaService } from './prisma/prisma.service'
|
||||
import { PrismaModule } from './prisma/prisma.module'
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [AppService, PrismaService],
|
||||
imports: [PrismaModule],
|
||||
providers: [PrismaService],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
@ -1,8 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!'
|
||||
}
|
||||
}
|
@ -1,8 +1,17 @@
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { AppModule } from './app.module'
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule)
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Traintrape-moi')
|
||||
.setDescription('API permettant de stocker les données de Traintrape-moi')
|
||||
.setVersion('1.0')
|
||||
.build()
|
||||
const document = SwaggerModule.createDocument(app, config)
|
||||
|
||||
SwaggerModule.setup('', app, document);
|
||||
await app.listen(process.env.PORT ?? 3000)
|
||||
}
|
||||
bootstrap()
|
||||
|
8
server/src/prisma/prisma.module.ts
Normal file
8
server/src/prisma/prisma.module.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { PrismaService } from './prisma.service'
|
||||
|
||||
@Module({
|
||||
providers: [PrismaService],
|
||||
exports: [PrismaService],
|
||||
})
|
||||
export class PrismaModule {}
|
Reference in New Issue
Block a user