From 243460b12959b1459ae8a7fa14d02d4897583ac6 Mon Sep 17 00:00:00 2001 From: JensUweB Date: Wed, 15 Jan 2020 10:34:06 +0100 Subject: [PATCH] removed unused stuff --- datamodel.prisma | 4 - docker-compose.yml | 18 - generated/prisma-client/index.ts | 374 ------------------ generated/prisma-client/prisma-schema.ts | 144 ------- prisma.yml | 7 - src/modules/auth/auth.module.ts | 9 +- src/modules/auth/local.strategy.ts | 22 -- src/modules/guards/auth.guard.ts | 25 -- .../martialArts/martialArts.Service.ts | 1 - 9 files changed, 3 insertions(+), 601 deletions(-) delete mode 100644 datamodel.prisma delete mode 100644 docker-compose.yml delete mode 100644 generated/prisma-client/index.ts delete mode 100644 generated/prisma-client/prisma-schema.ts delete mode 100644 prisma.yml delete mode 100644 src/modules/auth/local.strategy.ts delete mode 100644 src/modules/guards/auth.guard.ts diff --git a/datamodel.prisma b/datamodel.prisma deleted file mode 100644 index 8c735e5..0000000 --- a/datamodel.prisma +++ /dev/null @@ -1,4 +0,0 @@ -type User { - id: ID! @id - name: String! -} diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8faf46c..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3' -services: - prisma: - image: prismagraphql/prisma:1.34 - restart: always - ports: - - "4466:4466" - environment: - PRISMA_CONFIG: | - port: 4466 - # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security - # managementApiSecret: my-secret - databases: - default: - connector: mongo - schema: examadmin - uri: >- - mongodb://admin:admin%40p8x@127.0.0.1:27017/examadmin?authSource=admin&compressors=zlib&readPreference=primary&gssapiServiceName=mongodb&appname=MongoDB%20Compass%20Community&ssl=false \ No newline at end of file diff --git a/generated/prisma-client/index.ts b/generated/prisma-client/index.ts deleted file mode 100644 index a170a16..0000000 --- a/generated/prisma-client/index.ts +++ /dev/null @@ -1,374 +0,0 @@ -// Code generated by Prisma (prisma@1.34.10). DO NOT EDIT. -// Please don't change this file manually but run `prisma generate` to update it. -// For more information, please read the docs: https://www.prisma.io/docs/prisma-client/ - -import { DocumentNode } from "graphql"; -import { - makePrismaClientClass, - BaseClientOptions, - Model -} from "prisma-client-lib"; -import { typeDefs } from "./prisma-schema"; - -export type AtLeastOne }> = Partial & - U[keyof U]; - -export type Maybe = T | undefined | null; - -export interface Exists { - user: (where?: UserWhereInput) => Promise; -} - -export interface Node {} - -export type FragmentableArray = Promise> & Fragmentable; - -export interface Fragmentable { - $fragment(fragment: string | DocumentNode): Promise; -} - -export interface Prisma { - $exists: Exists; - $graphql: ( - query: string, - variables?: { [key: string]: any } - ) => Promise; - - /** - * Queries - */ - - user: (where: UserWhereUniqueInput) => UserNullablePromise; - users: (args?: { - where?: UserWhereInput; - orderBy?: UserOrderByInput; - skip?: Int; - after?: String; - before?: String; - first?: Int; - last?: Int; - }) => FragmentableArray; - usersConnection: (args?: { - where?: UserWhereInput; - orderBy?: UserOrderByInput; - skip?: Int; - after?: String; - before?: String; - first?: Int; - last?: Int; - }) => UserConnectionPromise; - node: (args: { id: ID_Output }) => Node; - - /** - * Mutations - */ - - createUser: (data: UserCreateInput) => UserPromise; - updateUser: (args: { - data: UserUpdateInput; - where: UserWhereUniqueInput; - }) => UserPromise; - updateManyUsers: (args: { - data: UserUpdateManyMutationInput; - where?: UserWhereInput; - }) => BatchPayloadPromise; - upsertUser: (args: { - where: UserWhereUniqueInput; - create: UserCreateInput; - update: UserUpdateInput; - }) => UserPromise; - deleteUser: (where: UserWhereUniqueInput) => UserPromise; - deleteManyUsers: (where?: UserWhereInput) => BatchPayloadPromise; - - /** - * Subscriptions - */ - - $subscribe: Subscription; -} - -export interface Subscription { - user: ( - where?: UserSubscriptionWhereInput - ) => UserSubscriptionPayloadSubscription; -} - -export interface ClientConstructor { - new (options?: BaseClientOptions): T; -} - -/** - * Types - */ - -export type UserOrderByInput = "id_ASC" | "id_DESC" | "name_ASC" | "name_DESC"; - -export type MutationType = "CREATED" | "UPDATED" | "DELETED"; - -export type UserWhereUniqueInput = AtLeastOne<{ - id: Maybe; -}>; - -export interface UserWhereInput { - id?: Maybe; - id_not?: Maybe; - id_in?: Maybe; - id_not_in?: Maybe; - id_lt?: Maybe; - id_lte?: Maybe; - id_gt?: Maybe; - id_gte?: Maybe; - id_contains?: Maybe; - id_not_contains?: Maybe; - id_starts_with?: Maybe; - id_not_starts_with?: Maybe; - id_ends_with?: Maybe; - id_not_ends_with?: Maybe; - name?: Maybe; - name_not?: Maybe; - name_in?: Maybe; - name_not_in?: Maybe; - name_lt?: Maybe; - name_lte?: Maybe; - name_gt?: Maybe; - name_gte?: Maybe; - name_contains?: Maybe; - name_not_contains?: Maybe; - name_starts_with?: Maybe; - name_not_starts_with?: Maybe; - name_ends_with?: Maybe; - name_not_ends_with?: Maybe; - AND?: Maybe; -} - -export interface UserCreateInput { - id?: Maybe; - name: String; -} - -export interface UserUpdateInput { - name?: Maybe; -} - -export interface UserUpdateManyMutationInput { - name?: Maybe; -} - -export interface UserSubscriptionWhereInput { - mutation_in?: Maybe; - updatedFields_contains?: Maybe; - updatedFields_contains_every?: Maybe; - updatedFields_contains_some?: Maybe; - node?: Maybe; - AND?: Maybe; -} - -export interface NodeNode { - id: ID_Output; -} - -export interface User { - id: ID_Output; - name: String; -} - -export interface UserPromise extends Promise, Fragmentable { - id: () => Promise; - name: () => Promise; -} - -export interface UserSubscription - extends Promise>, - Fragmentable { - id: () => Promise>; - name: () => Promise>; -} - -export interface UserNullablePromise - extends Promise, - Fragmentable { - id: () => Promise; - name: () => Promise; -} - -export interface UserConnection { - pageInfo: PageInfo; - edges: UserEdge[]; -} - -export interface UserConnectionPromise - extends Promise, - Fragmentable { - pageInfo: () => T; - edges: >() => T; - aggregate: () => T; -} - -export interface UserConnectionSubscription - extends Promise>, - Fragmentable { - pageInfo: () => T; - edges: >>() => T; - aggregate: () => T; -} - -export interface PageInfo { - hasNextPage: Boolean; - hasPreviousPage: Boolean; - startCursor?: String; - endCursor?: String; -} - -export interface PageInfoPromise extends Promise, Fragmentable { - hasNextPage: () => Promise; - hasPreviousPage: () => Promise; - startCursor: () => Promise; - endCursor: () => Promise; -} - -export interface PageInfoSubscription - extends Promise>, - Fragmentable { - hasNextPage: () => Promise>; - hasPreviousPage: () => Promise>; - startCursor: () => Promise>; - endCursor: () => Promise>; -} - -export interface UserEdge { - node: User; - cursor: String; -} - -export interface UserEdgePromise extends Promise, Fragmentable { - node: () => T; - cursor: () => Promise; -} - -export interface UserEdgeSubscription - extends Promise>, - Fragmentable { - node: () => T; - cursor: () => Promise>; -} - -export interface AggregateUser { - count: Int; -} - -export interface AggregateUserPromise - extends Promise, - Fragmentable { - count: () => Promise; -} - -export interface AggregateUserSubscription - extends Promise>, - Fragmentable { - count: () => Promise>; -} - -export interface BatchPayload { - count: Long; -} - -export interface BatchPayloadPromise - extends Promise, - Fragmentable { - count: () => Promise; -} - -export interface BatchPayloadSubscription - extends Promise>, - Fragmentable { - count: () => Promise>; -} - -export interface UserSubscriptionPayload { - mutation: MutationType; - node: User; - updatedFields: String[]; - previousValues: UserPreviousValues; -} - -export interface UserSubscriptionPayloadPromise - extends Promise, - Fragmentable { - mutation: () => Promise; - node: () => T; - updatedFields: () => Promise; - previousValues: () => T; -} - -export interface UserSubscriptionPayloadSubscription - extends Promise>, - Fragmentable { - mutation: () => Promise>; - node: () => T; - updatedFields: () => Promise>; - previousValues: () => T; -} - -export interface UserPreviousValues { - id: ID_Output; - name: String; -} - -export interface UserPreviousValuesPromise - extends Promise, - Fragmentable { - id: () => Promise; - name: () => Promise; -} - -export interface UserPreviousValuesSubscription - extends Promise>, - Fragmentable { - id: () => Promise>; - name: () => Promise>; -} - -/* -The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID. -*/ -export type ID_Input = string | number; -export type ID_Output = string; - -/* -The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. -*/ -export type String = string; - -/* -The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. -*/ -export type Int = number; - -/* -The `Boolean` scalar type represents `true` or `false`. -*/ -export type Boolean = boolean; - -export type Long = string; - -/** - * Model Metadata - */ - -export const models: Model[] = [ - { - name: "User", - embedded: false - } -]; - -/** - * Type Defs - */ - -export const Prisma = makePrismaClientClass>({ - typeDefs, - models, - endpoint: `http://localhost:4466` -}); -export const prisma = new Prisma(); diff --git a/generated/prisma-client/prisma-schema.ts b/generated/prisma-client/prisma-schema.ts deleted file mode 100644 index 1d05d01..0000000 --- a/generated/prisma-client/prisma-schema.ts +++ /dev/null @@ -1,144 +0,0 @@ -// Code generated by Prisma (prisma@1.34.10). DO NOT EDIT. - // Please don't change this file manually but run `prisma generate` to update it. - // For more information, please read the docs: https://www.prisma.io/docs/prisma-client/ - -export const typeDefs = /* GraphQL */ `type AggregateUser { - count: Int! -} - -type BatchPayload { - count: Long! -} - -scalar Long - -type Mutation { - createUser(data: UserCreateInput!): User! - updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User - updateManyUsers(data: UserUpdateManyMutationInput!, where: UserWhereInput): BatchPayload! - upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User! - deleteUser(where: UserWhereUniqueInput!): User - deleteManyUsers(where: UserWhereInput): BatchPayload! -} - -enum MutationType { - CREATED - UPDATED - DELETED -} - -interface Node { - id: ID! -} - -type PageInfo { - hasNextPage: Boolean! - hasPreviousPage: Boolean! - startCursor: String - endCursor: String -} - -type Query { - user(where: UserWhereUniqueInput!): User - users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]! - usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection! - node(id: ID!): Node -} - -type Subscription { - user(where: UserSubscriptionWhereInput): UserSubscriptionPayload -} - -type User { - id: ID! - name: String! -} - -type UserConnection { - pageInfo: PageInfo! - edges: [UserEdge]! - aggregate: AggregateUser! -} - -input UserCreateInput { - id: ID - name: String! -} - -type UserEdge { - node: User! - cursor: String! -} - -enum UserOrderByInput { - id_ASC - id_DESC - name_ASC - name_DESC -} - -type UserPreviousValues { - id: ID! - name: String! -} - -type UserSubscriptionPayload { - mutation: MutationType! - node: User - updatedFields: [String!] - previousValues: UserPreviousValues -} - -input UserSubscriptionWhereInput { - mutation_in: [MutationType!] - updatedFields_contains: String - updatedFields_contains_every: [String!] - updatedFields_contains_some: [String!] - node: UserWhereInput - AND: [UserSubscriptionWhereInput!] -} - -input UserUpdateInput { - name: String -} - -input UserUpdateManyMutationInput { - name: String -} - -input UserWhereInput { - id: ID - id_not: ID - id_in: [ID!] - id_not_in: [ID!] - id_lt: ID - id_lte: ID - id_gt: ID - id_gte: ID - id_contains: ID - id_not_contains: ID - id_starts_with: ID - id_not_starts_with: ID - id_ends_with: ID - id_not_ends_with: ID - name: String - name_not: String - name_in: [String!] - name_not_in: [String!] - name_lt: String - name_lte: String - name_gt: String - name_gte: String - name_contains: String - name_not_contains: String - name_starts_with: String - name_not_starts_with: String - name_ends_with: String - name_not_ends_with: String - AND: [UserWhereInput!] -} - -input UserWhereUniqueInput { - id: ID -} -` \ No newline at end of file diff --git a/prisma.yml b/prisma.yml deleted file mode 100644 index 21f98c3..0000000 --- a/prisma.yml +++ /dev/null @@ -1,7 +0,0 @@ -endpoint: http://localhost:4466 -datamodel: datamodel.prisma -databaseType: document - -generate: - - generator: typescript-client - output: ./generated/prisma-client/ \ No newline at end of file diff --git a/src/modules/auth/auth.module.ts b/src/modules/auth/auth.module.ts index 0a92dd9..0ad6c1f 100644 --- a/src/modules/auth/auth.module.ts +++ b/src/modules/auth/auth.module.ts @@ -5,11 +5,9 @@ import { AuthService } from "./auth.service"; import { JwtStrategy } from './jwt.strategy'; import { JwtModule } from "@nestjs/jwt"; import { jwtConstants } from "./constants"; -import { MongooseModule } from "@nestjs/mongoose"; -import { UserSchema } from "../user/user.schema"; import { AuthResolver } from "./auth.resolver"; -import { AuthGuard } from "../guards/auth.guard"; import { MailerService } from "./mailer.service"; +import { GraphqlAuthGuard } from "../guards/graphql-auth.guard"; @Module({ imports: [ @@ -21,10 +19,9 @@ import { MailerService } from "./mailer.service"; secret: jwtConstants.secret, signOptions: {expiresIn: 3600} }), - //MongooseModule.forFeature([{name: 'User', schema: UserSchema}]) ], - providers: [AuthService, MailerService, JwtStrategy, AuthResolver, AuthGuard], - exports: [AuthService, MailerService, JwtModule, AuthGuard] + providers: [AuthService, MailerService, JwtStrategy, AuthResolver, GraphqlAuthGuard], + exports: [AuthService, MailerService, JwtModule, GraphqlAuthGuard] }) export class AuthModule { diff --git a/src/modules/auth/local.strategy.ts b/src/modules/auth/local.strategy.ts deleted file mode 100644 index 01f75eb..0000000 --- a/src/modules/auth/local.strategy.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Strategy } from 'passport-local'; -import { PassportStrategy } from '@nestjs/passport'; -import { Injectable, UnauthorizedException } from '@nestjs/common'; -import { AuthService } from './auth.service'; - -/** - * @DEPRECATED - */ -@Injectable() -export class LocalStrategy extends PassportStrategy(Strategy) { - constructor(private readonly authService: AuthService) { - super(); - } - - async validate(email: string, password: string): Promise { - const user = await this.authService.validateUser({email, password}); - if (!user) { - throw new UnauthorizedException(); - } - return user; - } -} \ No newline at end of file diff --git a/src/modules/guards/auth.guard.ts b/src/modules/guards/auth.guard.ts deleted file mode 100644 index eabcb25..0000000 --- a/src/modules/guards/auth.guard.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { CanActivate, Injectable, ExecutionContext } from "@nestjs/common"; -import { JwtService } from "@nestjs/jwt"; -import { GqlExecutionContext } from "@nestjs/graphql"; - -/** - * @DEPRECATED - */ -@Injectable() -export class AuthGuard implements CanActivate { - constructor(readonly jwtService: JwtService/*, readonly userService: UsersService*/) { } - canActivate(context: ExecutionContext): boolean { - const ctx = GqlExecutionContext.create(context); - const { req } = ctx.getContext(); - const request = ctx.getContext().request; - const Authorization = request.get('Authorization'); - - if (Authorization) { - const token = Authorization.replace('Bearer ', ''); - const { userId, firstName } = this.jwtService.verify(token) as { userId: string; firstName: string } ; - request.authInfo = { userId, firstName }; - //console.log(request.authInfo); - return !!userId; - } - } -} \ No newline at end of file diff --git a/src/modules/martialArts/martialArts.Service.ts b/src/modules/martialArts/martialArts.Service.ts index e762dbf..dc98383 100644 --- a/src/modules/martialArts/martialArts.Service.ts +++ b/src/modules/martialArts/martialArts.Service.ts @@ -5,7 +5,6 @@ import { Model } from "mongoose"; import { MartialArtsInput } from "./inputs/martialArts.input"; import { MartialArtsDto } from "./dto/martialArts.dto"; import { RankDto } from "./dto/rank.dto"; -import { Int } from "generated/prisma-client"; @Injectable() export class MartialArtsService {