nestjs_auth init..

This commit is contained in:
최준흠 2022-09-10 19:52:00 +09:00
parent 4084b8d2cf
commit c911b75b27
4 changed files with 40 additions and 40 deletions

2
.env
View File

@ -4,7 +4,7 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings # See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mysql://root:@localhost:3306/test" DATABASE_URL="mysql://root:@localhost:3306/test_todo"
CORS_ALLOW_ORIGINS = ['http://localhost:8080'] CORS_ALLOW_ORIGINS = ['http://localhost:8080']
CORS_ALLOW_METHOD = "GET,PUT,POST,DELETE,PATCH,OPTIONS" CORS_ALLOW_METHOD = "GET,PUT,POST,DELETE,PATCH,OPTIONS"

60
package-lock.json generated
View File

@ -12,7 +12,7 @@
"@nestjs/common": "^9.0.0", "@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0", "@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0", "@nestjs/platform-express": "^9.0.0",
"@prisma/client": "^4.1.1", "@prisma/client": "^4.3.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
@ -35,7 +35,7 @@
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "28.1.2", "jest": "28.1.2",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"prisma": "^4.1.1", "prisma": "^4.3.1",
"source-map-support": "^0.5.20", "source-map-support": "^0.5.20",
"supertest": "^6.1.3", "supertest": "^6.1.3",
"ts-jest": "28.0.5", "ts-jest": "28.0.5",
@ -1738,12 +1738,12 @@
} }
}, },
"node_modules/@prisma/client": { "node_modules/@prisma/client": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.1.1.tgz", "resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.3.1.tgz",
"integrity": "sha512-2pXuIUYxHv5H9o6QTa1VIsl4yMgsAjKQOitlo8WVTB+vo73rmMJITBPavdGUZSWUc7adMkFzEV3y5rVTUQr77Q==", "integrity": "sha512-FA0/d1VMJNWqzU7WVWTNWJ+lGOLR9JUBnF73GdIPAEVo/6dWk4gHx0EmgeU+SMv4MZoxgOeTBJF2azhg7x0hMw==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@prisma/engines-version": "4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8" "@prisma/engines-version": "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b"
}, },
"engines": { "engines": {
"node": ">=14.17" "node": ">=14.17"
@ -1758,16 +1758,16 @@
} }
}, },
"node_modules/@prisma/engines": { "node_modules/@prisma/engines": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.1.1.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.3.1.tgz",
"integrity": "sha512-DCw8L/SS0IXqmj5IW/fMxOXiifnsfjBzDfRhf0j3NFWqvMCh9OtfjmXQZxVgI2mwvJLc/5jzXhkiWT39qS09dA==", "integrity": "sha512-4JF/uMaEDAPdcdZNOrnzE3BvrbGpjgV0FcPT3EVoi6I86fWkloqqxBt+KcK/+fIRR0Pxj66uGR9wVH8U1Y13JA==",
"devOptional": true, "devOptional": true,
"hasInstallScript": true "hasInstallScript": true
}, },
"node_modules/@prisma/engines-version": { "node_modules/@prisma/engines-version": {
"version": "4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8", "version": "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b.tgz",
"integrity": "sha512-cRRJwpHFGFJZvtHbY3GZjMffNBEjjZk68ztn+S2hDgPCGB4H66IK26roK94GJxBodSehwRJ0wGyebC2GoIH1JQ==" "integrity": "sha512-8yWpXkQRmiSfsi2Wb/ZS5D3RFbeu/btL9Pm/gdF4phB0Lo5KGsDFMxFMgaD64mwED2nHc8ZaEJg/+4Jymb9Znw=="
}, },
"node_modules/@sinclair/typebox": { "node_modules/@sinclair/typebox": {
"version": "0.24.27", "version": "0.24.27",
@ -6684,13 +6684,13 @@
} }
}, },
"node_modules/prisma": { "node_modules/prisma": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-4.1.1.tgz", "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.3.1.tgz",
"integrity": "sha512-yw50J8If2dKP4wYIi695zthsCASQFHiogGvUHHWd3falx/rpsD6Sb1LMLRV9nO3iGG3lozxNJ2PSINxK7xwdpg==", "integrity": "sha512-90xo06wtqil76Xsi3mNpc4Js3SdDRR5g4qb9h+4VWY4Y8iImJY6xc3PX+C9xxTSt1lr0Q89A0MLkJjd8ax6KiQ==",
"devOptional": true, "devOptional": true,
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@prisma/engines": "4.1.1" "@prisma/engines": "4.3.1"
}, },
"bin": { "bin": {
"prisma": "build/index.js", "prisma": "build/index.js",
@ -9699,23 +9699,23 @@
} }
}, },
"@prisma/client": { "@prisma/client": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.1.1.tgz", "resolved": "https://registry.npmjs.org/@prisma/client/-/client-4.3.1.tgz",
"integrity": "sha512-2pXuIUYxHv5H9o6QTa1VIsl4yMgsAjKQOitlo8WVTB+vo73rmMJITBPavdGUZSWUc7adMkFzEV3y5rVTUQr77Q==", "integrity": "sha512-FA0/d1VMJNWqzU7WVWTNWJ+lGOLR9JUBnF73GdIPAEVo/6dWk4gHx0EmgeU+SMv4MZoxgOeTBJF2azhg7x0hMw==",
"requires": { "requires": {
"@prisma/engines-version": "4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8" "@prisma/engines-version": "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b"
} }
}, },
"@prisma/engines": { "@prisma/engines": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.1.1.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-4.3.1.tgz",
"integrity": "sha512-DCw8L/SS0IXqmj5IW/fMxOXiifnsfjBzDfRhf0j3NFWqvMCh9OtfjmXQZxVgI2mwvJLc/5jzXhkiWT39qS09dA==", "integrity": "sha512-4JF/uMaEDAPdcdZNOrnzE3BvrbGpjgV0FcPT3EVoi6I86fWkloqqxBt+KcK/+fIRR0Pxj66uGR9wVH8U1Y13JA==",
"devOptional": true "devOptional": true
}, },
"@prisma/engines-version": { "@prisma/engines-version": {
"version": "4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8", "version": "4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b",
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.1.0-48.8d8414deb360336e4698a65aa45a1fbaf1ce13d8.tgz", "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b.tgz",
"integrity": "sha512-cRRJwpHFGFJZvtHbY3GZjMffNBEjjZk68ztn+S2hDgPCGB4H66IK26roK94GJxBodSehwRJ0wGyebC2GoIH1JQ==" "integrity": "sha512-8yWpXkQRmiSfsi2Wb/ZS5D3RFbeu/btL9Pm/gdF4phB0Lo5KGsDFMxFMgaD64mwED2nHc8ZaEJg/+4Jymb9Znw=="
}, },
"@sinclair/typebox": { "@sinclair/typebox": {
"version": "0.24.27", "version": "0.24.27",
@ -13462,12 +13462,12 @@
} }
}, },
"prisma": { "prisma": {
"version": "4.1.1", "version": "4.3.1",
"resolved": "https://registry.npmjs.org/prisma/-/prisma-4.1.1.tgz", "resolved": "https://registry.npmjs.org/prisma/-/prisma-4.3.1.tgz",
"integrity": "sha512-yw50J8If2dKP4wYIi695zthsCASQFHiogGvUHHWd3falx/rpsD6Sb1LMLRV9nO3iGG3lozxNJ2PSINxK7xwdpg==", "integrity": "sha512-90xo06wtqil76Xsi3mNpc4Js3SdDRR5g4qb9h+4VWY4Y8iImJY6xc3PX+C9xxTSt1lr0Q89A0MLkJjd8ax6KiQ==",
"devOptional": true, "devOptional": true,
"requires": { "requires": {
"@prisma/engines": "4.1.1" "@prisma/engines": "4.3.1"
} }
}, },
"process-nextick-args": { "process-nextick-args": {

View File

@ -24,7 +24,7 @@
"@nestjs/common": "^9.0.0", "@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0", "@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0", "@nestjs/platform-express": "^9.0.0",
"@prisma/client": "^4.1.1", "@prisma/client": "^4.3.1",
"cors": "^2.8.5", "cors": "^2.8.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
@ -47,7 +47,7 @@
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "28.1.2", "jest": "28.1.2",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"prisma": "^4.1.1", "prisma": "^4.3.1",
"source-map-support": "^0.5.20", "source-map-support": "^0.5.20",
"supertest": "^6.1.3", "supertest": "^6.1.3",
"ts-jest": "28.0.5", "ts-jest": "28.0.5",

View File

@ -18,7 +18,7 @@ export class TodoService {
where?: Prisma.TodoWhereInput where?: Prisma.TodoWhereInput
}): Promise<number> { }): Promise<number> {
const { cursor, where } = params const { cursor, where } = params
return this.prisma.todo.count({ return await this.prisma.todo.count({
cursor, cursor,
where where
}) })
@ -33,7 +33,7 @@ export class TodoService {
orderBy?: Prisma.TodoOrderByWithRelationInput orderBy?: Prisma.TodoOrderByWithRelationInput
}): Promise<Todo[]> { }): Promise<Todo[]> {
const { skip, take, cursor, where, orderBy } = params const { skip, take, cursor, where, orderBy } = params
return this.prisma.todo.findMany({ return await this.prisma.todo.findMany({
skip, skip,
take, take,
cursor, cursor,
@ -43,13 +43,13 @@ export class TodoService {
} }
//단일 조회 //단일 조회
async fetchOne(where: Prisma.TodoWhereUniqueInput): Promise<Todo | null> { async fetchOne(where: Prisma.TodoWhereInput): Promise<Todo | null> {
return this.prisma.todo.findUnique({ where }) return await this.prisma.todo.findFirstOrThrow({ where: where })
} }
//단일 추가 //단일 추가
async add(data: Prisma.TodoCreateInput): Promise<Todo> { async add(data: Prisma.TodoCreateInput): Promise<Todo> {
return this.prisma.todo.create({ data }) return await this.prisma.todo.create({ data })
} }
//단일 수정 //단일 수정
@ -58,7 +58,7 @@ export class TodoService {
data: Prisma.TodoUpdateInput data: Prisma.TodoUpdateInput
}): Promise<Todo | null> { }): Promise<Todo | null> {
const { where, data } = params const { where, data } = params
return this.prisma.todo.update({ return await this.prisma.todo.update({
data, data,
where where
}) })
@ -66,6 +66,6 @@ export class TodoService {
//단일 삭제 //단일 삭제
async remove(where: Prisma.TodoWhereUniqueInput): Promise<Todo | null> { async remove(where: Prisma.TodoWhereUniqueInput): Promise<Todo | null> {
return this.prisma.todo.delete({ where }) return await this.prisma.todo.delete({ where })
} }
} }