parent
0209893e2d
commit
d7042fbcc2
@ -1,4 +1,4 @@ |
||||
{ |
||||
"singleQuote": true, |
||||
"trailingComma": "all" |
||||
} |
||||
"singleQuote": false, |
||||
"trailingComma": "all", |
||||
} |
||||
|
@ -1,15 +1,12 @@ |
||||
import { Body, Controller, Get, Param, Req } from '@nestjs/common'; |
||||
import { AppService } from './app.service'; |
||||
import { Body, Controller, Get } from "@nestjs/common"; |
||||
import { AppService } from "./app.service"; |
||||
|
||||
@Controller('cats') |
||||
@Controller("") |
||||
export class AppController { |
||||
constructor(private readonly appService: AppService) {} |
||||
|
||||
@Get('hello/:id') |
||||
getHello(@Req() req: Request, @Body() body: any, @Param() param): string { |
||||
// console.log(req);
|
||||
console.log(body); |
||||
console.log(param); |
||||
@Get() |
||||
getHello(): string { |
||||
return this.appService.getHello(); |
||||
} |
||||
} |
||||
|
@ -1,8 +1,8 @@ |
||||
import { Injectable } from '@nestjs/common'; |
||||
import { Injectable } from "@nestjs/common"; |
||||
|
||||
@Injectable() |
||||
export class AppService { |
||||
getHello(): string { |
||||
return 'Hello World!'; |
||||
return "Hello World!"; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,18 @@ |
||||
import { Test, TestingModule } from "@nestjs/testing"; |
||||
import { CatsController } from "./cats.controller"; |
||||
|
||||
describe("CatsController", () => { |
||||
let controller: CatsController; |
||||
|
||||
beforeEach(async () => { |
||||
const module: TestingModule = await Test.createTestingModule({ |
||||
controllers: [CatsController], |
||||
}).compile(); |
||||
|
||||
controller = module.get<CatsController>(CatsController); |
||||
}); |
||||
|
||||
it("should be defined", () => { |
||||
expect(controller).toBeDefined(); |
||||
}); |
||||
}); |
@ -0,0 +1,37 @@ |
||||
import { Controller, Delete, Get, Patch, Post, Put } from "@nestjs/common"; |
||||
import { CatsService } from "./cats.service"; |
||||
|
||||
@Controller("cats") |
||||
export class CatsController { |
||||
constructor(private readonly catsService: CatsService) {} |
||||
|
||||
@Get() |
||||
getAllCat() { |
||||
return "all cat"; |
||||
} |
||||
|
||||
@Get(":id") |
||||
getOneGat() { |
||||
return "one cat"; |
||||
} |
||||
|
||||
@Post() |
||||
createCat() { |
||||
return "create cat"; |
||||
} |
||||
|
||||
@Put(":id") |
||||
updateCat() { |
||||
return "update cat"; |
||||
} |
||||
|
||||
@Patch(":id") |
||||
updatePartialCat() { |
||||
return "update partial cat"; |
||||
} |
||||
|
||||
@Delete(":id") |
||||
deleteCat() { |
||||
return "delete cat"; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
import { Module } from "@nestjs/common"; |
||||
import { CatsController } from "./cats.controller"; |
||||
import { CatsService } from "./cats.service"; |
||||
|
||||
@Module({ |
||||
controllers: [CatsController], |
||||
providers: [CatsService], |
||||
}) |
||||
export class CatsModule {} |
@ -0,0 +1,18 @@ |
||||
import { Test, TestingModule } from "@nestjs/testing"; |
||||
import { CatsService } from "./cats.service"; |
||||
|
||||
describe("CatsService", () => { |
||||
let service: CatsService; |
||||
|
||||
beforeEach(async () => { |
||||
const module: TestingModule = await Test.createTestingModule({ |
||||
providers: [CatsService], |
||||
}).compile(); |
||||
|
||||
service = module.get<CatsService>(CatsService); |
||||
}); |
||||
|
||||
it("should be defined", () => { |
||||
expect(service).toBeDefined(); |
||||
}); |
||||
}); |
@ -0,0 +1,4 @@ |
||||
import { Injectable } from "@nestjs/common"; |
||||
|
||||
@Injectable() |
||||
export class CatsService {} |
@ -0,0 +1,4 @@ |
||||
import { Module } from '@nestjs/common'; |
||||
|
||||
@Module({}) |
||||
export class UsersModule {} |
Loading…
Reference in new issue