├── Procfile ├── dist ├── main.d.ts ├── src │ ├── main.d.ts │ ├── app.controller.spec.d.ts │ ├── user │ │ ├── user.resolver.spec.d.ts │ │ ├── user.service.spec.d.ts │ │ ├── user.module.d.ts │ │ ├── dto │ │ │ ├── create-user.input.d.ts │ │ │ ├── update-user.input.d.ts │ │ │ ├── create-user.input.js.map │ │ │ ├── update-user.input.js.map │ │ │ ├── create-user.input.js │ │ │ └── update-user.input.js │ │ ├── user.entity.d.ts │ │ ├── user.module.js.map │ │ ├── user.service.spec.js.map │ │ ├── user.resolver.spec.js.map │ │ ├── user.service.spec.js │ │ ├── user.resolver.spec.js │ │ ├── user.service.d.ts │ │ ├── user.resolver.d.ts │ │ ├── user.entity.js.map │ │ ├── user.service.js.map │ │ ├── user.module.js │ │ ├── user.resolver.js.map │ │ ├── user.entity.js │ │ ├── user.service.js │ │ └── user.resolver.js │ ├── app.module.d.ts │ ├── app.service.d.ts │ ├── config │ │ ├── typeOrmConfig.d.ts │ │ ├── typeOrmConfig.js.map │ │ └── typeOrmConfig.js │ ├── app.controller.d.ts │ ├── app.service.js.map │ ├── main.js.map │ ├── main.js │ ├── app.controller.js.map │ ├── app.module.js.map │ ├── app.controller.spec.js.map │ ├── app.controller.spec.js │ ├── app.service.js │ ├── app.controller.js │ └── app.module.js ├── test │ ├── app.e2e-spec.d.ts │ ├── app.e2e-spec.js.map │ └── app.e2e-spec.js ├── app.module.d.ts ├── poll │ ├── poll.module.d.ts │ ├── dto │ │ ├── create-poll.input.d.ts │ │ ├── update-poll.input.d.ts │ │ ├── update-poll.input.js.map │ │ ├── create-poll.input.js.map │ │ ├── update-poll.input.js │ │ └── create-poll.input.js │ ├── entities │ │ ├── poll-option.entity.d.ts │ │ ├── poll.entity.d.ts │ │ ├── poll.entity.js.map │ │ ├── poll-option.entity.js.map │ │ ├── poll-option.entity.js │ │ └── poll.entity.js │ ├── poll.module.js.map │ ├── poll.resolver.d.ts │ ├── poll.service.d.ts │ ├── poll.service.js.map │ ├── poll.module.js │ ├── poll.resolver.js.map │ ├── poll.service.js │ └── poll.resolver.js ├── user │ ├── user.module.d.ts │ ├── entities │ │ ├── user.entity.d.ts │ │ ├── user.entity.js.map │ │ └── user.entity.js │ ├── dto │ │ ├── create-user.input.d.ts │ │ ├── login-user.input.d.ts │ │ ├── update-user.input.d.ts │ │ ├── login-user.input.js.map │ │ ├── create-user.input.js.map │ │ ├── update-user.input.js.map │ │ ├── login-user.input.js │ │ ├── create-user.input.js │ │ └── update-user.input.js │ ├── user.controller.d.ts │ ├── user.entity.d.ts │ ├── user.subscriber.d.ts │ ├── user.subscriber.js.map │ ├── user.module.js.map │ ├── user.controller.js.map │ ├── user.resolver.d.ts │ ├── user.service.d.ts │ ├── user.entity.js.map │ ├── user.subscriber.js │ ├── user.module.js │ ├── user.controller.js │ ├── user.resolver.js.map │ ├── user.entity.js │ ├── user.service.js.map │ ├── user.service.js │ └── user.resolver.js ├── app.service.d.ts ├── utils │ ├── redis.d.ts │ ├── confirmEmailLinks.d.ts │ ├── sendEmail.d.ts │ ├── redis.js.map │ ├── redis.js │ ├── confirmEmailLinks.js.map │ ├── confirmEmailLinks.js │ ├── sendEmail.js.map │ └── sendEmail.js ├── shared │ ├── getuserid.decorator.d.ts │ ├── error-response.d.ts │ ├── response-object.d.ts │ ├── auth.guard.d.ts │ ├── getuserid.decorator.js.map │ ├── error-response.js.map │ ├── response-object.js.map │ ├── getuserid.decorator.js │ ├── auth.guard.js.map │ ├── auth.guard.js │ ├── error-response.js │ └── response-object.js ├── types │ ├── my-context.js │ ├── my-context.js.map │ └── my-context.d.ts ├── config │ ├── typeOrmConfig.d.ts │ ├── typeOrmConfig.js.map │ └── typeOrmConfig.js ├── app.controller.d.ts ├── app.service.js.map ├── app.controller.js.map ├── main.js.map ├── app.service.js ├── app.module.js.map ├── main.js ├── app.controller.js └── app.module.js ├── .prettierrc ├── nest-cli.json ├── tsconfig.build.json ├── src ├── types │ └── my-context.ts ├── app.service.ts ├── utils │ ├── redis.ts │ ├── confirmEmailLinks.ts │ └── sendEmail.ts ├── poll │ ├── dto │ │ ├── create-poll.input.ts │ │ └── update-poll.input.ts │ ├── poll.module.ts │ ├── entities │ │ ├── poll-option.entity.ts │ │ └── poll.entity.ts │ ├── poll.resolver.ts │ └── poll.service.ts ├── shared │ ├── error-response.ts │ ├── getuserid.decorator.ts │ ├── auth.guard.ts │ └── response-object.ts ├── app.controller.ts ├── user │ ├── user.controller.ts │ ├── dto │ │ ├── login-user.input.ts │ │ ├── create-user.input.ts │ │ └── update-user.input.ts │ ├── user.module.ts │ ├── user.subscriber.ts │ ├── user.entity.ts │ ├── user.resolver.ts │ └── user.service.ts ├── app.controller.spec.ts ├── main.ts ├── config │ └── typeOrmConfig.ts ├── app.module.ts └── schema.gql ├── test ├── jest-e2e.json └── app.e2e-spec.ts ├── .gitignore ├── tsconfig.json ├── .eslintrc.js ├── .vscode └── launch.json ├── package.json └── README.md /Procfile: -------------------------------------------------------------------------------- 1 | web: npm run start:prod -------------------------------------------------------------------------------- /dist/main.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/main.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/test/app.e2e-spec.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/app.controller.spec.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/user/user.resolver.spec.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/src/user/user.service.spec.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /dist/app.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppModule { 2 | } 3 | -------------------------------------------------------------------------------- /dist/src/app.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppModule { 2 | } 3 | -------------------------------------------------------------------------------- /dist/poll/poll.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class PollModule { 2 | } 3 | -------------------------------------------------------------------------------- /dist/user/user.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class UserModule { 2 | } 3 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /dist/src/user/user.module.d.ts: -------------------------------------------------------------------------------- 1 | export declare class UserModule { 2 | } 3 | -------------------------------------------------------------------------------- /dist/app.service.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppService { 2 | getHello(): string; 3 | } 4 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /dist/src/app.service.d.ts: -------------------------------------------------------------------------------- 1 | export declare class AppService { 2 | getHello(): string; 3 | } 4 | -------------------------------------------------------------------------------- /dist/utils/redis.d.ts: -------------------------------------------------------------------------------- 1 | import * as Redis from 'ioredis'; 2 | export declare const redis: Redis.Redis; 3 | -------------------------------------------------------------------------------- /dist/utils/confirmEmailLinks.d.ts: -------------------------------------------------------------------------------- 1 | export declare const confirmEmailLink: (userId: string) => Promise; 2 | -------------------------------------------------------------------------------- /dist/utils/sendEmail.d.ts: -------------------------------------------------------------------------------- 1 | export declare const sendEmail: (userEmail: string, link: string) => Promise; 2 | -------------------------------------------------------------------------------- /dist/shared/getuserid.decorator.d.ts: -------------------------------------------------------------------------------- 1 | export declare const GetUserId: (...dataOrPipes: unknown[]) => ParameterDecorator; 2 | -------------------------------------------------------------------------------- /dist/shared/error-response.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ErrorResponse { 2 | path: string; 3 | message: string; 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /dist/poll/dto/create-poll.input.d.ts: -------------------------------------------------------------------------------- 1 | export declare class CreatePollInput { 2 | name: string; 3 | options: string[]; 4 | } 5 | -------------------------------------------------------------------------------- /dist/types/my-context.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | //# sourceMappingURL=my-context.js.map -------------------------------------------------------------------------------- /dist/types/my-context.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"my-context.js","sourceRoot":"","sources":["../../src/types/my-context.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/user/entities/user.entity.d.ts: -------------------------------------------------------------------------------- 1 | export declare class User { 2 | name: String; 3 | department: String; 4 | description: String; 5 | } 6 | -------------------------------------------------------------------------------- /dist/src/config/typeOrmConfig.d.ts: -------------------------------------------------------------------------------- 1 | import { TypeOrmModuleOptions } from "@nestjs/typeorm"; 2 | export declare const typeOrmConfig: TypeOrmModuleOptions; 3 | -------------------------------------------------------------------------------- /src/types/my-context.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | 3 | export interface MyContext { 4 | req: Request; 5 | res: Response 6 | } -------------------------------------------------------------------------------- /dist/types/my-context.d.ts: -------------------------------------------------------------------------------- 1 | import { Request, Response } from "express"; 2 | export interface MyContext { 3 | req: Request; 4 | res: Response; 5 | } 6 | -------------------------------------------------------------------------------- /dist/user/dto/create-user.input.d.ts: -------------------------------------------------------------------------------- 1 | export declare class CreateUserInput { 2 | userName: string; 3 | email: string; 4 | password: string; 5 | } 6 | -------------------------------------------------------------------------------- /dist/shared/response-object.d.ts: -------------------------------------------------------------------------------- 1 | export declare class ResponseObject { 2 | data: any[]; 3 | error: any[]; 4 | constructor(data?: any[], error?: any[]); 5 | } 6 | -------------------------------------------------------------------------------- /dist/src/user/dto/create-user.input.d.ts: -------------------------------------------------------------------------------- 1 | export declare class CreateUserInput { 2 | userName: string; 3 | email: string; 4 | password: string; 5 | isActive: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /dist/src/user/user.entity.d.ts: -------------------------------------------------------------------------------- 1 | export declare class User { 2 | id: number; 3 | userName: string; 4 | email: string; 5 | password: string; 6 | isActive: boolean; 7 | } 8 | -------------------------------------------------------------------------------- /src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dist/user/dto/login-user.input.d.ts: -------------------------------------------------------------------------------- 1 | import { MainUser } from '../user.entity'; 2 | export declare class LoginUserInput implements Partial { 3 | email: string; 4 | password: string; 5 | } 6 | -------------------------------------------------------------------------------- /dist/config/typeOrmConfig.d.ts: -------------------------------------------------------------------------------- 1 | import { TypeOrmModuleOptions } from "@nestjs/typeorm"; 2 | export declare const typeOrmConfig: TypeOrmModuleOptions; 3 | export declare const typeOrmProdConfig: TypeOrmModuleOptions; 4 | -------------------------------------------------------------------------------- /dist/shared/auth.guard.d.ts: -------------------------------------------------------------------------------- 1 | import { CanActivate, ExecutionContext } from '@nestjs/common'; 2 | export declare class AuthGuard implements CanActivate { 3 | canActivate(context: ExecutionContext): boolean; 4 | } 5 | -------------------------------------------------------------------------------- /dist/utils/redis.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/utils/redis.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAIpB,QAAA,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC"} -------------------------------------------------------------------------------- /src/utils/redis.ts: -------------------------------------------------------------------------------- 1 | import * as Redis from 'ioredis'; 2 | 3 | // export const redis = new Redis(parseInt(process.env.REDIS_PORT),`${process.env.REDIS_HOST}`); 4 | 5 | export const redis = new Redis(process.env.REDIS_URL); -------------------------------------------------------------------------------- /dist/app.controller.d.ts: -------------------------------------------------------------------------------- 1 | import { AppService } from './app.service'; 2 | export declare class AppController { 3 | private readonly appService; 4 | constructor(appService: AppService); 5 | getHello(): string; 6 | } 7 | -------------------------------------------------------------------------------- /dist/src/app.controller.d.ts: -------------------------------------------------------------------------------- 1 | import { AppService } from './app.service'; 2 | export declare class AppController { 3 | private readonly appService; 4 | constructor(appService: AppService); 5 | getHello(): string; 6 | } 7 | -------------------------------------------------------------------------------- /dist/poll/entities/poll-option.entity.d.ts: -------------------------------------------------------------------------------- 1 | import { Poll } from './poll.entity'; 2 | export declare class PollOption { 3 | id: string; 4 | text: string; 5 | vote: number; 6 | pollId: string; 7 | poll: Promise; 8 | } 9 | -------------------------------------------------------------------------------- /test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/utils/redis.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.redis = void 0; 4 | const Redis = require("ioredis"); 5 | exports.redis = new Redis(process.env.REDIS_URL); 6 | //# sourceMappingURL=redis.js.map -------------------------------------------------------------------------------- /dist/user/user.controller.d.ts: -------------------------------------------------------------------------------- 1 | import { UserService } from './user.service'; 2 | export declare class UserController { 3 | private readonly userService; 4 | constructor(userService: UserService); 5 | confirmEmail(id: string): Promise; 6 | } 7 | -------------------------------------------------------------------------------- /src/poll/dto/create-poll.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Field } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CreatePollInput { 5 | 6 | @Field(() => String) 7 | name: string; 8 | 9 | @Field(() => [String]) 10 | options: string[]; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/shared/error-response.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from "@nestjs/graphql"; 2 | 3 | @ObjectType() 4 | export class ErrorResponse { 5 | @Field(() => String ,{nullable:true}) 6 | path: string; 7 | @Field(() => String, {nullable:true}) 8 | message: string; 9 | } -------------------------------------------------------------------------------- /dist/user/user.entity.d.ts: -------------------------------------------------------------------------------- 1 | import { Poll } from 'src/poll/entities/poll.entity'; 2 | export declare class MainUser { 3 | id: string; 4 | userName: string; 5 | email: string; 6 | password: string; 7 | isActive: boolean; 8 | pollOptions: Promise; 9 | } 10 | -------------------------------------------------------------------------------- /dist/app.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAG5C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AAJY,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB;AAJY,gCAAU"} -------------------------------------------------------------------------------- /dist/poll/dto/update-poll.input.d.ts: -------------------------------------------------------------------------------- 1 | import { CreatePollInput } from './create-poll.input'; 2 | declare const UpdatePollInput_base: import("@nestjs/common").Type>; 3 | export declare class UpdatePollInput extends UpdatePollInput_base { 4 | id: number; 5 | } 6 | export {}; 7 | -------------------------------------------------------------------------------- /dist/src/app.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.service.js","sourceRoot":"","sources":["../../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAG5C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,QAAQ;QACN,OAAO,cAAc,CAAC;IACxB,CAAC;CACF,CAAA;AAJY,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB;AAJY,gCAAU"} -------------------------------------------------------------------------------- /src/poll/dto/update-poll.input.ts: -------------------------------------------------------------------------------- 1 | import { CreatePollInput } from './create-poll.input'; 2 | import { InputType, Field, Int, PartialType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class UpdatePollInput extends PartialType(CreatePollInput) { 6 | @Field(() => Int) 7 | id: number; 8 | } 9 | -------------------------------------------------------------------------------- /dist/src/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"} -------------------------------------------------------------------------------- /src/utils/confirmEmailLinks.ts: -------------------------------------------------------------------------------- 1 | import { v4 } from 'uuid'; 2 | import { redis } from './redis'; 3 | 4 | export const confirmEmailLink = async (userId: string) => { 5 | const id = v4(); 6 | await redis.set(id, userId, 'ex', 60 * 60 * 15); 7 | return `${process.env.BACKEND_HOST}/user/confirm/${id}`; 8 | } -------------------------------------------------------------------------------- /dist/poll/entities/poll.entity.d.ts: -------------------------------------------------------------------------------- 1 | import { MainUser } from 'src/user/user.entity'; 2 | import { PollOption } from './poll-option.entity'; 3 | export declare class Poll { 4 | id: string; 5 | name: string; 6 | userId: string; 7 | user: MainUser; 8 | pollOptions: Promise; 9 | } 10 | -------------------------------------------------------------------------------- /dist/user/user.subscriber.d.ts: -------------------------------------------------------------------------------- 1 | import { EntitySubscriberInterface, InsertEvent } from "typeorm"; 2 | import { MainUser } from "./user.entity"; 3 | export declare class PostSubscriber implements EntitySubscriberInterface { 4 | listenTo(): typeof MainUser; 5 | beforeInsert(event: InsertEvent): Promise; 6 | } 7 | -------------------------------------------------------------------------------- /src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dist/src/config/typeOrmConfig.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"typeOrmConfig.js","sourceRoot":"","sources":["../../../src/config/typeOrmConfig.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAyB;IAC/C,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,CAAC,SAAS,GAAG,0BAA0B,CAAC;IAClD,WAAW,EAAE,IAAI;CACpB,CAAA"} -------------------------------------------------------------------------------- /dist/user/dto/update-user.input.d.ts: -------------------------------------------------------------------------------- 1 | import { CreateUserInput } from './create-user.input'; 2 | declare const UpdateUserInput_base: import("@nestjs/common").Type>; 3 | export declare class UpdateUserInput extends UpdateUserInput_base { 4 | id: string; 5 | userName: string; 6 | email: string; 7 | isActive: boolean; 8 | } 9 | export {}; 10 | -------------------------------------------------------------------------------- /dist/src/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const core_1 = require("@nestjs/core"); 4 | const app_module_1 = require("./app.module"); 5 | async function bootstrap() { 6 | const app = await core_1.NestFactory.create(app_module_1.AppModule); 7 | await app.listen(3000); 8 | } 9 | bootstrap(); 10 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /dist/poll/dto/update-poll.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"update-poll.input.js","sourceRoot":"","sources":["../../../src/poll/dto/update-poll.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAsD;AACtD,6CAAqE;AAGrE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,IAAA,qBAAW,EAAC,mCAAe,CAAC;CAGhE,CAAA;AADC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,aAAG,CAAC;;2CACN;AAFA,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAG3B;AAHY,0CAAe"} -------------------------------------------------------------------------------- /dist/src/user/dto/update-user.input.d.ts: -------------------------------------------------------------------------------- 1 | import { CreateUserInput } from './create-user.input'; 2 | declare const UpdateUserInput_base: import("@nestjs/common").Type>; 3 | export declare class UpdateUserInput extends UpdateUserInput_base { 4 | id: number; 5 | userName: string; 6 | email: string; 7 | password: string; 8 | isActive: boolean; 9 | } 10 | export {}; 11 | -------------------------------------------------------------------------------- /dist/poll/dto/create-poll.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"create-poll.input.js","sourceRoot":"","sources":["../../../src/poll/dto/create-poll.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AAGnD,IAAa,eAAe,GAA5B,MAAa,eAAe;CAQ3B,CAAA;AALC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;6CACP;AAGb;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;;gDACJ;AANP,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAQ3B;AARY,0CAAe"} -------------------------------------------------------------------------------- /src/user/user.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Param } from '@nestjs/common'; 2 | import { UserService } from './user.service'; 3 | 4 | @Controller('user') 5 | export class UserController { 6 | constructor(private readonly userService: UserService){} 7 | @Get('/confirm/:id') 8 | confirmEmail(@Param('id') id: string) { 9 | return this.userService.confirmEmail(id); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /dist/shared/getuserid.decorator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"getuserid.decorator.js","sourceRoot":"","sources":["../../src/shared/getuserid.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,6CAAsD;AACtD,oDAAiD;AAEpC,QAAA,SAAS,GAAG,IAAA,6BAAoB,EACzC,CAAC,IAAa,EAAE,GAAqB,EAAE,EAAE;IACrC,MAAM,OAAO,GAAc,6BAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IACxE,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AACzC,CAAC,CACJ,CAAC"} -------------------------------------------------------------------------------- /src/user/dto/login-user.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Field } from '@nestjs/graphql'; 2 | import { MainUser } from '../user.entity'; 3 | 4 | @InputType({description: "Login Input"}) 5 | export class LoginUserInput implements Partial { 6 | 7 | @Field(() => String, { description: 'email' }) 8 | email: string; 9 | 10 | @Field(() => String, { description: 'password' }) 11 | password: string; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /dist/app.controller.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,+CAA2C;AAG3C,IAAa,aAAa,GAA1B,MAAa,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAA;AAHC;IADC,IAAA,YAAG,GAAE;;;;6CAGL;AANU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAOzB;AAPY,sCAAa"} -------------------------------------------------------------------------------- /dist/src/app.controller.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,+CAA2C;AAG3C,IAAa,aAAa,GAA1B,MAAa,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAA;AAHC;IADC,IAAA,YAAG,GAAE;;;;6CAGL;AANU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAOzB;AAPY,sCAAa"} -------------------------------------------------------------------------------- /dist/shared/error-response.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"error-response.js","sourceRoot":"","sources":["../../src/shared/error-response.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AAGpD,IAAa,aAAa,GAA1B,MAAa,aAAa;CAKzB,CAAA;AAHG;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAC,IAAI,EAAC,CAAC;;2CACxB;AAEb;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAC,QAAQ,EAAC,IAAI,EAAC,CAAC;;8CACrB;AAJP,aAAa;IADzB,IAAA,oBAAU,GAAE;GACA,aAAa,CAKzB;AALY,sCAAa"} -------------------------------------------------------------------------------- /dist/src/user/user.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../../src/user/user.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,mDAA+C;AAC/C,+CAAqC;AACrC,6CAAgD;AAShD,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IAPtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,CAAC,CAAC;SACjC;QACD,OAAO,EAAE,CAAC,uBAAa,CAAC;QACxB,SAAS,EAAE,CAAC,4BAAY,EAAE,0BAAW,CAAC;KACvC,CAAC;GACW,UAAU,CAAG;AAAb,gCAAU"} -------------------------------------------------------------------------------- /dist/utils/confirmEmailLinks.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"confirmEmailLinks.js","sourceRoot":"","sources":["../../src/utils/confirmEmailLinks.ts"],"names":[],"mappings":";;;AAAA,+BAA0B;AAC1B,mCAAgC;AAEzB,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;IACrD,MAAM,EAAE,GAAG,IAAA,SAAE,GAAE,CAAC;IAChB,MAAM,aAAK,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IAChD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,iBAAiB,EAAE,EAAE,CAAC;AAC5D,CAAC,CAAA;AAJY,QAAA,gBAAgB,oBAI5B"} -------------------------------------------------------------------------------- /src/shared/getuserid.decorator.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from "@nestjs/common"; 2 | import { GqlExecutionContext } from "@nestjs/graphql"; 3 | import { MyContext } from "src/types/my-context"; 4 | 5 | export const GetUserId = createParamDecorator( 6 | (data: unknown, ctx: ExecutionContext) => { 7 | const context: MyContext = GqlExecutionContext.create(ctx).getContext(); 8 | return context.req.session['userId']; 9 | } 10 | ); -------------------------------------------------------------------------------- /dist/poll/poll.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"poll.module.js","sourceRoot":"","sources":["../../src/poll/poll.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,mDAA+C;AAC/C,wDAA8C;AAC9C,sEAA2D;AAC3D,6CAAgD;AAWhD,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IATtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,+BAAU,CAAC,CAAC;SAC7C;QACD,OAAO,EAAE;YACP,uBAAa;SACd;QACD,SAAS,EAAE,CAAC,4BAAY,EAAE,0BAAW,CAAC;KACvC,CAAC;GACW,UAAU,CAAG;AAAb,gCAAU"} -------------------------------------------------------------------------------- /dist/src/config/typeOrmConfig.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.typeOrmConfig = void 0; 4 | exports.typeOrmConfig = { 5 | type: 'postgres', 6 | host: 'localhost', 7 | port: 5432, 8 | username: 'postgres', 9 | password: 'hassan121', 10 | database: 'votingDB', 11 | entities: [__dirname + '/../**/*.entity{.ts,.js}'], 12 | synchronize: true, 13 | }; 14 | //# sourceMappingURL=typeOrmConfig.js.map -------------------------------------------------------------------------------- /dist/user/user.subscriber.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.subscriber.js","sourceRoot":"","sources":["../../src/user/user.subscriber.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAkF;AAClF,+CAAyC;AACzC,mCAAmC;AAGnC,IAAa,cAAc,GAA3B,MAAa,cAAc;IAMvB,QAAQ;QACJ,OAAO,sBAAQ,CAAC;IACpB,CAAC;IAKD,KAAK,CAAC,YAAY,CAAC,KAA4B;QAE3C,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEzE,CAAC;CAEJ,CAAA;AAnBY,cAAc;IAD1B,IAAA,yBAAe,GAAE;GACL,cAAc,CAmB1B;AAnBY,wCAAc"} -------------------------------------------------------------------------------- /dist/user/dto/login-user.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"login-user.input.js","sourceRoot":"","sources":["../../../src/user/dto/login-user.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AAInD,IAAa,cAAc,GAA3B,MAAa,cAAc;CAQ1B,CAAA;AALC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;;6CAChC;AAGd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;gDAChC;AANN,cAAc;IAD1B,IAAA,mBAAS,EAAC,EAAC,WAAW,EAAE,aAAa,EAAC,CAAC;GAC3B,cAAc,CAQ1B;AARY,wCAAc"} -------------------------------------------------------------------------------- /src/user/dto/create-user.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Field } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CreateUserInput { 5 | 6 | @Field(() => String, { description: 'Name' }) 7 | userName: string; 8 | 9 | @Field(() => String, { description: 'Department' }) 10 | email: string; 11 | 12 | @Field(() => String, { description: 'password' }) 13 | password: string; 14 | 15 | // @Field(() => Boolean, { description: 'active' }) 16 | // isActive: boolean; 17 | } 18 | -------------------------------------------------------------------------------- /dist/shared/response-object.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"response-object.js","sourceRoot":"","sources":["../../src/shared/response-object.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AAGpD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAKvB,YAAY,IAAY,EAAE,KAAa;QACnC,IAAI,CAAC,IAAI,GAAC,IAAI,CAAC;QACf,IAAI,CAAC,KAAK,GAAC,KAAK,CAAC;IACrB,CAAC;CACJ,CAAA;AAPG;IADC,IAAA,eAAK,EAAC,EAAC,QAAQ,EAAC,IAAI,EAAC,CAAC;;4CACX;AAEZ;IADC,IAAA,eAAK,EAAC,EAAC,QAAQ,EAAC,IAAI,EAAC,CAAC;;6CACV;AAJJ,cAAc;IAD1B,IAAA,oBAAU,GAAE;;GACA,cAAc,CAS1B;AATY,wCAAc"} -------------------------------------------------------------------------------- /dist/user/user.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.module.js","sourceRoot":"","sources":["../../src/user/user.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,mDAA+C;AAC/C,+CAAyC;AACzC,6CAAgD;AAChD,uDAAmD;AAUnD,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IARtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,UAAU,CAAC,CAAC,sBAAQ,CAAC,CAAC;SACrC;QACD,OAAO,EAAE,CAAC,uBAAa,CAAC;QACxB,SAAS,EAAE,CAAC,4BAAY,EAAE,0BAAW,CAAC;QACtC,WAAW,EAAE,CAAC,gCAAc,CAAC;KAC9B,CAAC;GACW,UAAU,CAAG;AAAb,gCAAU"} -------------------------------------------------------------------------------- /dist/user/user.controller.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.controller.js","sourceRoot":"","sources":["../../src/user/user.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwD;AACxD,iDAA6C;AAG7C,IAAa,cAAc,GAA3B,MAAa,cAAc;IACvB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAE,CAAC;IAExD,YAAY,CAAc,EAAU;QAChC,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAHG;IADC,IAAA,YAAG,EAAC,cAAc,CAAC;IACN,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;kDAExB;AALQ,cAAc;IAD1B,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAE2B,0BAAW;GAD5C,cAAc,CAM1B;AANY,wCAAc"} -------------------------------------------------------------------------------- /dist/utils/confirmEmailLinks.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.confirmEmailLink = void 0; 4 | const uuid_1 = require("uuid"); 5 | const redis_1 = require("./redis"); 6 | const confirmEmailLink = async (userId) => { 7 | const id = (0, uuid_1.v4)(); 8 | await redis_1.redis.set(id, userId, 'ex', 60 * 60 * 15); 9 | return `${process.env.BACKEND_HOST}/user/confirm/${id}`; 10 | }; 11 | exports.confirmEmailLink = confirmEmailLink; 12 | //# sourceMappingURL=confirmEmailLinks.js.map -------------------------------------------------------------------------------- /dist/user/dto/create-user.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"create-user.input.js","sourceRoot":"","sources":["../../../src/user/dto/create-user.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AAGnD,IAAa,eAAe,GAA5B,MAAa,eAAe;CAa3B,CAAA;AAVC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;iDAC5B;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;8CACrC;AAGd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;iDAChC;AATN,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAa3B;AAbY,0CAAe"} -------------------------------------------------------------------------------- /dist/shared/getuserid.decorator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.GetUserId = void 0; 4 | const common_1 = require("@nestjs/common"); 5 | const graphql_1 = require("@nestjs/graphql"); 6 | const my_context_1 = require("../types/my-context"); 7 | exports.GetUserId = (0, common_1.createParamDecorator)((data, ctx) => { 8 | const context = graphql_1.GqlExecutionContext.create(ctx).getContext(); 9 | return context.req.session['userId']; 10 | }); 11 | //# sourceMappingURL=getuserid.decorator.js.map -------------------------------------------------------------------------------- /src/poll/poll.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PollService } from './poll.service'; 3 | import { PollResolver } from './poll.resolver'; 4 | import { Poll } from './entities/poll.entity'; 5 | import { PollOption } from './entities/poll-option.entity'; 6 | import { TypeOrmModule } from '@nestjs/typeorm'; 7 | 8 | @Module({ 9 | imports: [ 10 | TypeOrmModule.forFeature([Poll, PollOption]) 11 | ], 12 | exports: [ 13 | TypeOrmModule 14 | ], 15 | providers: [PollResolver, PollService] 16 | }) 17 | export class PollModule {} 18 | -------------------------------------------------------------------------------- /src/user/user.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UserService } from './user.service'; 3 | import { UserResolver } from './user.resolver'; 4 | import { MainUser } from './user.entity'; 5 | import { TypeOrmModule } from '@nestjs/typeorm'; 6 | import { UserController } from './user.controller'; 7 | 8 | @Module({ 9 | imports: [ 10 | TypeOrmModule.forFeature([MainUser]) 11 | ], 12 | exports: [TypeOrmModule], 13 | providers: [UserResolver, UserService], 14 | controllers: [UserController] 15 | }) 16 | export class UserModule {} 17 | -------------------------------------------------------------------------------- /dist/user/entities/user.entity.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/user/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyD;AAGzD,IAAa,IAAI,GAAjB,MAAa,IAAI;CAShB,CAAA;AAPC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;8BACvC,MAAM;kCAAC;AAGb;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;8BACvC,MAAM;wCAAC;AAGnB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;8BACvC,MAAM;yCAAC;AART,IAAI;IADhB,IAAA,oBAAU,GAAE;GACA,IAAI,CAShB;AATY,oBAAI"} -------------------------------------------------------------------------------- /dist/src/user/user.service.spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.service.spec.js","sourceRoot":"","sources":["../../../src/user/user.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,iDAA6C;AAE7C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,IAAI,OAAoB,CAAC;IAEzB,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,0BAAW,CAAC;SACzB,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAc,0BAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | # /dist 3 | # /node_modules 4 | .env 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | pnpm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | lerna-debug.log* 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | node_modules 38 | -------------------------------------------------------------------------------- /dist/shared/auth.guard.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/shared/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,6CAAsD;AAItD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,WAAW,CAAC,OAAyB;QACnC,MAAM,GAAG,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,GAAG,GAAY,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC;QAC1C,IAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACrC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;YAChD,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAVY,SAAS;IADrB,IAAA,mBAAU,GAAE;GACA,SAAS,CAUrB;AAVY,8BAAS"} -------------------------------------------------------------------------------- /dist/src/user/user.resolver.spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.resolver.spec.js","sourceRoot":"","sources":["../../../src/user/user.resolver.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,mDAA+C;AAC/C,iDAA6C;AAE7C,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,IAAI,QAAsB,CAAC;IAE3B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,4BAAY,EAAE,0BAAW,CAAC;SACvC,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAe,4BAAY,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /src/shared/auth.guard.ts: -------------------------------------------------------------------------------- 1 | import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; 2 | import { GqlExecutionContext } from '@nestjs/graphql'; 3 | import { Request } from 'express'; 4 | 5 | @Injectable() 6 | export class AuthGuard implements CanActivate { 7 | canActivate(context: ExecutionContext): boolean { 8 | const ctx = GqlExecutionContext.create(context); 9 | const req: Request = ctx.getContext().req; 10 | if(req.session && req.session['userId']) { 11 | console.log('User Id: ' + req.session['userId']) 12 | return true; 13 | } 14 | return false; 15 | } 16 | } -------------------------------------------------------------------------------- /dist/src/user/dto/create-user.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"create-user.input.js","sourceRoot":"","sources":["../../../../src/user/dto/create-user.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmD;AAGnD,IAAa,eAAe,GAA5B,MAAa,eAAe;CAa3B,CAAA;AAVC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;iDAC5B;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;8CACrC;AAGd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;iDAChC;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;iDAC9B;AAZP,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAa3B;AAbY,0CAAe"} -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dist/test/app.e2e-spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.e2e-spec.js","sourceRoot":"","sources":["../../test/app.e2e-spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AAEtD,qCAAqC;AACrC,oDAAgD;AAEhD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,GAAqB,CAAC;IAE1B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,aAAa,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAClE,OAAO,EAAE,CAAC,sBAAS,CAAC;SACrB,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,GAAG,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAC5C,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACjB,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;aAChC,GAAG,CAAC,GAAG,CAAC;aACR,MAAM,CAAC,GAAG,CAAC;aACX,MAAM,CAAC,cAAc,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/poll/poll.resolver.d.ts: -------------------------------------------------------------------------------- 1 | import { PollService } from './poll.service'; 2 | import { Poll } from './entities/poll.entity'; 3 | import { CreatePollInput } from './dto/create-poll.input'; 4 | import { UpdatePollInput } from './dto/update-poll.input'; 5 | export declare class PollResolver { 6 | private readonly pollService; 7 | constructor(pollService: PollService); 8 | createPoll(createPollInput: CreatePollInput, userId: string): Promise; 9 | findAll(userId: string): Promise; 10 | findOne(id: string, userId: string): Promise; 11 | updatePoll(updatePollInput: UpdatePollInput): string; 12 | removePoll(id: number): string; 13 | } 14 | -------------------------------------------------------------------------------- /src/user/dto/update-user.input.ts: -------------------------------------------------------------------------------- 1 | import { CreateUserInput } from './create-user.input'; 2 | import { InputType, Field, PartialType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class UpdateUserInput extends PartialType(CreateUserInput) { 6 | @Field(() => String, { description: 'Name' }) 7 | id: string; 8 | 9 | @Field(() => String, { description: 'Name' }) 10 | userName: string; 11 | 12 | @Field(() => String, { description: 'Department' }) 13 | email: string; 14 | 15 | // @Field(() => String, { description: 'password' }) 16 | // password: string; 17 | 18 | @Field(() => Boolean, { description: 'active' }) 19 | isActive: boolean; 20 | } 21 | -------------------------------------------------------------------------------- /dist/src/app.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6CAAgD;AAChD,2DAA+E;AAC/E,+BAA4B;AAC5B,qDAAiD;AACjD,+CAA2C;AAC3C,0DAAuD;AACvD,oDAAgD;AAgBhD,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAdrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,OAAO,CAAC,6BAAa,CAAC;YACpC,uBAAa,CAAC,OAAO,CAAC;gBACpB,cAAc,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;gBACrD,UAAU,EAAE,KAAK;gBACjB,OAAO,EAAE,CAAC,IAAA,8DAAyC,GAAE,CAAC;gBACtD,UAAU,EAAE,IAAI;aACjB,CAAC;YACF,wBAAU;SACX;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"} -------------------------------------------------------------------------------- /dist/user/dto/update-user.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"update-user.input.js","sourceRoot":"","sources":["../../../src/user/dto/update-user.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAsD;AACtD,6CAAgE;AAGhE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,IAAA,qBAAW,EAAC,mCAAe,CAAC;CAehE,CAAA;AAbC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;2CAClC;AAGX;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;iDAC5B;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;8CACrC;AAMd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;iDAC9B;AAdP,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAe3B;AAfY,0CAAe"} -------------------------------------------------------------------------------- /dist/src/user/user.service.spec.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const testing_1 = require("@nestjs/testing"); 4 | const user_service_1 = require("./user.service"); 5 | describe('UserService', () => { 6 | let service; 7 | beforeEach(async () => { 8 | const module = await testing_1.Test.createTestingModule({ 9 | providers: [user_service_1.UserService], 10 | }).compile(); 11 | service = module.get(user_service_1.UserService); 12 | }); 13 | it('should be defined', () => { 14 | expect(service).toBeDefined(); 15 | }); 16 | }); 17 | //# sourceMappingURL=user.service.spec.js.map -------------------------------------------------------------------------------- /dist/src/app.controller.spec.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.controller.spec.js","sourceRoot":"","sources":["../../src/app.controller.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,qDAAiD;AACjD,+CAA2C;AAE3C,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,aAA4B,CAAC;IAEjC,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,GAAG,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YACxD,WAAW,EAAE,CAAC,8BAAa,CAAC;YAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;SACxB,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,aAAa,GAAG,GAAG,CAAC,GAAG,CAAgB,8BAAa,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} -------------------------------------------------------------------------------- /dist/utils/sendEmail.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../../src/utils/sendEmail.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AAIlC,MAAM,SAAS,GAAG,KAAK,EAAE,SAAgB,EAAE,IAAY,EAAE,EAAE;IAMhE,IAAI,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC;QAC3C,IAAI,EAAE,2BAA2B;QACjC,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,KAAK;QACb,IAAI,EAAE;YACJ,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,4FAA4F,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB;SACnI;KACF,CAAC,CAAC;IAGH,IAAI,IAAI,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC;QACpC,IAAI,EAAE,iCAAiC;QACvC,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,gCAAgC,IAAI,qBAAqB;KAChE,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAMlD,CAAC,CAAA;AA/BY,QAAA,SAAS,aA+BrB"} -------------------------------------------------------------------------------- /dist/config/typeOrmConfig.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"typeOrmConfig.js","sourceRoot":"","sources":["../../src/config/typeOrmConfig.ts"],"names":[],"mappings":";;;AAEa,QAAA,aAAa,GAAyB;IAC/C,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IACzB,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IAC7B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IAC7B,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;IAC7B,QAAQ,EAAE,CAAC,SAAS,GAAG,0BAA0B,CAAC;IAClD,WAAW,EAAE,CAAC,SAAS,GAAG,8BAA8B,CAAC;IACzD,WAAW,EAAE,KAAK;CAErB,CAAA;AAEY,QAAA,iBAAiB,GAAyB;IACnD,IAAI,EAAE,UAAU;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;IAC7B,QAAQ,EAAE,CAAC,SAAS,GAAG,0BAA0B,CAAC;IAClD,WAAW,EAAE,CAAC,SAAS,GAAG,8BAA8B,CAAC;IAEzD,MAAM,EAAE,gBAAgB;IAIxB,WAAW,EAAE,KAAK;CAGrB,CAAA"} -------------------------------------------------------------------------------- /src/poll/entities/poll-option.entity.ts: -------------------------------------------------------------------------------- 1 | import { ObjectType, Field, Int } from '@nestjs/graphql'; 2 | import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; 3 | import { Poll } from './poll.entity'; 4 | 5 | @ObjectType() 6 | @Entity() 7 | export class PollOption { 8 | @Field(() => String) 9 | @PrimaryGeneratedColumn('uuid') 10 | id: string; 11 | 12 | @Field(() => String) 13 | @Column() 14 | text: string; 15 | 16 | @Field(() => Int) 17 | @Column() 18 | vote: number; 19 | 20 | @Field(() => String) 21 | @Column() 22 | pollId: string; 23 | 24 | @Field(() => Poll) 25 | @ManyToOne(() => Poll, poll => poll.pollOptions) 26 | poll: Promise; 27 | } 28 | -------------------------------------------------------------------------------- /src/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppController', () => { 6 | let appController: AppController; 7 | 8 | beforeEach(async () => { 9 | const app: TestingModule = await Test.createTestingModule({ 10 | controllers: [AppController], 11 | providers: [AppService], 12 | }).compile(); 13 | 14 | appController = app.get(AppController); 15 | }); 16 | 17 | describe('root', () => { 18 | it('should return "Hello World!"', () => { 19 | expect(appController.getHello()).toBe('Hello World!'); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | parserOptions: { 4 | project: 'tsconfig.json', 5 | sourceType: 'module', 6 | }, 7 | plugins: ['@typescript-eslint/eslint-plugin'], 8 | extends: [ 9 | 'plugin:@typescript-eslint/recommended', 10 | 'plugin:prettier/recommended', 11 | ], 12 | root: true, 13 | env: { 14 | node: true, 15 | jest: true, 16 | }, 17 | ignorePatterns: ['.eslintrc.js'], 18 | rules: { 19 | '@typescript-eslint/interface-name-prefix': 'off', 20 | '@typescript-eslint/explicit-function-return-type': 'off', 21 | '@typescript-eslint/explicit-module-boundary-types': 'off', 22 | '@typescript-eslint/no-explicit-any': 'off', 23 | }, 24 | }; 25 | -------------------------------------------------------------------------------- /test/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { INestApplication } from '@nestjs/common'; 3 | import * as request from 'supertest'; 4 | import { AppModule } from './../src/app.module'; 5 | 6 | describe('AppController (e2e)', () => { 7 | let app: INestApplication; 8 | 9 | beforeEach(async () => { 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); 13 | 14 | app = moduleFixture.createNestApplication(); 15 | await app.init(); 16 | }); 17 | 18 | it('/ (GET)', () => { 19 | return request(app.getHttpServer()) 20 | .get('/') 21 | .expect(200) 22 | .expect('Hello World!'); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /src/user/user.subscriber.ts: -------------------------------------------------------------------------------- 1 | import { EntitySubscriberInterface, EventSubscriber, InsertEvent } from "typeorm"; 2 | import { MainUser } from "./user.entity"; 3 | import * as bcrypt from 'bcryptjs'; 4 | 5 | @EventSubscriber() 6 | export class PostSubscriber implements EntitySubscriberInterface { 7 | 8 | 9 | /** 10 | * Indicates that this subscriber only listen to Post events. 11 | */ 12 | listenTo() { 13 | return MainUser; 14 | } 15 | 16 | /** 17 | * Called before post insertion. 18 | */ 19 | async beforeInsert(event: InsertEvent) { 20 | 21 | event.entity.password = await bcrypt.hash(event.entity.password, 12); 22 | // console.log(`BEFORE POST INSERTED: `, event.entity); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /dist/src/user/dto/update-user.input.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"update-user.input.js","sourceRoot":"","sources":["../../../../src/user/dto/update-user.input.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAsD;AACtD,6CAAgE;AAGhE,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,IAAA,qBAAW,EAAC,mCAAe,CAAC;CAehE,CAAA;AAbC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;2CAClC;AAGX;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;iDAC5B;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;8CACrC;AAGd;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;iDAChC;AAGjB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;;iDAC9B;AAdP,eAAe;IAD3B,IAAA,mBAAS,GAAE;GACC,eAAe,CAe3B;AAfY,0CAAe"} -------------------------------------------------------------------------------- /dist/src/user/user.resolver.spec.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const testing_1 = require("@nestjs/testing"); 4 | const user_resolver_1 = require("./user.resolver"); 5 | const user_service_1 = require("./user.service"); 6 | describe('UserResolver', () => { 7 | let resolver; 8 | beforeEach(async () => { 9 | const module = await testing_1.Test.createTestingModule({ 10 | providers: [user_resolver_1.UserResolver, user_service_1.UserService], 11 | }).compile(); 12 | resolver = module.get(user_resolver_1.UserResolver); 13 | }); 14 | it('should be defined', () => { 15 | expect(resolver).toBeDefined(); 16 | }); 17 | }); 18 | //# sourceMappingURL=user.resolver.spec.js.map -------------------------------------------------------------------------------- /src/poll/entities/poll.entity.ts: -------------------------------------------------------------------------------- 1 | import { ObjectType, Field, Int } from '@nestjs/graphql'; 2 | import { MainUser } from 'src/user/user.entity'; 3 | import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; 4 | import { PollOption } from './poll-option.entity'; 5 | 6 | @ObjectType() 7 | @Entity() 8 | export class Poll { 9 | @Field(() => String) 10 | @PrimaryGeneratedColumn('uuid') 11 | id: string; 12 | 13 | @Field(() => String) 14 | @Column() 15 | name: string; 16 | 17 | @Field(() => String) 18 | @Column() 19 | userId: string; 20 | 21 | @ManyToOne(() => MainUser) 22 | user: MainUser; 23 | 24 | @Field(() => [PollOption]) 25 | @OneToMany(() => PollOption, polloption => polloption.poll) 26 | pollOptions: Promise; 27 | } 28 | -------------------------------------------------------------------------------- /dist/poll/poll.service.d.ts: -------------------------------------------------------------------------------- 1 | import { Repository } from 'typeorm'; 2 | import { CreatePollInput } from './dto/create-poll.input'; 3 | import { UpdatePollInput } from './dto/update-poll.input'; 4 | import { PollOption } from './entities/poll-option.entity'; 5 | import { Poll } from './entities/poll.entity'; 6 | export declare class PollService { 7 | private pollRepository; 8 | private pollOptionRepository; 9 | constructor(pollRepository: Repository, pollOptionRepository: Repository); 10 | create(createPollInput: CreatePollInput, userId: string): Promise; 11 | findAll(userId: string): Promise; 12 | findOne(id: string, userId: any): Promise; 13 | update(id: number, updatePollInput: UpdatePollInput): string; 14 | remove(id: number): string; 15 | } 16 | -------------------------------------------------------------------------------- /dist/poll/entities/poll.entity.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"poll.entity.js","sourceRoot":"","sources":["../../../src/poll/entities/poll.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyD;AACzD,wDAAgD;AAChD,qCAAuF;AACvF,6DAAkD;AAIlD,IAAa,IAAI,GAAjB,MAAa,IAAI;CAmBhB,CAAA;AAhBC;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gCAAsB,EAAC,MAAM,CAAC;;gCACpB;AAIX;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gBAAM,GAAE;;kCACI;AAIb;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gBAAM,GAAE;;oCACM;AAGf;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,sBAAQ,CAAC;8BACpB,sBAAQ;kCAAC;AAIf;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,+BAAU,CAAC,CAAC;IACzB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,+BAAU,EAAE,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;;yCACxB;AAlBxB,IAAI;IAFhB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;GACI,IAAI,CAmBhB;AAnBY,oBAAI"} -------------------------------------------------------------------------------- /dist/poll/entities/poll-option.entity.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"poll-option.entity.js","sourceRoot":"","sources":["../../../src/poll/entities/poll-option.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyD;AACzD,qCAA4E;AAC5E,+CAAqC;AAIrC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAoBtB,CAAA;AAjBG;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gCAAsB,EAAC,MAAM,CAAC;;sCACpB;AAIX;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gBAAM,GAAE;;wCACI;AAIb;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,aAAG,CAAC;IAChB,IAAA,gBAAM,GAAE;;wCACI;AAIb;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACnB,IAAA,gBAAM,GAAE;;0CACM;AAIf;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACjB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;wCAC5B;AAnBX,UAAU;IAFtB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;GACI,UAAU,CAoBtB;AApBY,gCAAU"} -------------------------------------------------------------------------------- /dist/src/user/user.service.d.ts: -------------------------------------------------------------------------------- 1 | import { Repository } from 'typeorm'; 2 | import { CreateUserInput } from './dto/create-user.input'; 3 | import { UpdateUserInput } from './dto/update-user.input'; 4 | import { User } from './user.entity'; 5 | export declare class UserService { 6 | private usersRepository; 7 | constructor(usersRepository: Repository); 8 | create(createUserInput: CreateUserInput): Promise<({ 9 | userName: string; 10 | email: string; 11 | password: string; 12 | isActive: boolean; 13 | } & User) | { 14 | path: string; 15 | message: string; 16 | }[]>; 17 | findAll(): Promise; 18 | findOne(id: number): Promise; 19 | update(id: number, updateUserInput: UpdateUserInput): string; 20 | remove(id: number): string; 21 | } 22 | -------------------------------------------------------------------------------- /dist/src/user/user.resolver.d.ts: -------------------------------------------------------------------------------- 1 | import { UserService } from './user.service'; 2 | import { User } from './user.entity'; 3 | import { CreateUserInput } from './dto/create-user.input'; 4 | import { UpdateUserInput } from './dto/update-user.input'; 5 | export declare class UserResolver { 6 | private readonly userService; 7 | constructor(userService: UserService); 8 | findAll(): Promise; 9 | findOne(id: number): Promise; 10 | createUser(createUser: CreateUserInput): Promise<({ 11 | userName: string; 12 | email: string; 13 | password: string; 14 | isActive: boolean; 15 | } & User) | { 16 | path: string; 17 | message: string; 18 | }[]>; 19 | updateUser(updateUserInput: UpdateUserInput): string; 20 | removeUser(id: number): string; 21 | } 22 | -------------------------------------------------------------------------------- /dist/test/app.e2e-spec.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const testing_1 = require("@nestjs/testing"); 4 | const request = require("supertest"); 5 | const app_module_1 = require("./../src/app.module"); 6 | describe('AppController (e2e)', () => { 7 | let app; 8 | beforeEach(async () => { 9 | const moduleFixture = await testing_1.Test.createTestingModule({ 10 | imports: [app_module_1.AppModule], 11 | }).compile(); 12 | app = moduleFixture.createNestApplication(); 13 | await app.init(); 14 | }); 15 | it('/ (GET)', () => { 16 | return request(app.getHttpServer()) 17 | .get('/') 18 | .expect(200) 19 | .expect('Hello World!'); 20 | }); 21 | }); 22 | //# sourceMappingURL=app.e2e-spec.js.map -------------------------------------------------------------------------------- /dist/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,6CAAyC;AACzC,uCAAuC;AACvC,2CAA2C;AAC3C,8CAA8C;AAC9C,iCAAiC;AACjC,yCAAsC;AAEtC,MAAM,CAAC,MAAM,EAAE,CAAA;AAEf,KAAK,UAAU,SAAS;IACtB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;IACxB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QACd,KAAK,EAAE,IAAI,UAAU,CAAC,EAAC,MAAM,EAAE,aAAK,EAAC,CAAC;QACtC,IAAI,EAAE,WAAW;QACjB,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE,KAAK;QACb,iBAAiB,EAAE,KAAK;QACxB,MAAM,EAAE;YACN,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YAC7C,MAAM,EAAE,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;SAC5B;KACF,CAAC,CAAC,CAAC;IAEJ,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAC7C,CAAC;AACD,SAAS,EAAE,CAAC"} -------------------------------------------------------------------------------- /dist/src/user/user.entity.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/user/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AACpD,qCAAiE;AAKjE,IAAa,IAAI,GAAjB,MAAa,IAAI;CAoBhB,CAAA;AAjBC;IAFC,IAAA,gCAAsB,GAAE;IACxB,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;;gCAClC;AAIX;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IAC5C,IAAA,gBAAM,GAAE;;sCACQ;AAIjB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;IAClD,IAAA,gBAAM,GAAE;;mCACK;AAId;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAChD,IAAA,gBAAM,GAAE;;sCACQ;AAIjB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC/C,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;sCACR;AAnBP,IAAI;IAFhB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;GACI,IAAI,CAoBhB;AApBY,oBAAI"} -------------------------------------------------------------------------------- /dist/user/user.resolver.d.ts: -------------------------------------------------------------------------------- 1 | import { UserService } from './user.service'; 2 | import { MainUser } from './user.entity'; 3 | import { CreateUserInput } from './dto/create-user.input'; 4 | import { UpdateUserInput } from './dto/update-user.input'; 5 | import { LoginUserInput } from './dto/login-user.input'; 6 | import { MyContext } from 'src/types/my-context'; 7 | export declare class UserResolver { 8 | private readonly userService; 9 | constructor(userService: UserService); 10 | findAll(): Promise; 11 | findOne(id: string): Promise; 12 | createUser(createUser: CreateUserInput): Promise; 13 | updateUser(updateUserInput: UpdateUserInput): Promise; 14 | removeUser(id: number): string; 15 | loginUser(loginInput: LoginUserInput, ctx: MyContext): Promise; 16 | logout(ctx: MyContext): Promise; 17 | } 18 | -------------------------------------------------------------------------------- /dist/config/typeOrmConfig.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.typeOrmProdConfig = exports.typeOrmConfig = void 0; 4 | exports.typeOrmConfig = { 5 | type: 'postgres', 6 | host: process.env.DB_HOST, 7 | port: 5432, 8 | username: process.env.DB_User, 9 | password: process.env.DB_PASS, 10 | database: process.env.DB_NAME, 11 | entities: [__dirname + '/../**/*.entity{.ts,.js}'], 12 | subscribers: [__dirname + '/../**/*.subscriber{.ts,.js}'], 13 | synchronize: false, 14 | }; 15 | exports.typeOrmProdConfig = { 16 | type: 'postgres', 17 | url: process.env.DATABASE_URL, 18 | entities: [__dirname + '/../**/*.entity{.ts,.js}'], 19 | subscribers: [__dirname + '/../**/*.subscriber{.ts,.js}'], 20 | logger: 'simple-console', 21 | synchronize: false, 22 | }; 23 | //# sourceMappingURL=typeOrmConfig.js.map -------------------------------------------------------------------------------- /dist/src/app.controller.spec.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const testing_1 = require("@nestjs/testing"); 4 | const app_controller_1 = require("./app.controller"); 5 | const app_service_1 = require("./app.service"); 6 | describe('AppController', () => { 7 | let appController; 8 | beforeEach(async () => { 9 | const app = await testing_1.Test.createTestingModule({ 10 | controllers: [app_controller_1.AppController], 11 | providers: [app_service_1.AppService], 12 | }).compile(); 13 | appController = app.get(app_controller_1.AppController); 14 | }); 15 | describe('root', () => { 16 | it('should return "Hello World!"', () => { 17 | expect(appController.getHello()).toBe('Hello World!'); 18 | }); 19 | }); 20 | }); 21 | //# sourceMappingURL=app.controller.spec.js.map -------------------------------------------------------------------------------- /dist/user/user.service.d.ts: -------------------------------------------------------------------------------- 1 | import { Repository } from 'typeorm'; 2 | import { CreateUserInput } from './dto/create-user.input'; 3 | import { LoginUserInput } from './dto/login-user.input'; 4 | import { UpdateUserInput } from './dto/update-user.input'; 5 | import { MainUser } from './user.entity'; 6 | import { MyContext } from 'src/types/my-context'; 7 | export declare class UserService { 8 | private usersRepository; 9 | constructor(usersRepository: Repository); 10 | create(createUserInput: CreateUserInput): Promise; 11 | findAll(): Promise; 12 | findOne(id: string): Promise; 13 | update(id: string, updateUserInput: UpdateUserInput): Promise; 14 | confirmEmail(id: string): Promise; 15 | remove(id: number): string; 16 | login(loginInput: LoginUserInput, ctx: MyContext): Promise; 17 | logout(ctx: MyContext): Promise; 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | import * as Store from 'connect-redis'; 4 | import * as session from 'express-session'; 5 | import * as cookieParser from 'cookie-parser'; 6 | import * as dotenv from 'dotenv'; 7 | import { redis } from './utils/redis'; 8 | 9 | dotenv.config() 10 | 11 | async function bootstrap() { 12 | const RedisStore = Store(session); 13 | const app = await NestFactory.create(AppModule); 14 | app.use(cookieParser()); 15 | app.use(session({ 16 | store: new RedisStore({client: redis}), 17 | name: 'votingapp', 18 | secret: '994ikk34k3k42kkk3kk3k3k', 19 | resave: false, 20 | saveUninitialized: false, 21 | cookie: { 22 | httpOnly: true, 23 | secure: process.env.NODE_ENV === 'production', 24 | maxAge: 1000 * 60 * 60 * 24 25 | } 26 | })); 27 | 28 | await app.listen(process.env.PORT || 3000); 29 | } 30 | bootstrap(); 31 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Debug NestJs", 11 | "args": [ 12 | "${workspaceFolder}/src/main.ts" 13 | ], 14 | "runtimeArgs": [ 15 | "--nolazy", 16 | "-r", 17 | "ts-node/register", 18 | "-r", 19 | "tsconfig-paths/register" 20 | ], 21 | "sourceMaps": true, 22 | "envFile": "${workspaceFolder}/.env", 23 | "cwd": "${workspaceRoot}", 24 | "console": "integratedTerminal", 25 | "protocol": "inspector", 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /src/shared/response-object.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from "@nestjs/graphql"; 2 | 3 | @ObjectType() 4 | export class ResponseObject { 5 | @Field({nullable:true}) 6 | data: any[]; 7 | @Field({nullable:true}) 8 | error: any[]; 9 | constructor(data?: any[], error?: any[]) { 10 | this.data=data; 11 | this.error=error; 12 | } 13 | } 14 | 15 | // export default function ResponseObject(TItemClass: TItem) { 16 | // // `isAbstract` decorator option is mandatory to prevent registering in schema 17 | // @ObjectType({ isAbstract: true }) 18 | // abstract class PaginatedResponseClass { 19 | // // here we use the runtime argument 20 | // @Field(type => [TItemClass]) 21 | // // and here the generic type 22 | // items: TItem[]; 23 | 24 | // @Field(type => Int) 25 | // total: number; 26 | 27 | // @Field() 28 | // hasMore: boolean; 29 | // } 30 | // return PaginatedResponseClass; 31 | // } -------------------------------------------------------------------------------- /dist/user/user.entity.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/user/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AACpD,8DAAqD;AACrD,qCAA2E;AAK3E,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAgCpB,CAAA;AA7BC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;;oCACT;AAIX;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAChD,IAAA,gBAAM,GAAE;;0CACQ;AAIjB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;IAC7C,IAAA,gBAAM,GAAE;;uCACK;AAId;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAChD,IAAA,gBAAM,GAAE;;0CACQ;AAIjB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC/C,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;0CACT;AAKlB;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,kBAAI,CAAC,CAAC;IACnB,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;;6CACZ;AAxBlB,QAAQ;IAFpB,IAAA,oBAAU,GAAE;IACZ,IAAA,gBAAM,GAAE;GACI,QAAQ,CAgCpB;AAhCY,4BAAQ"} -------------------------------------------------------------------------------- /src/config/typeOrmConfig.ts: -------------------------------------------------------------------------------- 1 | import { TypeOrmModuleOptions } from "@nestjs/typeorm"; 2 | 3 | export const typeOrmConfig: TypeOrmModuleOptions = { 4 | type: 'postgres', 5 | host: process.env.DB_HOST, 6 | port: 5432, 7 | username: process.env.DB_User, 8 | password: process.env.DB_PASS, 9 | database: process.env.DB_NAME, 10 | entities: [__dirname + '/../**/*.entity{.ts,.js}'], 11 | subscribers: [__dirname + '/../**/*.subscriber{.ts,.js}'], 12 | synchronize: false, 13 | // dropSchema: true 14 | } 15 | 16 | export const typeOrmProdConfig: TypeOrmModuleOptions = { 17 | type: 'postgres', 18 | url: process.env.DATABASE_URL, 19 | entities: [__dirname + '/../**/*.entity{.ts,.js}'], 20 | subscribers: [__dirname + '/../**/*.subscriber{.ts,.js}'], 21 | // migrations: [__dirname + '/migrations/**/*.ts'], 22 | logger: 'simple-console', 23 | // cli: { 24 | // "migrationsDir": "migration" 25 | // }, 26 | synchronize: false, 27 | 28 | // dropSchema: true 29 | } -------------------------------------------------------------------------------- /dist/utils/sendEmail.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.sendEmail = void 0; 4 | const nodemailer = require("nodemailer"); 5 | const sendEmail = async (userEmail, link) => { 6 | let transporter = nodemailer.createTransport({ 7 | host: "smtp-relay.sendinblue.com", 8 | port: 587, 9 | secure: false, 10 | auth: { 11 | user: 'hsn121121@gmail.com', 12 | pass: "xsmtpsib-88cf2bace767261f7d762d28551dce0762ce4bf4dc2cd56230d2e90632ce4e77-nAZTQUtRVMI5s3XO" || process.env.SENDINBLUE_TOKEN, 13 | }, 14 | }); 15 | let info = await transporter.sendMail({ 16 | from: '"Fred Foo 👻" ', 17 | to: userEmail, 18 | subject: "Hello ✔", 19 | text: "Hello world?", 20 | html: `Hello world? Confirm Email`, 21 | }); 22 | console.log("Message sent: %s", info.messageId); 23 | }; 24 | exports.sendEmail = sendEmail; 25 | //# sourceMappingURL=sendEmail.js.map -------------------------------------------------------------------------------- /dist/app.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.AppService = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | let AppService = class AppService { 12 | getHello() { 13 | return 'Hello World!'; 14 | } 15 | }; 16 | AppService = __decorate([ 17 | (0, common_1.Injectable)() 18 | ], AppService); 19 | exports.AppService = AppService; 20 | //# sourceMappingURL=app.service.js.map -------------------------------------------------------------------------------- /dist/src/user/user.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAGrC,+CAAqC;AAGrC,IAAa,WAAW,GAAxB,MAAa,WAAW;IAEtB,YAEU,eAAiC;QAAjC,oBAAe,GAAf,eAAe,CAAkB;IACxC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,eAAgC;QAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,eAAe,CAAC,KAAK,EAAC,EAAC,CAAC,CAAA;QACxF,IAAG,UAAU,EAAE;YACb,OAAO,CAAC;oBACN,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE,sBAAsB;iBAChC,CAAC,CAAA;SACH;QACD,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,mBAAK,eAAe,EAAE,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,eAAgC;QACjD,OAAO,0BAA0B,EAAE,OAAO,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,0BAA0B,EAAE,OAAO,CAAC;IAC7C,CAAC;CACF,CAAA;AAjCY,WAAW;IADvB,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCACE,oBAAU;GAJ1B,WAAW,CAiCvB;AAjCY,kCAAW"} -------------------------------------------------------------------------------- /dist/src/app.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.AppService = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | let AppService = class AppService { 12 | getHello() { 13 | return 'Hello World!'; 14 | } 15 | }; 16 | AppService = __decorate([ 17 | (0, common_1.Injectable)() 18 | ], AppService); 19 | exports.AppService = AppService; 20 | //# sourceMappingURL=app.service.js.map -------------------------------------------------------------------------------- /src/user/user.entity.ts: -------------------------------------------------------------------------------- 1 | import { ObjectType, Field } from '@nestjs/graphql'; 2 | import { Poll } from 'src/poll/entities/poll.entity'; 3 | import {Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; 4 | 5 | 6 | @ObjectType() 7 | @Entity() 8 | export class MainUser { 9 | @PrimaryGeneratedColumn('uuid') 10 | @Field(() => String) 11 | id: string; 12 | 13 | @Field(() => String, { description: 'UserName' }) 14 | @Column() 15 | userName: string; 16 | 17 | @Field(() => String, { description: 'Email' }) 18 | @Column() 19 | email: string; 20 | 21 | @Field(() => String, { description: 'password' }) 22 | @Column() 23 | password: string; 24 | 25 | @Field(() => Boolean, { description: 'active' }) 26 | @Column({ default: false }) 27 | isActive: boolean; 28 | 29 | 30 | @Field(() => [Poll]) 31 | @OneToMany(() => Poll, poll => poll.user) 32 | pollOptions: Promise; 33 | 34 | // public async comparePassword(password: string): Promise { 35 | // return await bcrypt.compare(password, this.password, 12); 36 | // } 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /dist/app.module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6CAAgD;AAGhD,+BAA4B;AAC5B,qDAAiD;AACjD,+CAA2C;AAC3C,0DAA0E;AAC1E,oDAAgD;AAChD,oDAAgD;AAChD,oDAAgD;AAgChD,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IA9BrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,uBAAa,CAAC,OAAO,CAAC,iCAAiB,CAAC;YACxC,uBAAa,CAAC,OAAO,CAAC;gBACpB,cAAc,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;gBACrD,UAAU,EAAE,IAAI;gBAEhB,UAAU,EAAE,IAAI;gBAChB,WAAW,EAAE,CAAC,KAAmB,EAAE,EAAE;;oBACnC,MAAM,qBAAqB,GAAG;wBAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,KAAI,MAAA,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,SAAS,0CAAE,QAAQ,0CAAE,OAAO,CAAA;wBACxE,IAAI,EAAE,CAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,IAAI,KAAI,cAAc;wBAC9C,IAAI,EAAE,CAAA,MAAA,MAAA,KAAK,CAAC,UAAU,0CAAE,SAAS,0CAAE,IAAI,KAAI,KAAK,CAAC,IAAI;qBACtD,CAAC;oBAMF,OAAO,qBAAqB,CAAC;gBAC/B,CAAC;gBAED,OAAO,EAAE,CAAC,EAAC,GAAG,EAAE,GAAG,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,EAAE,GAAG,EAAC,CAAC;aACtC,CAAC;YACF,wBAAU;YACV,wBAAU;SACX;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,EAAE,sBAAS,CAAC;KACnC,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"} -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | const core_1 = require("@nestjs/core"); 4 | const app_module_1 = require("./app.module"); 5 | const Store = require("connect-redis"); 6 | const session = require("express-session"); 7 | const cookieParser = require("cookie-parser"); 8 | const dotenv = require("dotenv"); 9 | const redis_1 = require("./utils/redis"); 10 | dotenv.config(); 11 | async function bootstrap() { 12 | const RedisStore = Store(session); 13 | const app = await core_1.NestFactory.create(app_module_1.AppModule); 14 | app.use(cookieParser()); 15 | app.use(session({ 16 | store: new RedisStore({ client: redis_1.redis }), 17 | name: 'votingapp', 18 | secret: '994ikk34k3k42kkk3kk3k3k', 19 | resave: false, 20 | saveUninitialized: false, 21 | cookie: { 22 | httpOnly: true, 23 | secure: process.env.NODE_ENV === 'production', 24 | maxAge: 1000 * 60 * 60 * 24 25 | } 26 | })); 27 | await app.listen(process.env.PORT || 3000); 28 | } 29 | bootstrap(); 30 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /dist/user/user.subscriber.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.PostSubscriber = void 0; 10 | const typeorm_1 = require("typeorm"); 11 | const user_entity_1 = require("./user.entity"); 12 | const bcrypt = require("bcryptjs"); 13 | let PostSubscriber = class PostSubscriber { 14 | listenTo() { 15 | return user_entity_1.MainUser; 16 | } 17 | async beforeInsert(event) { 18 | event.entity.password = await bcrypt.hash(event.entity.password, 12); 19 | } 20 | }; 21 | PostSubscriber = __decorate([ 22 | (0, typeorm_1.EventSubscriber)() 23 | ], PostSubscriber); 24 | exports.PostSubscriber = PostSubscriber; 25 | //# sourceMappingURL=user.subscriber.js.map -------------------------------------------------------------------------------- /dist/shared/auth.guard.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.AuthGuard = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const graphql_1 = require("@nestjs/graphql"); 12 | let AuthGuard = class AuthGuard { 13 | canActivate(context) { 14 | const ctx = graphql_1.GqlExecutionContext.create(context); 15 | const req = ctx.getContext().req; 16 | if (req.session && req.session['userId']) { 17 | console.log('User Id: ' + req.session['userId']); 18 | return true; 19 | } 20 | return false; 21 | } 22 | }; 23 | AuthGuard = __decorate([ 24 | (0, common_1.Injectable)() 25 | ], AuthGuard); 26 | exports.AuthGuard = AuthGuard; 27 | //# sourceMappingURL=auth.guard.js.map -------------------------------------------------------------------------------- /dist/src/user/user.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.UserModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const user_service_1 = require("./user.service"); 12 | const user_resolver_1 = require("./user.resolver"); 13 | const user_entity_1 = require("./user.entity"); 14 | const typeorm_1 = require("@nestjs/typeorm"); 15 | let UserModule = class UserModule { 16 | }; 17 | UserModule = __decorate([ 18 | (0, common_1.Module)({ 19 | imports: [ 20 | typeorm_1.TypeOrmModule.forFeature([user_entity_1.User]) 21 | ], 22 | exports: [typeorm_1.TypeOrmModule], 23 | providers: [user_resolver_1.UserResolver, user_service_1.UserService] 24 | }) 25 | ], UserModule); 26 | exports.UserModule = UserModule; 27 | //# sourceMappingURL=user.module.js.map -------------------------------------------------------------------------------- /dist/src/user/user.resolver.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.resolver.js","sourceRoot":"","sources":["../../../src/user/user.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAuE;AACvE,iDAA6C;AAC7C,+CAAqC;AACrC,+DAA0D;AAC1D,+DAA0D;AAI1D,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAIzD,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAGD,OAAO,CAAkC,EAAU;QACjD,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAID,UAAU,CAAqB,UAA2B;QACxD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAGD,UAAU,CAAqB,eAAgC;QAC7D,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IAGD,UAAU,CAAkC,EAAU;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAxBC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,kBAAI,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;;;2CAGtC;AAGD;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,CAAC,CAAA;;;;2CAEvC;AAID;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,YAAY,CAAC,CAAA;;qCAAa,mCAAe;;8CAEzD;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,YAAY,CAAC,CAAA;;qCAAkB,mCAAe;;8CAE9D;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,CAAC,CAAA;;;;8CAE1C;AA5BU,YAAY;IADxB,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;qCAEuB,0BAAW;GAD1C,YAAY,CA6BxB;AA7BY,oCAAY"} -------------------------------------------------------------------------------- /dist/poll/dto/update-poll.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.UpdatePollInput = void 0; 13 | const create_poll_input_1 = require("./create-poll.input"); 14 | const graphql_1 = require("@nestjs/graphql"); 15 | let UpdatePollInput = class UpdatePollInput extends (0, graphql_1.PartialType)(create_poll_input_1.CreatePollInput) { 16 | }; 17 | __decorate([ 18 | (0, graphql_1.Field)(() => graphql_1.Int), 19 | __metadata("design:type", Number) 20 | ], UpdatePollInput.prototype, "id", void 0); 21 | UpdatePollInput = __decorate([ 22 | (0, graphql_1.InputType)() 23 | ], UpdatePollInput); 24 | exports.UpdatePollInput = UpdatePollInput; 25 | //# sourceMappingURL=update-poll.input.js.map -------------------------------------------------------------------------------- /dist/poll/poll.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"poll.service.js","sourceRoot":"","sources":["../../src/poll/poll.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAGrC,sEAA2D;AAC3D,wDAA8C;AAG9C,IAAa,WAAW,GAAxB,MAAa,WAAW;IAGtB,YAA4C,cAAgC,EACtC,oBAA4C;QADtC,mBAAc,GAAd,cAAc,CAAkB;QACtC,yBAAoB,GAApB,oBAAoB,CAAwB;IAAE,CAAC;IAErF,KAAK,CAAC,MAAM,CAAC,eAAgC,EAAE,MAAc;QAC3D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAC;QAElF,eAAe,CAAC,OAAO,CAAC,GAAG,CAAE,KAAK,EAAC,IAAI,EAAC,EAAE;YACxC,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;gBACnC,IAAI;gBACJ,IAAI,EAAE,CAAC;gBACP,MAAM,EAAE,IAAI,CAAC,EAAE;aAChB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAC,EAAE,SAAS,EAAE,CAAC,aAAa,CAAC,EAAC,CAAC,CAAC;IAC/F,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc;QAC1B,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,SAAS,EAAE,CAAC,aAAa,CAAC,EAAC,CAAC,CAAC;IAClG,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,MAAM;QAC9B,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAC,EAAE,SAAS,EAAE,CAAC,aAAa,CAAC,EAAC,CAAC,CAAC;IAC1G,CAAC;IAED,MAAM,CAAC,EAAU,EAAE,eAAgC;QACjD,OAAO,0BAA0B,EAAE,OAAO,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,0BAA0B,EAAE,OAAO,CAAC;IAC7C,CAAC;CACF,CAAA;AAnCY,WAAW;IADvB,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IAClC,WAAA,IAAA,0BAAgB,EAAC,+BAAU,CAAC,CAAA;qCAD+B,oBAAU;QACV,oBAAU;GAJ3D,WAAW,CAmCvB;AAnCY,kCAAW"} -------------------------------------------------------------------------------- /dist/poll/dto/create-poll.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.CreatePollInput = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let CreatePollInput = class CreatePollInput { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String), 18 | __metadata("design:type", String) 19 | ], CreatePollInput.prototype, "name", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => [String]), 22 | __metadata("design:type", Array) 23 | ], CreatePollInput.prototype, "options", void 0); 24 | CreatePollInput = __decorate([ 25 | (0, graphql_1.InputType)() 26 | ], CreatePollInput); 27 | exports.CreatePollInput = CreatePollInput; 28 | //# sourceMappingURL=create-poll.input.js.map -------------------------------------------------------------------------------- /dist/shared/error-response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ErrorResponse = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let ErrorResponse = class ErrorResponse { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String, { nullable: true }), 18 | __metadata("design:type", String) 19 | ], ErrorResponse.prototype, "path", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => String, { nullable: true }), 22 | __metadata("design:type", String) 23 | ], ErrorResponse.prototype, "message", void 0); 24 | ErrorResponse = __decorate([ 25 | (0, graphql_1.ObjectType)() 26 | ], ErrorResponse); 27 | exports.ErrorResponse = ErrorResponse; 28 | //# sourceMappingURL=error-response.js.map -------------------------------------------------------------------------------- /dist/user/user.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.UserModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const user_service_1 = require("./user.service"); 12 | const user_resolver_1 = require("./user.resolver"); 13 | const user_entity_1 = require("./user.entity"); 14 | const typeorm_1 = require("@nestjs/typeorm"); 15 | const user_controller_1 = require("./user.controller"); 16 | let UserModule = class UserModule { 17 | }; 18 | UserModule = __decorate([ 19 | (0, common_1.Module)({ 20 | imports: [ 21 | typeorm_1.TypeOrmModule.forFeature([user_entity_1.MainUser]) 22 | ], 23 | exports: [typeorm_1.TypeOrmModule], 24 | providers: [user_resolver_1.UserResolver, user_service_1.UserService], 25 | controllers: [user_controller_1.UserController] 26 | }) 27 | ], UserModule); 28 | exports.UserModule = UserModule; 29 | //# sourceMappingURL=user.module.js.map -------------------------------------------------------------------------------- /dist/poll/poll.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.PollModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const poll_service_1 = require("./poll.service"); 12 | const poll_resolver_1 = require("./poll.resolver"); 13 | const poll_entity_1 = require("./entities/poll.entity"); 14 | const poll_option_entity_1 = require("./entities/poll-option.entity"); 15 | const typeorm_1 = require("@nestjs/typeorm"); 16 | let PollModule = class PollModule { 17 | }; 18 | PollModule = __decorate([ 19 | (0, common_1.Module)({ 20 | imports: [ 21 | typeorm_1.TypeOrmModule.forFeature([poll_entity_1.Poll, poll_option_entity_1.PollOption]) 22 | ], 23 | exports: [ 24 | typeorm_1.TypeOrmModule 25 | ], 26 | providers: [poll_resolver_1.PollResolver, poll_service_1.PollService] 27 | }) 28 | ], PollModule); 29 | exports.PollModule = PollModule; 30 | //# sourceMappingURL=poll.module.js.map -------------------------------------------------------------------------------- /dist/user/dto/login-user.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.LoginUserInput = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let LoginUserInput = class LoginUserInput { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String, { description: 'email' }), 18 | __metadata("design:type", String) 19 | ], LoginUserInput.prototype, "email", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => String, { description: 'password' }), 22 | __metadata("design:type", String) 23 | ], LoginUserInput.prototype, "password", void 0); 24 | LoginUserInput = __decorate([ 25 | (0, graphql_1.InputType)({ description: "Login Input" }) 26 | ], LoginUserInput); 27 | exports.LoginUserInput = LoginUserInput; 28 | //# sourceMappingURL=login-user.input.js.map -------------------------------------------------------------------------------- /src/poll/poll.resolver.ts: -------------------------------------------------------------------------------- 1 | import { Resolver, Query, Mutation, Args, Int } from '@nestjs/graphql'; 2 | import { PollService } from './poll.service'; 3 | import { Poll } from './entities/poll.entity'; 4 | import { CreatePollInput } from './dto/create-poll.input'; 5 | import { UpdatePollInput } from './dto/update-poll.input'; 6 | import { UseGuards } from '@nestjs/common'; 7 | import { AuthGuard } from 'src/shared/auth.guard'; 8 | import { GetUserId } from 'src/shared/getuserid.decorator'; 9 | 10 | @Resolver(() => Poll) 11 | export class PollResolver { 12 | constructor(private readonly pollService: PollService) {} 13 | 14 | @Mutation(() => Poll, {nullable: true}) 15 | @UseGuards(AuthGuard) 16 | createPoll(@Args('createPollInput') createPollInput: CreatePollInput, @GetUserId() userId: string): Promise { 17 | return this.pollService.create(createPollInput, userId); 18 | } 19 | 20 | @Query(() => [Poll], { name: 'poll' }) 21 | findAll( @GetUserId() userId: string) { 22 | return this.pollService.findAll(userId); 23 | } 24 | 25 | @Query(() => Poll, { name: 'poll' }) 26 | @UseGuards(AuthGuard) 27 | findOne(@Args('id', { type: () => String }) id: string, @GetUserId() userId: string) { 28 | return this.pollService.findOne(id, userId); 29 | } 30 | 31 | @Mutation(() => Poll) 32 | updatePoll(@Args('updatePollInput') updatePollInput: UpdatePollInput) { 33 | return this.pollService.update(updatePollInput.id, updatePollInput); 34 | } 35 | 36 | @Mutation(() => Poll) 37 | removePoll(@Args('id', { type: () => Int }) id: number) { 38 | return this.pollService.remove(id); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /dist/user/entities/user.entity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.User = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let User = class User { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 18 | __metadata("design:type", String) 19 | ], User.prototype, "name", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 22 | __metadata("design:type", String) 23 | ], User.prototype, "department", void 0); 24 | __decorate([ 25 | (0, graphql_1.Field)(() => String, { description: 'description' }), 26 | __metadata("design:type", String) 27 | ], User.prototype, "description", void 0); 28 | User = __decorate([ 29 | (0, graphql_1.ObjectType)() 30 | ], User); 31 | exports.User = User; 32 | //# sourceMappingURL=user.entity.js.map -------------------------------------------------------------------------------- /dist/shared/response-object.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.ResponseObject = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let ResponseObject = class ResponseObject { 15 | constructor(data, error) { 16 | this.data = data; 17 | this.error = error; 18 | } 19 | }; 20 | __decorate([ 21 | (0, graphql_1.Field)({ nullable: true }), 22 | __metadata("design:type", Array) 23 | ], ResponseObject.prototype, "data", void 0); 24 | __decorate([ 25 | (0, graphql_1.Field)({ nullable: true }), 26 | __metadata("design:type", Array) 27 | ], ResponseObject.prototype, "error", void 0); 28 | ResponseObject = __decorate([ 29 | (0, graphql_1.ObjectType)(), 30 | __metadata("design:paramtypes", [Array, Array]) 31 | ], ResponseObject); 32 | exports.ResponseObject = ResponseObject; 33 | //# sourceMappingURL=response-object.js.map -------------------------------------------------------------------------------- /src/poll/poll.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Repository } from 'typeorm'; 4 | import { CreatePollInput } from './dto/create-poll.input'; 5 | import { UpdatePollInput } from './dto/update-poll.input'; 6 | import { PollOption } from './entities/poll-option.entity'; 7 | import { Poll } from './entities/poll.entity'; 8 | 9 | @Injectable() 10 | export class PollService { 11 | 12 | 13 | constructor(@InjectRepository(Poll) private pollRepository: Repository, 14 | @InjectRepository(PollOption) private pollOptionRepository: Repository){} 15 | 16 | async create(createPollInput: CreatePollInput, userId: string): Promise { 17 | const poll = await this.pollRepository.save({name: createPollInput.name, userId}); 18 | 19 | createPollInput.options.map( async text => { 20 | await this.pollOptionRepository.save({ 21 | text, 22 | vote: 0, 23 | pollId: poll.id 24 | }); 25 | }); 26 | 27 | return await this.pollRepository.findOne({where: {id: poll.id}, relations: ['pollOptions']}); 28 | } 29 | 30 | async findAll(userId: string) { 31 | return await this.pollRepository.findOne({where: {userId: userId}, relations: ['pollOptions']}); 32 | } 33 | 34 | async findOne(id: string, userId) { 35 | return await this.pollRepository.findOne({where: {id: id, userId: userId}, relations: ['pollOptions']}); 36 | } 37 | 38 | update(id: number, updatePollInput: UpdatePollInput) { 39 | return `This action updates a #${id} poll`; 40 | } 41 | 42 | remove(id: number) { 43 | return `This action removes a #${id} poll`; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /dist/app.controller.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.AppController = void 0; 13 | const common_1 = require("@nestjs/common"); 14 | const app_service_1 = require("./app.service"); 15 | let AppController = class AppController { 16 | constructor(appService) { 17 | this.appService = appService; 18 | } 19 | getHello() { 20 | return this.appService.getHello(); 21 | } 22 | }; 23 | __decorate([ 24 | (0, common_1.Get)(), 25 | __metadata("design:type", Function), 26 | __metadata("design:paramtypes", []), 27 | __metadata("design:returntype", String) 28 | ], AppController.prototype, "getHello", null); 29 | AppController = __decorate([ 30 | (0, common_1.Controller)(), 31 | __metadata("design:paramtypes", [app_service_1.AppService]) 32 | ], AppController); 33 | exports.AppController = AppController; 34 | //# sourceMappingURL=app.controller.js.map -------------------------------------------------------------------------------- /dist/src/app.controller.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.AppController = void 0; 13 | const common_1 = require("@nestjs/common"); 14 | const app_service_1 = require("./app.service"); 15 | let AppController = class AppController { 16 | constructor(appService) { 17 | this.appService = appService; 18 | } 19 | getHello() { 20 | return this.appService.getHello(); 21 | } 22 | }; 23 | __decorate([ 24 | (0, common_1.Get)(), 25 | __metadata("design:type", Function), 26 | __metadata("design:paramtypes", []), 27 | __metadata("design:returntype", String) 28 | ], AppController.prototype, "getHello", null); 29 | AppController = __decorate([ 30 | (0, common_1.Controller)(), 31 | __metadata("design:paramtypes", [app_service_1.AppService]) 32 | ], AppController); 33 | exports.AppController = AppController; 34 | //# sourceMappingURL=app.controller.js.map -------------------------------------------------------------------------------- /src/utils/sendEmail.ts: -------------------------------------------------------------------------------- 1 | import * as nodemailer from 'nodemailer'; 2 | 3 | 4 | // async..await is not allowed in global scope, must use a wrapper 5 | export const sendEmail = async (userEmail:string, link: string) => { 6 | // Generate test SMTP service account from ethereal.email 7 | // Only needed if you don't have a real mail account for testing 8 | // let testAccount = await nodemailer.createTestAccount(); 9 | 10 | // create reusable transporter object using the default SMTP transport 11 | let transporter = nodemailer.createTransport({ 12 | host: "smtp-relay.sendinblue.com", 13 | port: 587, 14 | secure: false, // true for 465, false for other ports 15 | auth: { 16 | user: 'hsn121121@gmail.com', // generated ethereal user 17 | pass: "xsmtpsib-88cf2bace767261f7d762d28551dce0762ce4bf4dc2cd56230d2e90632ce4e77-nAZTQUtRVMI5s3XO" || process.env.SENDINBLUE_TOKEN, // generated ethereal password 18 | }, 19 | }); 20 | 21 | // send mail with defined transport object 22 | let info = await transporter.sendMail({ 23 | from: '"Fred Foo 👻" ', // sender address 24 | to: userEmail, // list of receivers 25 | subject: "Hello ✔", // Subject line 26 | text: "Hello world?", // plain text body 27 | html: `Hello world? Confirm Email`, // html body 28 | }); 29 | 30 | console.log("Message sent: %s", info.messageId); 31 | // Message sent: 32 | 33 | // Preview only available when sending through an Ethereal account 34 | // console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info)); 35 | // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou... 36 | } 37 | 38 | // main().catch(console.error); 39 | -------------------------------------------------------------------------------- /dist/poll/poll.resolver.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"poll.resolver.js","sourceRoot":"","sources":["../../src/poll/poll.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAuE;AACvE,iDAA6C;AAC7C,wDAA8C;AAC9C,+DAA0D;AAC1D,+DAA0D;AAC1D,2CAA2C;AAC3C,qDAAkD;AAClD,uEAA2D;AAG3D,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAIzD,UAAU,CAA0B,eAAgC,EAAe,MAAc;QAC/F,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAGD,OAAO,CAAe,MAAc;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAID,OAAO,CAAqC,EAAU,EAAe,MAAc;QACjF,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAGD,UAAU,CAA0B,eAAgC;QAClE,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IAGD,UAAU,CAAkC,EAAU;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAxBC;IAFC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;IACtC,IAAA,kBAAS,EAAC,sBAAS,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,iBAAiB,CAAC,CAAA;IAAoC,WAAA,IAAA,+BAAS,GAAE,CAAA;;qCAA7B,mCAAe;;8CAEnE;AAGD;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,kBAAI,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC5B,WAAA,IAAA,+BAAS,GAAE,CAAA;;;;2CAEpB;AAID;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACnC,IAAA,kBAAS,EAAC,sBAAS,CAAC;IACZ,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;IAAc,WAAA,IAAA,+BAAS,GAAE,CAAA;;;;2CAEnE;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,iBAAiB,CAAC,CAAA;;qCAAkB,mCAAe;;8CAEnE;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;IACT,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,CAAC,CAAA;;;;8CAE1C;AA5BU,YAAY;IADxB,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,kBAAI,CAAC;qCAEuB,0BAAW;GAD1C,YAAY,CA6BxB;AA7BY,oCAAY"} -------------------------------------------------------------------------------- /dist/user/dto/create-user.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.CreateUserInput = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let CreateUserInput = class CreateUserInput { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 18 | __metadata("design:type", String) 19 | ], CreateUserInput.prototype, "userName", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 22 | __metadata("design:type", String) 23 | ], CreateUserInput.prototype, "email", void 0); 24 | __decorate([ 25 | (0, graphql_1.Field)(() => String, { description: 'password' }), 26 | __metadata("design:type", String) 27 | ], CreateUserInput.prototype, "password", void 0); 28 | CreateUserInput = __decorate([ 29 | (0, graphql_1.InputType)() 30 | ], CreateUserInput); 31 | exports.CreateUserInput = CreateUserInput; 32 | //# sourceMappingURL=create-user.input.js.map -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GraphQLModule } from '@nestjs/graphql'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | // import { ApolloServerPluginLandingPageLocalDefault } from 'apollo-server-core'; 5 | import { GraphQLError } from 'graphql'; 6 | import { join } from 'path'; 7 | import { AppController } from './app.controller'; 8 | import { AppService } from './app.service'; 9 | import { typeOrmConfig, typeOrmProdConfig } from './config/typeOrmConfig'; 10 | import { AuthGuard } from './shared/auth.guard'; 11 | import { UserModule } from './user/user.module'; 12 | import { PollModule } from './poll/poll.module'; 13 | 14 | @Module({ 15 | imports: [ 16 | TypeOrmModule.forRoot(typeOrmProdConfig), 17 | GraphQLModule.forRoot({ 18 | autoSchemaFile: join(process.cwd(), 'src/schema.gql'), 19 | playground: true, 20 | // plugins: [ApolloServerPluginLandingPageLocalDefault()], 21 | sortSchema: true, 22 | formatError: (error: GraphQLError) => { 23 | const graphQLFormattedError = { 24 | message: error.message || error.extensions?.exception?.response?.message, 25 | code: error.extensions?.code || "SERVER_ERROR", 26 | name: error.extensions?.exception?.name || error.name, 27 | }; 28 | // const graphQLFormattedError: GraphQLFormattedError = { 29 | // // code: error.extensions.code, 30 | // // extensions 31 | // message: error.message, 32 | // }; 33 | return graphQLFormattedError; 34 | }, 35 | 36 | context: ({req, res}) => ({req, res}) 37 | }), 38 | UserModule, 39 | PollModule, 40 | ], 41 | controllers: [AppController], 42 | providers: [AppService, AuthGuard], 43 | }) 44 | export class AppModule {} 45 | -------------------------------------------------------------------------------- /src/user/user.resolver.ts: -------------------------------------------------------------------------------- 1 | import { Resolver, Query, Mutation, Args, Int, Context } from '@nestjs/graphql'; 2 | import { UserService } from './user.service'; 3 | import { MainUser } from './user.entity'; 4 | import { CreateUserInput } from './dto/create-user.input'; 5 | import { UpdateUserInput } from './dto/update-user.input'; 6 | import { LoginUserInput } from './dto/login-user.input'; 7 | import { MyContext } from 'src/types/my-context'; 8 | import { UseGuards } from '@nestjs/common'; 9 | import { AuthGuard } from 'src/shared/auth.guard'; 10 | 11 | 12 | @Resolver(() => MainUser) 13 | export class UserResolver { 14 | constructor(private readonly userService: UserService) {} 15 | 16 | 17 | @Query(() => [MainUser], { name: 'users' }) 18 | @UseGuards(AuthGuard) 19 | findAll() { 20 | return this.userService.findAll(); 21 | } 22 | 23 | @Query(() => MainUser, { name: 'user' }) 24 | findOne(@Args('id', { type: () => String }) id: string) { 25 | return this.userService.findOne(id); 26 | } 27 | 28 | 29 | @Mutation(() => MainUser, { nullable: true}) 30 | createUser(@Args('createUser') createUser: CreateUserInput): Promise { 31 | return this.userService.create(createUser); 32 | } 33 | 34 | @Mutation(() => MainUser, { nullable: true}) 35 | updateUser(@Args('updateUser') updateUserInput: UpdateUserInput) { 36 | return this.userService.update(updateUserInput.id, updateUserInput); 37 | } 38 | 39 | @Mutation(() => MainUser) 40 | removeUser(@Args('id', { type: () => Int }) id: number) { 41 | return this.userService.remove(id); 42 | } 43 | 44 | @Mutation(() => String, { nullable: true}) 45 | loginUser(@Args('loginInput') loginInput: LoginUserInput, @Context() ctx: MyContext) { 46 | return this.userService.login(loginInput, ctx); 47 | } 48 | 49 | @Mutation(() => String, { nullable: true}) 50 | logout(@Context() ctx: MyContext) { 51 | return this.userService.logout(ctx); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /dist/src/user/dto/create-user.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.CreateUserInput = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | let CreateUserInput = class CreateUserInput { 15 | }; 16 | __decorate([ 17 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 18 | __metadata("design:type", String) 19 | ], CreateUserInput.prototype, "userName", void 0); 20 | __decorate([ 21 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 22 | __metadata("design:type", String) 23 | ], CreateUserInput.prototype, "email", void 0); 24 | __decorate([ 25 | (0, graphql_1.Field)(() => String, { description: 'password' }), 26 | __metadata("design:type", String) 27 | ], CreateUserInput.prototype, "password", void 0); 28 | __decorate([ 29 | (0, graphql_1.Field)(() => Boolean, { description: 'active' }), 30 | __metadata("design:type", Boolean) 31 | ], CreateUserInput.prototype, "isActive", void 0); 32 | CreateUserInput = __decorate([ 33 | (0, graphql_1.InputType)() 34 | ], CreateUserInput); 35 | exports.CreateUserInput = CreateUserInput; 36 | //# sourceMappingURL=create-user.input.js.map -------------------------------------------------------------------------------- /dist/user/user.controller.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.UserController = void 0; 16 | const common_1 = require("@nestjs/common"); 17 | const user_service_1 = require("./user.service"); 18 | let UserController = class UserController { 19 | constructor(userService) { 20 | this.userService = userService; 21 | } 22 | confirmEmail(id) { 23 | return this.userService.confirmEmail(id); 24 | } 25 | }; 26 | __decorate([ 27 | (0, common_1.Get)('/confirm/:id'), 28 | __param(0, (0, common_1.Param)('id')), 29 | __metadata("design:type", Function), 30 | __metadata("design:paramtypes", [String]), 31 | __metadata("design:returntype", void 0) 32 | ], UserController.prototype, "confirmEmail", null); 33 | UserController = __decorate([ 34 | (0, common_1.Controller)('user'), 35 | __metadata("design:paramtypes", [user_service_1.UserService]) 36 | ], UserController); 37 | exports.UserController = UserController; 38 | //# sourceMappingURL=user.controller.js.map -------------------------------------------------------------------------------- /src/schema.gql: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ 2 | # THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) 3 | # ------------------------------------------------------ 4 | 5 | input CreatePollInput { 6 | name: String! 7 | options: [String!]! 8 | } 9 | 10 | input CreateUserInput { 11 | """Department""" 12 | email: String! 13 | 14 | """password""" 15 | password: String! 16 | 17 | """Name""" 18 | userName: String! 19 | } 20 | 21 | """Login Input""" 22 | input LoginUserInput { 23 | """email""" 24 | email: String! 25 | 26 | """password""" 27 | password: String! 28 | } 29 | 30 | type Mutation { 31 | createPoll(createPollInput: CreatePollInput!): Poll 32 | createUser(createUser: CreateUserInput!): User 33 | loginUser(loginInput: LoginUserInput!): String 34 | logout: String 35 | removePoll(id: Int!): Poll! 36 | removeUser(id: Int!): User! 37 | updatePoll(updatePollInput: UpdatePollInput!): Poll! 38 | updateUser(updateUser: UpdateUserInput!): User 39 | } 40 | 41 | type Poll { 42 | id: String! 43 | name: String! 44 | pollOptions: [PollOption!]! 45 | userId: String! 46 | } 47 | 48 | type PollOption { 49 | id: String! 50 | poll: Poll! 51 | pollId: String! 52 | text: String! 53 | vote: Int! 54 | } 55 | 56 | type Query { 57 | poll(id: String!): Poll! 58 | user(id: String!): User! 59 | users: [User!]! 60 | } 61 | 62 | input UpdatePollInput { 63 | id: Int! 64 | name: String 65 | options: [String!] 66 | } 67 | 68 | input UpdateUserInput { 69 | """Department""" 70 | email: String! 71 | 72 | """Name""" 73 | id: String! 74 | 75 | """active""" 76 | isActive: Boolean! 77 | 78 | """password""" 79 | password: String 80 | 81 | """Name""" 82 | userName: String! 83 | } 84 | 85 | type User { 86 | """Email""" 87 | email: String! 88 | id: String! 89 | 90 | """active""" 91 | isActive: Boolean! 92 | 93 | """password""" 94 | password: String! 95 | 96 | """UserName""" 97 | userName: String! 98 | } 99 | -------------------------------------------------------------------------------- /dist/src/app.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.AppModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const graphql_1 = require("@nestjs/graphql"); 12 | const typeorm_1 = require("@nestjs/typeorm"); 13 | const apollo_server_core_1 = require("apollo-server-core"); 14 | const path_1 = require("path"); 15 | const app_controller_1 = require("./app.controller"); 16 | const app_service_1 = require("./app.service"); 17 | const typeOrmConfig_1 = require("./config/typeOrmConfig"); 18 | const user_module_1 = require("./user/user.module"); 19 | let AppModule = class AppModule { 20 | }; 21 | AppModule = __decorate([ 22 | (0, common_1.Module)({ 23 | imports: [ 24 | typeorm_1.TypeOrmModule.forRoot(typeOrmConfig_1.typeOrmConfig), 25 | graphql_1.GraphQLModule.forRoot({ 26 | autoSchemaFile: (0, path_1.join)(process.cwd(), 'src/schema.gql'), 27 | playground: false, 28 | plugins: [(0, apollo_server_core_1.ApolloServerPluginLandingPageLocalDefault)()], 29 | sortSchema: true, 30 | }), 31 | user_module_1.UserModule, 32 | ], 33 | controllers: [app_controller_1.AppController], 34 | providers: [app_service_1.AppService], 35 | }) 36 | ], AppModule); 37 | exports.AppModule = AppModule; 38 | //# sourceMappingURL=app.module.js.map -------------------------------------------------------------------------------- /dist/user/dto/update-user.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.UpdateUserInput = void 0; 13 | const create_user_input_1 = require("./create-user.input"); 14 | const graphql_1 = require("@nestjs/graphql"); 15 | let UpdateUserInput = class UpdateUserInput extends (0, graphql_1.PartialType)(create_user_input_1.CreateUserInput) { 16 | }; 17 | __decorate([ 18 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 19 | __metadata("design:type", String) 20 | ], UpdateUserInput.prototype, "id", void 0); 21 | __decorate([ 22 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 23 | __metadata("design:type", String) 24 | ], UpdateUserInput.prototype, "userName", void 0); 25 | __decorate([ 26 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 27 | __metadata("design:type", String) 28 | ], UpdateUserInput.prototype, "email", void 0); 29 | __decorate([ 30 | (0, graphql_1.Field)(() => Boolean, { description: 'active' }), 31 | __metadata("design:type", Boolean) 32 | ], UpdateUserInput.prototype, "isActive", void 0); 33 | UpdateUserInput = __decorate([ 34 | (0, graphql_1.InputType)() 35 | ], UpdateUserInput); 36 | exports.UpdateUserInput = UpdateUserInput; 37 | //# sourceMappingURL=update-user.input.js.map -------------------------------------------------------------------------------- /dist/user/user.resolver.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.resolver.js","sourceRoot":"","sources":["../../src/user/user.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAgF;AAChF,iDAA6C;AAC7C,+CAAyC;AACzC,+DAA0D;AAC1D,+DAA0D;AAC1D,6DAAwD;AACxD,oDAAiD;AACjD,2CAA2C;AAC3C,qDAAkD;AAIlD,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAKzD,OAAO;QACL,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAGD,OAAO,CAAqC,EAAU;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAID,UAAU,CAAqB,UAA2B;QACxD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAGD,UAAU,CAAqB,eAAgC;QAC7D,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IAGD,UAAU,CAAkC,EAAU;QACpD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;IAGD,SAAS,CAAqB,UAA0B,EAAa,GAAc;QACjF,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAGD,MAAM,CAAY,GAAc;QAC9B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AAlCC;IAFC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,sBAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IAC1C,IAAA,kBAAS,EAAC,sBAAS,CAAC;;;;2CAGpB;AAGD;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,sBAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC/B,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;;;;2CAE1C;AAID;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;IAChC,WAAA,IAAA,cAAI,EAAC,YAAY,CAAC,CAAA;;qCAAa,mCAAe;;8CAEzD;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;IAChC,WAAA,IAAA,cAAI,EAAC,YAAY,CAAC,CAAA;;qCAAkB,mCAAe;;8CAE9D;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAQ,CAAC;IACb,WAAA,IAAA,cAAI,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,aAAG,EAAE,CAAC,CAAA;;;;8CAE1C;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;IAC/B,WAAA,IAAA,cAAI,EAAC,YAAY,CAAC,CAAA;IAA8B,WAAA,IAAA,iBAAO,GAAE,CAAA;;qCAA1B,iCAAc;;6CAEvD;AAGD;IADC,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;IAClC,WAAA,IAAA,iBAAO,GAAE,CAAA;;;;0CAEhB;AAvCU,YAAY;IADxB,IAAA,kBAAQ,EAAC,GAAG,EAAE,CAAC,sBAAQ,CAAC;qCAEmB,0BAAW;GAD1C,YAAY,CAwCxB;AAxCY,oCAAY"} -------------------------------------------------------------------------------- /dist/src/user/user.entity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.User = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | const typeorm_1 = require("typeorm"); 15 | let User = class User { 16 | }; 17 | __decorate([ 18 | (0, typeorm_1.PrimaryGeneratedColumn)(), 19 | (0, graphql_1.Field)(() => Number, { description: 'Name' }), 20 | __metadata("design:type", Number) 21 | ], User.prototype, "id", void 0); 22 | __decorate([ 23 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 24 | (0, typeorm_1.Column)(), 25 | __metadata("design:type", String) 26 | ], User.prototype, "userName", void 0); 27 | __decorate([ 28 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 29 | (0, typeorm_1.Column)(), 30 | __metadata("design:type", String) 31 | ], User.prototype, "email", void 0); 32 | __decorate([ 33 | (0, graphql_1.Field)(() => String, { description: 'password' }), 34 | (0, typeorm_1.Column)(), 35 | __metadata("design:type", String) 36 | ], User.prototype, "password", void 0); 37 | __decorate([ 38 | (0, graphql_1.Field)(() => Boolean, { description: 'active' }), 39 | (0, typeorm_1.Column)({ default: true }), 40 | __metadata("design:type", Boolean) 41 | ], User.prototype, "isActive", void 0); 42 | User = __decorate([ 43 | (0, graphql_1.ObjectType)(), 44 | (0, typeorm_1.Entity)() 45 | ], User); 46 | exports.User = User; 47 | //# sourceMappingURL=user.entity.js.map -------------------------------------------------------------------------------- /dist/src/user/dto/update-user.input.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.UpdateUserInput = void 0; 13 | const create_user_input_1 = require("./create-user.input"); 14 | const graphql_1 = require("@nestjs/graphql"); 15 | let UpdateUserInput = class UpdateUserInput extends (0, graphql_1.PartialType)(create_user_input_1.CreateUserInput) { 16 | }; 17 | __decorate([ 18 | (0, graphql_1.Field)(() => Number, { description: 'Name' }), 19 | __metadata("design:type", Number) 20 | ], UpdateUserInput.prototype, "id", void 0); 21 | __decorate([ 22 | (0, graphql_1.Field)(() => String, { description: 'Name' }), 23 | __metadata("design:type", String) 24 | ], UpdateUserInput.prototype, "userName", void 0); 25 | __decorate([ 26 | (0, graphql_1.Field)(() => String, { description: 'Department' }), 27 | __metadata("design:type", String) 28 | ], UpdateUserInput.prototype, "email", void 0); 29 | __decorate([ 30 | (0, graphql_1.Field)(() => String, { description: 'password' }), 31 | __metadata("design:type", String) 32 | ], UpdateUserInput.prototype, "password", void 0); 33 | __decorate([ 34 | (0, graphql_1.Field)(() => Boolean, { description: 'active' }), 35 | __metadata("design:type", Boolean) 36 | ], UpdateUserInput.prototype, "isActive", void 0); 37 | UpdateUserInput = __decorate([ 38 | (0, graphql_1.InputType)() 39 | ], UpdateUserInput); 40 | exports.UpdateUserInput = UpdateUserInput; 41 | //# sourceMappingURL=update-user.input.js.map -------------------------------------------------------------------------------- /dist/poll/entities/poll-option.entity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.PollOption = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | const typeorm_1 = require("typeorm"); 15 | const poll_entity_1 = require("./poll.entity"); 16 | let PollOption = class PollOption { 17 | }; 18 | __decorate([ 19 | (0, graphql_1.Field)(() => String), 20 | (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), 21 | __metadata("design:type", String) 22 | ], PollOption.prototype, "id", void 0); 23 | __decorate([ 24 | (0, graphql_1.Field)(() => String), 25 | (0, typeorm_1.Column)(), 26 | __metadata("design:type", String) 27 | ], PollOption.prototype, "text", void 0); 28 | __decorate([ 29 | (0, graphql_1.Field)(() => graphql_1.Int), 30 | (0, typeorm_1.Column)(), 31 | __metadata("design:type", Number) 32 | ], PollOption.prototype, "vote", void 0); 33 | __decorate([ 34 | (0, graphql_1.Field)(() => String), 35 | (0, typeorm_1.Column)(), 36 | __metadata("design:type", String) 37 | ], PollOption.prototype, "pollId", void 0); 38 | __decorate([ 39 | (0, graphql_1.Field)(() => poll_entity_1.Poll), 40 | (0, typeorm_1.ManyToOne)(() => poll_entity_1.Poll, poll => poll.pollOptions), 41 | __metadata("design:type", Promise) 42 | ], PollOption.prototype, "poll", void 0); 43 | PollOption = __decorate([ 44 | (0, graphql_1.ObjectType)(), 45 | (0, typeorm_1.Entity)() 46 | ], PollOption); 47 | exports.PollOption = PollOption; 48 | //# sourceMappingURL=poll-option.entity.js.map -------------------------------------------------------------------------------- /dist/poll/entities/poll.entity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.Poll = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | const user_entity_1 = require("../../user/user.entity"); 15 | const typeorm_1 = require("typeorm"); 16 | const poll_option_entity_1 = require("./poll-option.entity"); 17 | let Poll = class Poll { 18 | }; 19 | __decorate([ 20 | (0, graphql_1.Field)(() => String), 21 | (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), 22 | __metadata("design:type", String) 23 | ], Poll.prototype, "id", void 0); 24 | __decorate([ 25 | (0, graphql_1.Field)(() => String), 26 | (0, typeorm_1.Column)(), 27 | __metadata("design:type", String) 28 | ], Poll.prototype, "name", void 0); 29 | __decorate([ 30 | (0, graphql_1.Field)(() => String), 31 | (0, typeorm_1.Column)(), 32 | __metadata("design:type", String) 33 | ], Poll.prototype, "userId", void 0); 34 | __decorate([ 35 | (0, typeorm_1.ManyToOne)(() => user_entity_1.MainUser), 36 | __metadata("design:type", user_entity_1.MainUser) 37 | ], Poll.prototype, "user", void 0); 38 | __decorate([ 39 | (0, graphql_1.Field)(() => [poll_option_entity_1.PollOption]), 40 | (0, typeorm_1.OneToMany)(() => poll_option_entity_1.PollOption, polloption => polloption.poll), 41 | __metadata("design:type", Promise) 42 | ], Poll.prototype, "pollOptions", void 0); 43 | Poll = __decorate([ 44 | (0, graphql_1.ObjectType)(), 45 | (0, typeorm_1.Entity)() 46 | ], Poll); 47 | exports.Poll = Poll; 48 | //# sourceMappingURL=poll.entity.js.map -------------------------------------------------------------------------------- /dist/src/user/user.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.UserService = void 0; 16 | const common_1 = require("@nestjs/common"); 17 | const typeorm_1 = require("@nestjs/typeorm"); 18 | const typeorm_2 = require("typeorm"); 19 | const user_entity_1 = require("./user.entity"); 20 | let UserService = class UserService { 21 | constructor(usersRepository) { 22 | this.usersRepository = usersRepository; 23 | } 24 | async create(createUserInput) { 25 | const userExists = this.usersRepository.findOne({ where: { email: createUserInput.email } }); 26 | if (userExists) { 27 | return [{ 28 | path: "email", 29 | message: "Email already exists" 30 | }]; 31 | } 32 | return this.usersRepository.save(Object.assign({}, createUserInput)); 33 | } 34 | async findAll() { 35 | return await this.usersRepository.find(); 36 | } 37 | async findOne(id) { 38 | return await this.usersRepository.findOne(id); 39 | } 40 | update(id, updateUserInput) { 41 | return `This action updates a #${id} user`; 42 | } 43 | remove(id) { 44 | return `This action removes a #${id} user`; 45 | } 46 | }; 47 | UserService = __decorate([ 48 | (0, common_1.Injectable)(), 49 | __param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)), 50 | __metadata("design:paramtypes", [typeorm_2.Repository]) 51 | ], UserService); 52 | exports.UserService = UserService; 53 | //# sourceMappingURL=user.service.js.map -------------------------------------------------------------------------------- /dist/user/user.entity.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | exports.MainUser = void 0; 13 | const graphql_1 = require("@nestjs/graphql"); 14 | const poll_entity_1 = require("../poll/entities/poll.entity"); 15 | const typeorm_1 = require("typeorm"); 16 | let MainUser = class MainUser { 17 | }; 18 | __decorate([ 19 | (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), 20 | (0, graphql_1.Field)(() => String), 21 | __metadata("design:type", String) 22 | ], MainUser.prototype, "id", void 0); 23 | __decorate([ 24 | (0, graphql_1.Field)(() => String, { description: 'UserName' }), 25 | (0, typeorm_1.Column)(), 26 | __metadata("design:type", String) 27 | ], MainUser.prototype, "userName", void 0); 28 | __decorate([ 29 | (0, graphql_1.Field)(() => String, { description: 'Email' }), 30 | (0, typeorm_1.Column)(), 31 | __metadata("design:type", String) 32 | ], MainUser.prototype, "email", void 0); 33 | __decorate([ 34 | (0, graphql_1.Field)(() => String, { description: 'password' }), 35 | (0, typeorm_1.Column)(), 36 | __metadata("design:type", String) 37 | ], MainUser.prototype, "password", void 0); 38 | __decorate([ 39 | (0, graphql_1.Field)(() => Boolean, { description: 'active' }), 40 | (0, typeorm_1.Column)({ default: false }), 41 | __metadata("design:type", Boolean) 42 | ], MainUser.prototype, "isActive", void 0); 43 | __decorate([ 44 | (0, graphql_1.Field)(() => [poll_entity_1.Poll]), 45 | (0, typeorm_1.OneToMany)(() => poll_entity_1.Poll, poll => poll.user), 46 | __metadata("design:type", Promise) 47 | ], MainUser.prototype, "pollOptions", void 0); 48 | MainUser = __decorate([ 49 | (0, graphql_1.ObjectType)(), 50 | (0, typeorm_1.Entity)() 51 | ], MainUser); 52 | exports.MainUser = MainUser; 53 | //# sourceMappingURL=user.entity.js.map -------------------------------------------------------------------------------- /dist/user/user.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"user.service.js","sourceRoot":"","sources":["../../src/user/user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,6CAAmD;AAEnD,qCAAuC;AACvC,0CAAuC;AACvC,qCAAqC;AAIrC,+CAAyC;AAEzC,mCAAmC;AACnC,oDAAiD;AACjD,kDAAgD;AAChD,kEAA+D;AAG/D,IAAa,WAAW,GAAxB,MAAa,WAAW;IACtB,YAAgD,eAAqC;QAArC,oBAAe,GAAf,eAAe,CAAsB;IAAG,CAAC;IAEzF,KAAK,CAAC,MAAM,CAAC,eAAgC;QAC3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,eAAe,CAAC,KAAK,EAAC,EAAC,CAAC,CAAA;QAC9F,IAAG,UAAU,EAAE;YACZ,MAAM,IAAI,sBAAY,CAAC,oBAAoB,CAAC,CAAC;SAC/C;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,mBAAK,eAAe,EAAE,CAAC;QACnE,MAAM,IAAA,qBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,MAAM,IAAA,oCAAgB,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,eAAgC;QACvD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,eAAe,CAAC,KAAK,EAAC,EAAC,CAAC,CAAA;QAC9F,IAAG,CAAC,UAAU,EAAE;YACd,MAAM,IAAI,sBAAY,CAAC,gBAAgB,CAAC,CAAC;SAC1C;QAED,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QACxD,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU;QAC3B,MAAM,MAAM,GAAG,MAAM,aAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACnC,IAAG,CAAC,MAAM,EAAE;YACV,MAAM,IAAI,0BAAiB,EAAE,CAAC;SAC/B;QAED,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAC,EAAE,EAAE,MAAM,EAAC,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QAElE,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,EAAU;QAEf,OAAO,0BAA0B,EAAE,OAAO,CAAC;IAC7C,CAAC;IAID,KAAK,CAAC,KAAK,CAAC,UAA0B,EAAE,GAAc;QACpD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAC,EAAC,CAAC,CAAA;QACnF,IAAG,CAAC,IAAI,EAAE;YACR,MAAM,IAAI,sBAAY,CAAC,8BAA8B,CAAC,CAAC;SACxD;QAED,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAG,CAAC,aAAa,EAAE;YACjB,MAAM,IAAI,sBAAY,CAAC,oBAAoB,CAAC,CAAC;SAC9C;QAED,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QACpC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjD,OAAO,kBAAkB,IAAI,CAAC,EAAE,+BAA+B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IAC9G,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAc;QACzB,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAClC,MAAM,IAAI,sBAAY,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACjC,OAAO,qBAAqB,CAAC;IAC/B,CAAC;CACF,CAAA;AAzEY,WAAW;IADvB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,0BAAgB,EAAC,sBAAQ,CAAC,CAAA;qCAA0B,oBAAU;GADhE,WAAW,CAyEvB;AAzEY,kCAAW"} -------------------------------------------------------------------------------- /dist/app.module.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | exports.AppModule = void 0; 10 | const common_1 = require("@nestjs/common"); 11 | const graphql_1 = require("@nestjs/graphql"); 12 | const typeorm_1 = require("@nestjs/typeorm"); 13 | const path_1 = require("path"); 14 | const app_controller_1 = require("./app.controller"); 15 | const app_service_1 = require("./app.service"); 16 | const typeOrmConfig_1 = require("./config/typeOrmConfig"); 17 | const auth_guard_1 = require("./shared/auth.guard"); 18 | const user_module_1 = require("./user/user.module"); 19 | const poll_module_1 = require("./poll/poll.module"); 20 | let AppModule = class AppModule { 21 | }; 22 | AppModule = __decorate([ 23 | (0, common_1.Module)({ 24 | imports: [ 25 | typeorm_1.TypeOrmModule.forRoot(typeOrmConfig_1.typeOrmProdConfig), 26 | graphql_1.GraphQLModule.forRoot({ 27 | autoSchemaFile: (0, path_1.join)(process.cwd(), 'src/schema.gql'), 28 | playground: true, 29 | sortSchema: true, 30 | formatError: (error) => { 31 | var _a, _b, _c, _d, _e, _f; 32 | const graphQLFormattedError = { 33 | message: error.message || ((_c = (_b = (_a = error.extensions) === null || _a === void 0 ? void 0 : _a.exception) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.message), 34 | code: ((_d = error.extensions) === null || _d === void 0 ? void 0 : _d.code) || "SERVER_ERROR", 35 | name: ((_f = (_e = error.extensions) === null || _e === void 0 ? void 0 : _e.exception) === null || _f === void 0 ? void 0 : _f.name) || error.name, 36 | }; 37 | return graphQLFormattedError; 38 | }, 39 | context: ({ req, res }) => ({ req, res }) 40 | }), 41 | user_module_1.UserModule, 42 | poll_module_1.PollModule, 43 | ], 44 | controllers: [app_controller_1.AppController], 45 | providers: [app_service_1.AppService, auth_guard_1.AuthGuard], 46 | }) 47 | ], AppModule); 48 | exports.AppModule = AppModule; 49 | //# sourceMappingURL=app.module.js.map -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "voting-app-graphql", 3 | "version": "0.0.1", 4 | "description": "", 5 | "author": "", 6 | "private": true, 7 | "license": "UNLICENSED", 8 | "scripts": { 9 | "build": "npm run clean && nest build", 10 | "clean": "rimraf dist", 11 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 12 | "start": "nest start --watch", 13 | "start:debug": "nest start --debug --watch", 14 | "start:prod": "node dist/main.js", 15 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", 16 | "test": "jest", 17 | "test:watch": "jest --watch", 18 | "test:cov": "jest --coverage", 19 | "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", 20 | "test:e2e": "jest --config ./test/jest-e2e.json" 21 | }, 22 | "dependencies": { 23 | "@nestjs/common": "^8.0.0", 24 | "@nestjs/config": "^1.0.1", 25 | "@nestjs/core": "^8.0.0", 26 | "@nestjs/graphql": "^9.0.4", 27 | "@nestjs/platform-express": "^8.0.0", 28 | "@nestjs/typeorm": "^8.0.2", 29 | "apollo-server-express": "^3.3.0", 30 | "bcryptjs": "^2.4.3", 31 | "connect-redis": "^6.0.0", 32 | "cookie-parser": "^1.4.5", 33 | "dotenv": "^8.6.0", 34 | "express-session": "^1.17.2", 35 | "graphql": "^15.5.3", 36 | "ioredis": "^4.27.9", 37 | "nodemailer": "^6.6.3", 38 | "pg": "^8.7.1", 39 | "reflect-metadata": "^0.1.13", 40 | "rimraf": "^3.0.2", 41 | "rxjs": "^7.2.0", 42 | "typeorm": "^0.2.37", 43 | "uuid": "^8.3.2" 44 | }, 45 | "devDependencies": { 46 | "@nestjs/cli": "^8.0.0", 47 | "@nestjs/schematics": "^8.0.0", 48 | "@nestjs/testing": "^8.0.0", 49 | "@types/connect-redis": "^0.0.17", 50 | "@types/express": "^4.17.13", 51 | "@types/express-session": "^1.17.4", 52 | "@types/ioredis": "^4.27.2", 53 | "@types/jest": "^27.0.1", 54 | "@types/node": "^16.0.0", 55 | "@types/supertest": "^2.0.11", 56 | "@types/uuid": "^8.3.1", 57 | "@typescript-eslint/eslint-plugin": "^4.28.2", 58 | "@typescript-eslint/parser": "^4.28.2", 59 | "eslint": "^7.30.0", 60 | "eslint-config-prettier": "^8.3.0", 61 | "eslint-plugin-prettier": "^3.4.0", 62 | "jest": "^27.0.6", 63 | "prettier": "^2.3.2", 64 | "supertest": "^6.1.3", 65 | "ts-jest": "^27.0.3", 66 | "ts-loader": "^9.2.3", 67 | "ts-node": "^10.0.0", 68 | "tsconfig-paths": "^3.10.1", 69 | "typescript": "^4.3.5" 70 | }, 71 | "jest": { 72 | "moduleFileExtensions": [ 73 | "js", 74 | "json", 75 | "ts" 76 | ], 77 | "rootDir": "src", 78 | "testRegex": ".*\\.spec\\.ts$", 79 | "transform": { 80 | "^.+\\.(t|j)s$": "ts-jest" 81 | }, 82 | "collectCoverageFrom": [ 83 | "**/*.(t|j)s" 84 | ], 85 | "coverageDirectory": "../coverage", 86 | "testEnvironment": "node" 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /dist/poll/poll.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.PollService = void 0; 16 | const common_1 = require("@nestjs/common"); 17 | const typeorm_1 = require("@nestjs/typeorm"); 18 | const typeorm_2 = require("typeorm"); 19 | const poll_option_entity_1 = require("./entities/poll-option.entity"); 20 | const poll_entity_1 = require("./entities/poll.entity"); 21 | let PollService = class PollService { 22 | constructor(pollRepository, pollOptionRepository) { 23 | this.pollRepository = pollRepository; 24 | this.pollOptionRepository = pollOptionRepository; 25 | } 26 | async create(createPollInput, userId) { 27 | const poll = await this.pollRepository.save({ name: createPollInput.name, userId }); 28 | createPollInput.options.map(async (text) => { 29 | await this.pollOptionRepository.save({ 30 | text, 31 | vote: 0, 32 | pollId: poll.id 33 | }); 34 | }); 35 | return await this.pollRepository.findOne({ where: { id: poll.id }, relations: ['pollOptions'] }); 36 | } 37 | async findAll(userId) { 38 | return await this.pollRepository.findOne({ where: { userId: userId }, relations: ['pollOptions'] }); 39 | } 40 | async findOne(id, userId) { 41 | return await this.pollRepository.findOne({ where: { id: id, userId: userId }, relations: ['pollOptions'] }); 42 | } 43 | update(id, updatePollInput) { 44 | return `This action updates a #${id} poll`; 45 | } 46 | remove(id) { 47 | return `This action removes a #${id} poll`; 48 | } 49 | }; 50 | PollService = __decorate([ 51 | (0, common_1.Injectable)(), 52 | __param(0, (0, typeorm_1.InjectRepository)(poll_entity_1.Poll)), 53 | __param(1, (0, typeorm_1.InjectRepository)(poll_option_entity_1.PollOption)), 54 | __metadata("design:paramtypes", [typeorm_2.Repository, 55 | typeorm_2.Repository]) 56 | ], PollService); 57 | exports.PollService = PollService; 58 | //# sourceMappingURL=poll.service.js.map -------------------------------------------------------------------------------- /src/user/user.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NotFoundException } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import { Request } from 'express'; 4 | import { GraphQLError } from 'graphql'; 5 | import { redis } from '../utils/redis'; 6 | import { Repository } from 'typeorm'; 7 | import { CreateUserInput } from './dto/create-user.input'; 8 | import { LoginUserInput } from './dto/login-user.input'; 9 | import { UpdateUserInput } from './dto/update-user.input'; 10 | import { MainUser } from './user.entity'; 11 | 12 | import * as bcrypt from 'bcryptjs'; 13 | import { MyContext } from 'src/types/my-context'; 14 | import { sendEmail } from 'src/utils/sendEmail'; 15 | import { confirmEmailLink } from 'src/utils/confirmEmailLinks'; 16 | 17 | @Injectable() 18 | export class UserService { 19 | constructor(@InjectRepository(MainUser) private usersRepository: Repository) {} 20 | 21 | async create(createUserInput: CreateUserInput): Promise { 22 | const userExists = await this.usersRepository.findOne({where: {email: createUserInput.email}}) 23 | if(userExists) { 24 | throw new GraphQLError("User Already Exist"); 25 | } 26 | const user = await this.usersRepository.save({...createUserInput}); 27 | await sendEmail(user.email, await confirmEmailLink(user.id)); 28 | return user; 29 | } 30 | 31 | async findAll() { 32 | return await this.usersRepository.find(); 33 | } 34 | 35 | async findOne(id: string) { 36 | return await this.usersRepository.findOne(id); 37 | } 38 | 39 | async update(id: string, updateUserInput: UpdateUserInput) { 40 | const userExists = await this.usersRepository.findOne({where: {email: updateUserInput.email}}) 41 | if(!userExists) { 42 | throw new GraphQLError("User Not Found"); 43 | } 44 | 45 | this.usersRepository.merge(userExists, updateUserInput); 46 | return await this.usersRepository.save(userExists); 47 | } 48 | 49 | async confirmEmail(id: string) { 50 | const userId = await redis.get(id); 51 | if(!userId) { 52 | throw new NotFoundException(); 53 | } 54 | 55 | await this.usersRepository.update({id: userId}, {isActive: true}); 56 | 57 | return "Email Successfully Confirmed"; 58 | } 59 | 60 | remove(id: number) { 61 | 62 | return `This action removes a #${id} user`; 63 | } 64 | 65 | 66 | 67 | async login(loginInput: LoginUserInput, ctx: MyContext): Promise { 68 | const user = await this.usersRepository.findOne({where: {email: loginInput.email}}) 69 | if(!user) { 70 | throw new GraphQLError("User Not Found By This Email"); 71 | } 72 | 73 | const checkPassword = await bcrypt.compare(loginInput.password, user.password); //user.comparePassword(loginInput.password); 74 | if(!checkPassword) { 75 | throw new GraphQLError("Password Incorrect"); 76 | } 77 | // ctx.res.setHeader('Set-Cookie', `Authentication=${user.id}; HttpOnly; Path=/; Max-Age=${new Date(Date.now() + 1000 * 60 * 60 * 24)}`); 78 | ctx.req.session['userId'] = user.id; 79 | ctx.req.session['userRoles'] = ['ADMIN', 'USER']; 80 | return `Authentication=${user.id}; HttpOnly; Path=/; Max-Age=${new Date(Date.now() + 1000 * 60 * 60 * 24)}`; 81 | } 82 | 83 | async logout(ctx: MyContext): Promise { 84 | await ctx.req.session.destroy(err => { 85 | throw new GraphQLError(err); 86 | }); 87 | 88 | ctx.res.clearCookie("votingapp"); 89 | return "Successfully Logout"; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Nest Logo 3 |

4 | 5 | [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 6 | [circleci-url]: https://circleci.com/gh/nestjs/nest 7 | 8 |

A progressive Node.js framework for building efficient and scalable server-side applications.

9 |

10 | NPM Version 11 | Package License 12 | NPM Downloads 13 | CircleCI 14 | Coverage 15 | Discord 16 | Backers on Open Collective 17 | Sponsors on Open Collective 18 | 19 | Support us 20 | 21 |

22 | 24 | 25 | ## Description 26 | 27 | [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. 28 | 29 | ## Installation 30 | 31 | ```bash 32 | $ npm install 33 | ``` 34 | 35 | ## Running the app 36 | 37 | ```bash 38 | # development 39 | $ npm run start 40 | 41 | # watch mode 42 | $ npm run start:dev 43 | 44 | # production mode 45 | $ npm run start:prod 46 | ``` 47 | 48 | ## Test 49 | 50 | ```bash 51 | # unit tests 52 | $ npm run test 53 | 54 | # e2e tests 55 | $ npm run test:e2e 56 | 57 | # test coverage 58 | $ npm run test:cov 59 | ``` 60 | 61 | ## Support 62 | 63 | Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). 64 | 65 | ## Stay in touch 66 | 67 | - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) 68 | - Website - [https://nestjs.com](https://nestjs.com/) 69 | - Twitter - [@nestframework](https://twitter.com/nestframework) 70 | 71 | ## License 72 | 73 | Nest is [MIT licensed](LICENSE). 74 | -------------------------------------------------------------------------------- /dist/src/user/user.resolver.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.UserResolver = void 0; 16 | const graphql_1 = require("@nestjs/graphql"); 17 | const user_service_1 = require("./user.service"); 18 | const user_entity_1 = require("./user.entity"); 19 | const create_user_input_1 = require("./dto/create-user.input"); 20 | const update_user_input_1 = require("./dto/update-user.input"); 21 | let UserResolver = class UserResolver { 22 | constructor(userService) { 23 | this.userService = userService; 24 | } 25 | findAll() { 26 | return this.userService.findAll(); 27 | } 28 | findOne(id) { 29 | return this.userService.findOne(id); 30 | } 31 | createUser(createUser) { 32 | return this.userService.create(createUser); 33 | } 34 | updateUser(updateUserInput) { 35 | return this.userService.update(updateUserInput.id, updateUserInput); 36 | } 37 | removeUser(id) { 38 | return this.userService.remove(id); 39 | } 40 | }; 41 | __decorate([ 42 | (0, graphql_1.Query)(() => [user_entity_1.User], { name: 'users' }), 43 | __metadata("design:type", Function), 44 | __metadata("design:paramtypes", []), 45 | __metadata("design:returntype", void 0) 46 | ], UserResolver.prototype, "findAll", null); 47 | __decorate([ 48 | (0, graphql_1.Query)(() => user_entity_1.User, { name: 'user' }), 49 | __param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.Int })), 50 | __metadata("design:type", Function), 51 | __metadata("design:paramtypes", [Number]), 52 | __metadata("design:returntype", void 0) 53 | ], UserResolver.prototype, "findOne", null); 54 | __decorate([ 55 | (0, graphql_1.Mutation)(() => user_entity_1.User), 56 | __param(0, (0, graphql_1.Args)('createUser')), 57 | __metadata("design:type", Function), 58 | __metadata("design:paramtypes", [create_user_input_1.CreateUserInput]), 59 | __metadata("design:returntype", void 0) 60 | ], UserResolver.prototype, "createUser", null); 61 | __decorate([ 62 | (0, graphql_1.Mutation)(() => user_entity_1.User), 63 | __param(0, (0, graphql_1.Args)('updateUser')), 64 | __metadata("design:type", Function), 65 | __metadata("design:paramtypes", [update_user_input_1.UpdateUserInput]), 66 | __metadata("design:returntype", void 0) 67 | ], UserResolver.prototype, "updateUser", null); 68 | __decorate([ 69 | (0, graphql_1.Mutation)(() => user_entity_1.User), 70 | __param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.Int })), 71 | __metadata("design:type", Function), 72 | __metadata("design:paramtypes", [Number]), 73 | __metadata("design:returntype", void 0) 74 | ], UserResolver.prototype, "removeUser", null); 75 | UserResolver = __decorate([ 76 | (0, graphql_1.Resolver)(() => user_entity_1.User), 77 | __metadata("design:paramtypes", [user_service_1.UserService]) 78 | ], UserResolver); 79 | exports.UserResolver = UserResolver; 80 | //# sourceMappingURL=user.resolver.js.map -------------------------------------------------------------------------------- /dist/poll/poll.resolver.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.PollResolver = void 0; 16 | const graphql_1 = require("@nestjs/graphql"); 17 | const poll_service_1 = require("./poll.service"); 18 | const poll_entity_1 = require("./entities/poll.entity"); 19 | const create_poll_input_1 = require("./dto/create-poll.input"); 20 | const update_poll_input_1 = require("./dto/update-poll.input"); 21 | const common_1 = require("@nestjs/common"); 22 | const auth_guard_1 = require("../shared/auth.guard"); 23 | const getuserid_decorator_1 = require("../shared/getuserid.decorator"); 24 | let PollResolver = class PollResolver { 25 | constructor(pollService) { 26 | this.pollService = pollService; 27 | } 28 | createPoll(createPollInput, userId) { 29 | return this.pollService.create(createPollInput, userId); 30 | } 31 | findAll(userId) { 32 | return this.pollService.findAll(userId); 33 | } 34 | findOne(id, userId) { 35 | return this.pollService.findOne(id, userId); 36 | } 37 | updatePoll(updatePollInput) { 38 | return this.pollService.update(updatePollInput.id, updatePollInput); 39 | } 40 | removePoll(id) { 41 | return this.pollService.remove(id); 42 | } 43 | }; 44 | __decorate([ 45 | (0, graphql_1.Mutation)(() => poll_entity_1.Poll, { nullable: true }), 46 | (0, common_1.UseGuards)(auth_guard_1.AuthGuard), 47 | __param(0, (0, graphql_1.Args)('createPollInput')), 48 | __param(1, (0, getuserid_decorator_1.GetUserId)()), 49 | __metadata("design:type", Function), 50 | __metadata("design:paramtypes", [create_poll_input_1.CreatePollInput, String]), 51 | __metadata("design:returntype", Promise) 52 | ], PollResolver.prototype, "createPoll", null); 53 | __decorate([ 54 | (0, graphql_1.Query)(() => [poll_entity_1.Poll], { name: 'poll' }), 55 | __param(0, (0, getuserid_decorator_1.GetUserId)()), 56 | __metadata("design:type", Function), 57 | __metadata("design:paramtypes", [String]), 58 | __metadata("design:returntype", void 0) 59 | ], PollResolver.prototype, "findAll", null); 60 | __decorate([ 61 | (0, graphql_1.Query)(() => poll_entity_1.Poll, { name: 'poll' }), 62 | (0, common_1.UseGuards)(auth_guard_1.AuthGuard), 63 | __param(0, (0, graphql_1.Args)('id', { type: () => String })), 64 | __param(1, (0, getuserid_decorator_1.GetUserId)()), 65 | __metadata("design:type", Function), 66 | __metadata("design:paramtypes", [String, String]), 67 | __metadata("design:returntype", void 0) 68 | ], PollResolver.prototype, "findOne", null); 69 | __decorate([ 70 | (0, graphql_1.Mutation)(() => poll_entity_1.Poll), 71 | __param(0, (0, graphql_1.Args)('updatePollInput')), 72 | __metadata("design:type", Function), 73 | __metadata("design:paramtypes", [update_poll_input_1.UpdatePollInput]), 74 | __metadata("design:returntype", void 0) 75 | ], PollResolver.prototype, "updatePoll", null); 76 | __decorate([ 77 | (0, graphql_1.Mutation)(() => poll_entity_1.Poll), 78 | __param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.Int })), 79 | __metadata("design:type", Function), 80 | __metadata("design:paramtypes", [Number]), 81 | __metadata("design:returntype", void 0) 82 | ], PollResolver.prototype, "removePoll", null); 83 | PollResolver = __decorate([ 84 | (0, graphql_1.Resolver)(() => poll_entity_1.Poll), 85 | __metadata("design:paramtypes", [poll_service_1.PollService]) 86 | ], PollResolver); 87 | exports.PollResolver = PollResolver; 88 | //# sourceMappingURL=poll.resolver.js.map -------------------------------------------------------------------------------- /dist/user/user.service.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.UserService = void 0; 16 | const common_1 = require("@nestjs/common"); 17 | const typeorm_1 = require("@nestjs/typeorm"); 18 | const graphql_1 = require("graphql"); 19 | const redis_1 = require("../utils/redis"); 20 | const typeorm_2 = require("typeorm"); 21 | const user_entity_1 = require("./user.entity"); 22 | const bcrypt = require("bcryptjs"); 23 | const my_context_1 = require("../types/my-context"); 24 | const sendEmail_1 = require("../utils/sendEmail"); 25 | const confirmEmailLinks_1 = require("../utils/confirmEmailLinks"); 26 | let UserService = class UserService { 27 | constructor(usersRepository) { 28 | this.usersRepository = usersRepository; 29 | } 30 | async create(createUserInput) { 31 | const userExists = await this.usersRepository.findOne({ where: { email: createUserInput.email } }); 32 | if (userExists) { 33 | throw new graphql_1.GraphQLError("User Already Exist"); 34 | } 35 | const user = await this.usersRepository.save(Object.assign({}, createUserInput)); 36 | await (0, sendEmail_1.sendEmail)(user.email, await (0, confirmEmailLinks_1.confirmEmailLink)(user.id)); 37 | return user; 38 | } 39 | async findAll() { 40 | return await this.usersRepository.find(); 41 | } 42 | async findOne(id) { 43 | return await this.usersRepository.findOne(id); 44 | } 45 | async update(id, updateUserInput) { 46 | const userExists = await this.usersRepository.findOne({ where: { email: updateUserInput.email } }); 47 | if (!userExists) { 48 | throw new graphql_1.GraphQLError("User Not Found"); 49 | } 50 | this.usersRepository.merge(userExists, updateUserInput); 51 | return await this.usersRepository.save(userExists); 52 | } 53 | async confirmEmail(id) { 54 | const userId = await redis_1.redis.get(id); 55 | if (!userId) { 56 | throw new common_1.NotFoundException(); 57 | } 58 | await this.usersRepository.update({ id: userId }, { isActive: true }); 59 | return "Email Successfully Confirmed"; 60 | } 61 | remove(id) { 62 | return `This action removes a #${id} user`; 63 | } 64 | async login(loginInput, ctx) { 65 | const user = await this.usersRepository.findOne({ where: { email: loginInput.email } }); 66 | if (!user) { 67 | throw new graphql_1.GraphQLError("User Not Found By This Email"); 68 | } 69 | const checkPassword = await bcrypt.compare(loginInput.password, user.password); 70 | if (!checkPassword) { 71 | throw new graphql_1.GraphQLError("Password Incorrect"); 72 | } 73 | ctx.req.session['userId'] = user.id; 74 | ctx.req.session['userRoles'] = ['ADMIN', 'USER']; 75 | return `Authentication=${user.id}; HttpOnly; Path=/; Max-Age=${new Date(Date.now() + 1000 * 60 * 60 * 24)}`; 76 | } 77 | async logout(ctx) { 78 | await ctx.req.session.destroy(err => { 79 | throw new graphql_1.GraphQLError(err); 80 | }); 81 | ctx.res.clearCookie("votingapp"); 82 | return "Successfully Logout"; 83 | } 84 | }; 85 | UserService = __decorate([ 86 | (0, common_1.Injectable)(), 87 | __param(0, (0, typeorm_1.InjectRepository)(user_entity_1.MainUser)), 88 | __metadata("design:paramtypes", [typeorm_2.Repository]) 89 | ], UserService); 90 | exports.UserService = UserService; 91 | //# sourceMappingURL=user.service.js.map -------------------------------------------------------------------------------- /dist/user/user.resolver.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 6 | return c > 3 && r && Object.defineProperty(target, key, r), r; 7 | }; 8 | var __metadata = (this && this.__metadata) || function (k, v) { 9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 10 | }; 11 | var __param = (this && this.__param) || function (paramIndex, decorator) { 12 | return function (target, key) { decorator(target, key, paramIndex); } 13 | }; 14 | Object.defineProperty(exports, "__esModule", { value: true }); 15 | exports.UserResolver = void 0; 16 | const graphql_1 = require("@nestjs/graphql"); 17 | const user_service_1 = require("./user.service"); 18 | const user_entity_1 = require("./user.entity"); 19 | const create_user_input_1 = require("./dto/create-user.input"); 20 | const update_user_input_1 = require("./dto/update-user.input"); 21 | const login_user_input_1 = require("./dto/login-user.input"); 22 | const my_context_1 = require("../types/my-context"); 23 | const common_1 = require("@nestjs/common"); 24 | const auth_guard_1 = require("../shared/auth.guard"); 25 | let UserResolver = class UserResolver { 26 | constructor(userService) { 27 | this.userService = userService; 28 | } 29 | findAll() { 30 | return this.userService.findAll(); 31 | } 32 | findOne(id) { 33 | return this.userService.findOne(id); 34 | } 35 | createUser(createUser) { 36 | return this.userService.create(createUser); 37 | } 38 | updateUser(updateUserInput) { 39 | return this.userService.update(updateUserInput.id, updateUserInput); 40 | } 41 | removeUser(id) { 42 | return this.userService.remove(id); 43 | } 44 | loginUser(loginInput, ctx) { 45 | return this.userService.login(loginInput, ctx); 46 | } 47 | logout(ctx) { 48 | return this.userService.logout(ctx); 49 | } 50 | }; 51 | __decorate([ 52 | (0, graphql_1.Query)(() => [user_entity_1.MainUser], { name: 'users' }), 53 | (0, common_1.UseGuards)(auth_guard_1.AuthGuard), 54 | __metadata("design:type", Function), 55 | __metadata("design:paramtypes", []), 56 | __metadata("design:returntype", void 0) 57 | ], UserResolver.prototype, "findAll", null); 58 | __decorate([ 59 | (0, graphql_1.Query)(() => user_entity_1.MainUser, { name: 'user' }), 60 | __param(0, (0, graphql_1.Args)('id', { type: () => String })), 61 | __metadata("design:type", Function), 62 | __metadata("design:paramtypes", [String]), 63 | __metadata("design:returntype", void 0) 64 | ], UserResolver.prototype, "findOne", null); 65 | __decorate([ 66 | (0, graphql_1.Mutation)(() => user_entity_1.MainUser, { nullable: true }), 67 | __param(0, (0, graphql_1.Args)('createUser')), 68 | __metadata("design:type", Function), 69 | __metadata("design:paramtypes", [create_user_input_1.CreateUserInput]), 70 | __metadata("design:returntype", Promise) 71 | ], UserResolver.prototype, "createUser", null); 72 | __decorate([ 73 | (0, graphql_1.Mutation)(() => user_entity_1.MainUser, { nullable: true }), 74 | __param(0, (0, graphql_1.Args)('updateUser')), 75 | __metadata("design:type", Function), 76 | __metadata("design:paramtypes", [update_user_input_1.UpdateUserInput]), 77 | __metadata("design:returntype", void 0) 78 | ], UserResolver.prototype, "updateUser", null); 79 | __decorate([ 80 | (0, graphql_1.Mutation)(() => user_entity_1.MainUser), 81 | __param(0, (0, graphql_1.Args)('id', { type: () => graphql_1.Int })), 82 | __metadata("design:type", Function), 83 | __metadata("design:paramtypes", [Number]), 84 | __metadata("design:returntype", void 0) 85 | ], UserResolver.prototype, "removeUser", null); 86 | __decorate([ 87 | (0, graphql_1.Mutation)(() => String, { nullable: true }), 88 | __param(0, (0, graphql_1.Args)('loginInput')), 89 | __param(1, (0, graphql_1.Context)()), 90 | __metadata("design:type", Function), 91 | __metadata("design:paramtypes", [login_user_input_1.LoginUserInput, Object]), 92 | __metadata("design:returntype", void 0) 93 | ], UserResolver.prototype, "loginUser", null); 94 | __decorate([ 95 | (0, graphql_1.Mutation)(() => String, { nullable: true }), 96 | __param(0, (0, graphql_1.Context)()), 97 | __metadata("design:type", Function), 98 | __metadata("design:paramtypes", [Object]), 99 | __metadata("design:returntype", void 0) 100 | ], UserResolver.prototype, "logout", null); 101 | UserResolver = __decorate([ 102 | (0, graphql_1.Resolver)(() => user_entity_1.MainUser), 103 | __metadata("design:paramtypes", [user_service_1.UserService]) 104 | ], UserResolver); 105 | exports.UserResolver = UserResolver; 106 | //# sourceMappingURL=user.resolver.js.map --------------------------------------------------------------------------------