-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create nest api folder structure
- Loading branch information
1 parent
b1a28cd
commit c0d1d33
Showing
12 changed files
with
1,626 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { UsersModule } from "./users/users.module"; | ||
|
||
@Module({ | ||
imports: [UsersModule], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
console.log("Hello, world."); | ||
import { NestFactory } from "@nestjs/core"; | ||
import { AppModule } from "./app.module"; | ||
|
||
const DEFAULT_PORT = 3000; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(process.env.PORT || DEFAULT_PORT); | ||
console.log(`Application is running on: ${await app.getUrl()}`); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class CreateUserDto {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { PartialType } from "@nestjs/mapped-types"; | ||
import { CreateUserDto } from "./create-user.dto"; | ||
|
||
export class UpdateUserDto extends PartialType(CreateUserDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class User {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { UsersController } from "./users.controller"; | ||
import { UsersService } from "./users.service"; | ||
|
||
describe("UsersController", () => { | ||
let controller: UsersController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [UsersController], | ||
providers: [UsersService], | ||
}).compile(); | ||
|
||
controller = module.get<UsersController>(UsersController); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
Controller, Get, Post, Body, Patch, Param, Delete, | ||
} from "@nestjs/common"; | ||
import { CreateUserDto } from "./dto/create-user.dto"; | ||
import { UpdateUserDto } from "./dto/update-user.dto"; | ||
import { UsersService } from "./users.service"; | ||
|
||
@Controller("users") | ||
export class UsersController { | ||
constructor(private readonly usersService: UsersService) {} | ||
|
||
@Post() | ||
create(@Body() createUserDto: CreateUserDto) { | ||
return this.usersService.create(createUserDto); | ||
} | ||
|
||
@Get() | ||
findAll() { | ||
return this.usersService.findAll(); | ||
} | ||
|
||
@Get(":id") | ||
findOne(@Param("id") id: string) { | ||
return this.usersService.findOne(+id); | ||
} | ||
|
||
@Patch(":id") | ||
update(@Param("id") id: string, @Body() updateUserDto: UpdateUserDto) { | ||
return this.usersService.update(+id, updateUserDto); | ||
} | ||
|
||
@Delete(":id") | ||
remove(@Param("id") id: string) { | ||
return this.usersService.remove(+id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { UsersController } from "./users.controller"; | ||
import { UsersService } from "./users.service"; | ||
|
||
@Module({ | ||
controllers: [UsersController], | ||
providers: [UsersService], | ||
}) | ||
export class UsersModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from "@nestjs/testing"; | ||
import { UsersService } from "./users.service"; | ||
|
||
describe("UsersService", () => { | ||
let service: UsersService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [UsersService], | ||
}).compile(); | ||
|
||
service = module.get<UsersService>(UsersService); | ||
}); | ||
|
||
it("should be defined", () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable */ | ||
import { Injectable } from "@nestjs/common"; | ||
import { CreateUserDto } from "./dto/create-user.dto"; | ||
import { UpdateUserDto } from "./dto/update-user.dto"; | ||
|
||
@Injectable() | ||
export class UsersService { | ||
create(createUserDto: CreateUserDto) { | ||
return "This action adds a new user"; | ||
} | ||
|
||
findAll() { | ||
return `This action returns all users`; | ||
} | ||
|
||
findOne(id: number) { | ||
return `This action returns a #${id} user`; | ||
} | ||
|
||
update(id: number, updateUserDto: UpdateUserDto) { | ||
return `This action updates a #${id} user`; | ||
} | ||
|
||
remove(id: number) { | ||
return `This action removes a #${id} user`; | ||
} | ||
} |
c0d1d33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
node-nest-typescript-starter-project – ./
node-nest-typescript-starter-project-git-main-nicolasbuecher.vercel.app
node-nest-typescript-starter-project.vercel.app
node-nest-typescript-starter-project-nicolasbuecher.vercel.app