chore: imported existing user module files from old repo
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import { ApolloDriver, ApolloDriverConfig } from '@nestjs/apollo';
|
||||
import { AppResolver } from './app.resolver';
|
||||
import { UserModule } from './user/user.module';
|
||||
import { GQLComplexityPlugin } from './plugins/GQLComplexityPlugin';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -44,8 +43,8 @@ import { AppResolver } from './app.resolver';
|
||||
},
|
||||
driver: ApolloDriver,
|
||||
}),
|
||||
UserModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService, AppResolver],
|
||||
providers: [GQLComplexityPlugin],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
10
packages/hoppscotch-backend/src/user/user.module.ts
Normal file
10
packages/hoppscotch-backend/src/user/user.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UserResolver } from './user.resolver';
|
||||
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
||||
|
||||
@Module({
|
||||
imports: [PubSubModule],
|
||||
providers: [UserResolver],
|
||||
exports: [],
|
||||
})
|
||||
export class UserModule {}
|
||||
57
packages/hoppscotch-backend/src/user/user.resolver.ts
Normal file
57
packages/hoppscotch-backend/src/user/user.resolver.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Resolver, Query } from '@nestjs/graphql';
|
||||
import { User } from './user.model';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
import { GqlAuthGuard } from '../guards/gql-auth.guard';
|
||||
import { GqlUser } from '../decorators/gql-user.decorator';
|
||||
|
||||
@Resolver(() => User)
|
||||
export class UserResolver {
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
constructor() {}
|
||||
|
||||
// Query
|
||||
// @Query(() => User, {
|
||||
// nullable: true,
|
||||
// description: 'Finds a user by their UID or null if no match',
|
||||
// deprecationReason:
|
||||
// 'Deprecated due to privacy concerns. Try to get the user from the context-relevant queries',
|
||||
// })
|
||||
// async user(@Args({ name: 'uid', type: () => ID }) uid: string): Promise<User | null> {
|
||||
// return this.userService.getUserForUID(uid);
|
||||
// }
|
||||
|
||||
@Query(() => User, {
|
||||
description:
|
||||
"Gives details of the user executing this query (pass Authorization 'Bearer' header)",
|
||||
})
|
||||
@UseGuards(GqlAuthGuard)
|
||||
me(@GqlUser() user: User): User {
|
||||
return user;
|
||||
}
|
||||
|
||||
// // Mutation
|
||||
// @Mutation(() => Boolean, {
|
||||
// description: 'Delete an user account',
|
||||
// })
|
||||
// @UseGuards(GqlAuthGuard)
|
||||
// deleteUser(
|
||||
// @GqlUser() user:User
|
||||
// ): Promise<boolean> {
|
||||
// return pipe(
|
||||
// this.userService.deleteUserByUID(user),
|
||||
// TE.map(() => true),
|
||||
// TE.mapLeft((message) => message.toString()),
|
||||
// TE.getOrElse(throwErr)
|
||||
// )();
|
||||
// }
|
||||
//
|
||||
// // Subscription
|
||||
// @Subscription(() => User, {
|
||||
// description: 'Listen for user deletion',
|
||||
// resolve: (value) => value,
|
||||
// })
|
||||
// @UseGuards(GqlAuthGuard)
|
||||
// userDeleted(@GqlUser() user: User): AsyncIterator<User> {
|
||||
// return this.pubsub.asyncIterator(`user/${user.uid}/deleted`);
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user