From 685ef5c16c0233ffa6f78db9c77aa824a6a4b280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berat=20Gen=C3=A7?= Date: Thu, 18 Jan 2024 19:41:48 +0300 Subject: [PATCH] added login mechanism --- package-lock.json | 102 +++++++++++++++++- package.json | 4 +- .../20240114145643_init/migration.sql | 23 ---- .../20240115211555_priority/migration.sql | 8 -- .../migration.sql | 8 -- .../migration.sql | 22 +--- prisma/schema.prisma | 3 +- src/app.module.ts | 27 +++-- src/employee/employee.controller.ts | 37 ++++++- src/employee/employee.service.ts | 11 ++ src/express.session.d.ts | 6 ++ src/main.ts | 12 ++- src/project/project.controller.ts | 15 ++- src/project/project.service.ts | 4 + src/session/session.controller.spec.ts | 20 ++++ src/session/session.module.ts | 46 ++++++++ src/session/session.service.spec.ts | 18 ++++ src/session/session.service.ts | 20 ++++ 18 files changed, 307 insertions(+), 79 deletions(-) delete mode 100644 prisma/migrations/20240114145643_init/migration.sql delete mode 100644 prisma/migrations/20240115211555_priority/migration.sql delete mode 100644 prisma/migrations/20240116210516_removedemployee/migration.sql rename prisma/migrations/{20240114164022_task => 20240118154150_clean}/migration.sql (84%) create mode 100644 src/express.session.d.ts create mode 100644 src/session/session.controller.spec.ts create mode 100644 src/session/session.module.ts create mode 100644 src/session/session.service.spec.ts create mode 100644 src/session/session.service.ts diff --git a/package-lock.json b/package-lock.json index baa3da4..1b386d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,11 @@ "@nestjs/platform-express": "^10.0.0", "@prisma/client": "^5.8.0", "axios": "^1.6.5", + "connect-redis": "^7.1.0", "dotenv": "^16.3.1", "express-session": "^1.17.3", "prisma": "^5.8.0", + "redis": "^4.6.12", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "zustand": "^4.4.7" @@ -26,7 +28,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", - "@types/express": "^4.17.17", + "@types/express": "^4.17.21", "@types/express-session": "^1.17.10", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", @@ -2005,6 +2007,64 @@ "@prisma/debug": "5.8.0" } }, + "node_modules/@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/client": { + "version": "1.5.13", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.5.13.tgz", + "integrity": "sha512-epkUM9D0Sdmt93/8Ozk43PNjLi36RZzG+d/T1Gdu5AI8jvghonTeLYV69WVWdilvFo+PYxbP0TZ0saMvr6nscQ==", + "dependencies": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@redis/client/node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/json": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.6.tgz", + "integrity": "sha512-rcZO3bfQbm2zPRpqo82XbW8zg4G/w4W3tI7X8Mqleq9goQjAGLL7q/1n1ZX4dXEAmORVZ4s1+uKLaUOg7LrUhw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/search": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.1.6.tgz", + "integrity": "sha512-mZXCxbTYKBQ3M2lZnEddwEAks0Kc7nauire8q20oA0oA/LoA+E/b5Y5KZn232ztPb1FkIGqo12vh3Lf+Vw5iTw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/time-series": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.0.5.tgz", + "integrity": "sha512-IFjIgTusQym2B5IZJG3XKr5llka7ey84fw/NOYqESP5WUfQs9zz1ww/9+qoz4ka/S6KcGBodzlCeZ5UImKbscg==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -3475,6 +3535,14 @@ "node": ">=0.8" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -3572,6 +3640,17 @@ "typedarray": "^0.0.6" } }, + "node_modules/connect-redis": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/connect-redis/-/connect-redis-7.1.0.tgz", + "integrity": "sha512-UaqO1EirWjON2ENsyau7N5lbkrdYBpS6mYlXSeff/OYXsd6EGZ+SXSmNPoljL2PSua8fgjAEaldSA73PMZQ9Eg==", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "express-session": ">=1" + } + }, "node_modules/consola": { "version": "2.15.3", "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", @@ -4854,6 +4933,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==", + "engines": { + "node": ">= 4" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -7310,6 +7397,19 @@ "node": ">= 0.10" } }, + "node_modules/redis": { + "version": "4.6.12", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.6.12.tgz", + "integrity": "sha512-41Xuuko6P4uH4VPe5nE3BqXHB7a9lkFL0J29AlxKaIfD6eWO8VO/5PDF9ad2oS+mswMsfFxaM5DlE3tnXT+P8Q==", + "dependencies": { + "@redis/bloom": "1.2.0", + "@redis/client": "1.5.13", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.6", + "@redis/search": "1.1.6", + "@redis/time-series": "1.0.5" + } + }, "node_modules/reflect-metadata": { "version": "0.1.14", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz", diff --git a/package.json b/package.json index 8cd4db1..ff275ec 100644 --- a/package.json +++ b/package.json @@ -26,9 +26,11 @@ "@nestjs/platform-express": "^10.0.0", "@prisma/client": "^5.8.0", "axios": "^1.6.5", + "connect-redis": "^7.1.0", "dotenv": "^16.3.1", "express-session": "^1.17.3", "prisma": "^5.8.0", + "redis": "^4.6.12", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "zustand": "^4.4.7" @@ -37,7 +39,7 @@ "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", - "@types/express": "^4.17.17", + "@types/express": "^4.17.21", "@types/express-session": "^1.17.10", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", diff --git a/prisma/migrations/20240114145643_init/migration.sql b/prisma/migrations/20240114145643_init/migration.sql deleted file mode 100644 index 0025a34..0000000 --- a/prisma/migrations/20240114145643_init/migration.sql +++ /dev/null @@ -1,23 +0,0 @@ --- CreateTable -CREATE TABLE `User` ( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `email` VARCHAR(191) NOT NULL, - `name` VARCHAR(191) NULL, - - UNIQUE INDEX `User_email_key`(`email`), - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- CreateTable -CREATE TABLE `Post` ( - `id` INTEGER NOT NULL AUTO_INCREMENT, - `title` VARCHAR(191) NOT NULL, - `content` VARCHAR(191) NULL, - `published` BOOLEAN NOT NULL DEFAULT false, - `authorId` INTEGER NOT NULL, - - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- AddForeignKey -ALTER TABLE `Post` ADD CONSTRAINT `Post_authorId_fkey` FOREIGN KEY (`authorId`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20240115211555_priority/migration.sql b/prisma/migrations/20240115211555_priority/migration.sql deleted file mode 100644 index fb42e6c..0000000 --- a/prisma/migrations/20240115211555_priority/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - Added the required column `priority` to the `Task` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE `Task` ADD COLUMN `priority` VARCHAR(191) NOT NULL; diff --git a/prisma/migrations/20240116210516_removedemployee/migration.sql b/prisma/migrations/20240116210516_removedemployee/migration.sql deleted file mode 100644 index 453fe28..0000000 --- a/prisma/migrations/20240116210516_removedemployee/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ --- DropForeignKey -ALTER TABLE `Project` DROP FOREIGN KEY `Project_employeeId_fkey`; - --- AlterTable -ALTER TABLE `Project` MODIFY `employeeId` INTEGER NULL; - --- AddForeignKey -ALTER TABLE `Project` ADD CONSTRAINT `Project_employeeId_fkey` FOREIGN KEY (`employeeId`) REFERENCES `Employee`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/20240114164022_task/migration.sql b/prisma/migrations/20240118154150_clean/migration.sql similarity index 84% rename from prisma/migrations/20240114164022_task/migration.sql rename to prisma/migrations/20240118154150_clean/migration.sql index cf9f9f6..fc43c9e 100644 --- a/prisma/migrations/20240114164022_task/migration.sql +++ b/prisma/migrations/20240118154150_clean/migration.sql @@ -1,24 +1,9 @@ -/* - Warnings: - - - You are about to drop the `Post` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `User` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropForeignKey -ALTER TABLE `Post` DROP FOREIGN KEY `Post_authorId_fkey`; - --- DropTable -DROP TABLE `Post`; - --- DropTable -DROP TABLE `User`; - -- CreateTable CREATE TABLE `Employee` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `username` VARCHAR(191) NOT NULL, `email` VARCHAR(191) NOT NULL, + `password` VARCHAR(191) NOT NULL, UNIQUE INDEX `Employee_email_key`(`email`), PRIMARY KEY (`id`) @@ -46,7 +31,7 @@ CREATE TABLE `Project` ( `name` VARCHAR(191) NOT NULL, `description` VARCHAR(191) NULL, `teamId` INTEGER NOT NULL, - `employeeId` INTEGER NOT NULL, + `employeeId` INTEGER NULL, PRIMARY KEY (`id`) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; @@ -56,6 +41,7 @@ CREATE TABLE `Task` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `title` VARCHAR(191) NOT NULL, `description` VARCHAR(191) NULL, + `priority` VARCHAR(191) NOT NULL, `completed` BOOLEAN NOT NULL DEFAULT false, `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updatedAt` DATETIME(3) NOT NULL, @@ -75,7 +61,7 @@ ALTER TABLE `EmployeeOnTeams` ADD CONSTRAINT `EmployeeOnTeams_employeeId_fkey` F ALTER TABLE `Project` ADD CONSTRAINT `Project_teamId_fkey` FOREIGN KEY (`teamId`) REFERENCES `Team`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE `Project` ADD CONSTRAINT `Project_employeeId_fkey` FOREIGN KEY (`employeeId`) REFERENCES `Employee`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE `Project` ADD CONSTRAINT `Project_employeeId_fkey` FOREIGN KEY (`employeeId`) REFERENCES `Employee`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE `Task` ADD CONSTRAINT `Task_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `Employee`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3b8b8e3..ed5eaa8 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -5,13 +5,14 @@ generator client { datasource db { provider = "mysql" - url = "mysql://root:ysxgdil0@35.195.248.72:3306/manager" + url = "mysql://root:ysxgdil0@35.195.248.72:3306/taskManagerp" } model Employee { id Int @id @default(autoincrement()) username String email String @unique + password String teams EmployeeOnTeams[] tasks Task[] projects Project[] diff --git a/src/app.module.ts b/src/app.module.ts index e1a5010..45a4339 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -1,16 +1,21 @@ -import { Module } from '@nestjs/common'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; -import { DatabaseModule } from './database/database.module'; -import { EmployeeModule } from './employee/employee.module'; -import { TasksModule } from './tasks/tasks.module'; -import { TeamModule } from './team/team.module'; -import { ProjectModule } from './project/project.module'; - +import { Module } from '@nestjs/common' +import { AppController } from './app.controller' +import { AppService } from './app.service' +import { DatabaseModule } from './database/database.module' +import { EmployeeModule } from './employee/employee.module' +import { TasksModule } from './tasks/tasks.module' +import { TeamModule } from './team/team.module' +import { ProjectModule } from './project/project.module' @Module({ - imports: [DatabaseModule, EmployeeModule, TasksModule, TeamModule, ProjectModule], + imports: [ + DatabaseModule, + EmployeeModule, + TasksModule, + TeamModule, + ProjectModule + ], controllers: [AppController], - providers: [AppService], + providers: [AppService] }) export class AppModule {} diff --git a/src/employee/employee.controller.ts b/src/employee/employee.controller.ts index 1799a1d..8f638d8 100644 --- a/src/employee/employee.controller.ts +++ b/src/employee/employee.controller.ts @@ -1,3 +1,4 @@ +// @ts-nocheck import { Controller, Get, @@ -5,20 +6,44 @@ import { Body, Patch, Param, - Delete + Delete, + Res, + Req } from '@nestjs/common' import { EmployeeService } from './employee.service' import { Prisma } from '@prisma/client' +import { Request } from 'express' @Controller('employee') export class EmployeeController { constructor(private readonly employeeService: EmployeeService) {} @Post() - create(@Body() createEmployeeDto: Prisma.EmployeeCreateInput) { + create( + @Body() createEmployeeDto: Prisma.EmployeeCreateInput, + @Req() request: Request + ) { + request.session.userMail = createEmployeeDto.email return this.employeeService.create(createEmployeeDto) } + @Get('/getUserId') + findUserId(@Req() request: Request) { + if (request.session.userMail) { + const mailAdress = request.session.userMail + return this.employeeService.findUserId(mailAdress) + } else { + return 'No access' + } + } + + // login( + // @Body() createEmployeeDto: Prisma.EmployeeCreateInput, + // @Req() request: Request + // ) { + // return this.employeeService.login() + // } + @Get() findAll() { return this.employeeService.findAll() @@ -30,7 +55,7 @@ export class EmployeeController { } @Get(':id') - findOne(@Param('id') id: string) { + findOne(@Param('id') id: string, @Req() request: Request) { return this.employeeService.findOne(+id) } @@ -49,6 +74,10 @@ export class EmployeeController { @Delete(':id') remove(@Param('id') id: string) { - return this.employeeService.remove(+id) + return this.employeeService.remove() + } + @Delete('/remove-all') + remove() { + return this.employeeService.removeAll() } } diff --git a/src/employee/employee.service.ts b/src/employee/employee.service.ts index 7cde53a..e0bd478 100644 --- a/src/employee/employee.service.ts +++ b/src/employee/employee.service.ts @@ -10,6 +10,13 @@ export class EmployeeService { return this.databaseService.employee.create({ data: createEmployeeDto }) } + async findUserId(mailAdress: string) { + const user = await this.databaseService.employee.findUnique({ + where: { email: mailAdress } + }) + return user.id + } + assignTask(id: number, taskId: number) { return this.databaseService.employee.update({ where: { id }, @@ -53,4 +60,8 @@ export class EmployeeService { remove(id: number) { return `This action removes a #${id} employee` } + + removeAll() { + return this.databaseService.employee.deleteMany({}) + } } diff --git a/src/express.session.d.ts b/src/express.session.d.ts new file mode 100644 index 0000000..e22d9a5 --- /dev/null +++ b/src/express.session.d.ts @@ -0,0 +1,6 @@ +declare module 'express-session' { + interface SessionData { + example?: string + // Add other custom properties as needed + } +} diff --git a/src/main.ts b/src/main.ts index 271c4ea..68d4d10 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,12 +1,20 @@ +// @ts-nocheck import { NestFactory } from '@nestjs/core' import { AppModule } from './app.module' +import * as session from 'express-session' +import { sessionOptions } from './session/session.module' + async function bootstrap() { const app = await NestFactory.create(AppModule) app.enableCors({ - origin: 'https://app.taskermanager.online' + origin: 'https://app.taskermanager.online', + // origin: ['https://app.taskermanager.online', 'http://localhost:3000'], + credentials: true }) + + app.use(session(sessionOptions)) console.log(`--- app is listening oooon ${process.env.PORT}`) - await app.listen(process.env.PORT ?? 3001) + await app.listen(process.env.PORT ?? 3005) } bootstrap() diff --git a/src/project/project.controller.ts b/src/project/project.controller.ts index 31ca7b8..29cd0c3 100644 --- a/src/project/project.controller.ts +++ b/src/project/project.controller.ts @@ -5,17 +5,23 @@ import { Body, Patch, Param, - Delete + Delete, + Req } from '@nestjs/common' import { ProjectService } from './project.service' import { Prisma } from '@prisma/client' +import { Request } from 'express' @Controller('project') export class ProjectController { constructor(private readonly projectService: ProjectService) {} @Post() - create(@Body() createProjectDto: Prisma.ProjectCreateInput) { + create( + @Body() createProjectDto: Prisma.ProjectCreateInput, + @Req() request: Request + ) { + console.log(request.session) return this.projectService.create(createProjectDto) } @@ -41,4 +47,9 @@ export class ProjectController { remove(@Param('id') id: string) { return this.projectService.remove(+id) } + + // @Delete('/remove-all') + // removeAll() { + // return this.projectService.removeAll() + // } } diff --git a/src/project/project.service.ts b/src/project/project.service.ts index 1093625..5633d5d 100644 --- a/src/project/project.service.ts +++ b/src/project/project.service.ts @@ -27,4 +27,8 @@ export class ProjectService { remove(id: number) { return this.databaseService.project.delete({ where: { id } }) } + + removeAll() { + return this.databaseService.project.deleteMany() + } } diff --git a/src/session/session.controller.spec.ts b/src/session/session.controller.spec.ts new file mode 100644 index 0000000..be7117c --- /dev/null +++ b/src/session/session.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { SessionController } from './session.controller'; +import { SessionService } from './session.service'; + +describe('SessionController', () => { + let controller: SessionController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [SessionController], + providers: [SessionService], + }).compile(); + + controller = module.get(SessionController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/session/session.module.ts b/src/session/session.module.ts new file mode 100644 index 0000000..67762c6 --- /dev/null +++ b/src/session/session.module.ts @@ -0,0 +1,46 @@ +// src/session/session.module.ts + +import { Module } from '@nestjs/common' +const RedisStore = require('connect-redis').default +import { createClient } from 'redis' +import * as session from 'express-session' + +const redisClient = createClient({ + password: '3JluMijpNIdRLNlgqVdyLE6HnhNClCTC', + socket: { + host: 'redis-11743.c300.eu-central-1-1.ec2.cloud.redislabs.com', + port: 11743 + } +}) + +redisClient.connect().catch(console.error) + +const redisStore = new RedisStore({ + client: redisClient +}) + +redisClient.on('connect', () => { + console.log('Connected to Redis server') +}) +export const sessionOptions = { + store: redisStore, + secret: 'mysecret', + saveUninitialized: false, + resave: false, + cookie: { + path: '/', + domain: 'auth-test.site', + maxAge: 1000 * 60 * 30, + sameSite: 'none', + secure: true, + httpOnly: true + } + // cookie: { + // path: '/', + // // domain: "auth-test.site", + // maxAge: 1000 * 60 * 30 + // // sameSite: "none", + // // secure: true, + // // httpOnly: true, + // } +} diff --git a/src/session/session.service.spec.ts b/src/session/session.service.spec.ts new file mode 100644 index 0000000..a351693 --- /dev/null +++ b/src/session/session.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { SessionService } from './session.service'; + +describe('SessionService', () => { + let service: SessionService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [SessionService], + }).compile(); + + service = module.get(SessionService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/session/session.service.ts b/src/session/session.service.ts new file mode 100644 index 0000000..d7938d1 --- /dev/null +++ b/src/session/session.service.ts @@ -0,0 +1,20 @@ +import { Injectable } from '@nestjs/common' + +@Injectable() +export class SessionService { + // create(createSessionDto: CreateSessionDto) { + // return 'This action adds a new session' + // } + // findAll() { + // return `This action returns all session` + // } + // findOne(id: number) { + // return `This action returns a #${id} session` + // } + // update(id: number, updateSessionDto: UpdateSessionDto) { + // return `This action updates a #${id} session` + // } + // remove(id: number) { + // return `This action removes a #${id} session` + // } +}