Merge of the middleware change to the branch

This commit is contained in:
elweyn 2021-09-05 10:40:36 +02:00
commit 18cf5ac1b4
3 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,5 @@
// import jwt from 'jsonwebtoken'
import { Resolver, Query, Args, Arg } from 'type-graphql'
import { Resolver, Query, Args, Arg, UseMiddleware } from 'type-graphql'
import CONFIG from '../../config'
import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
import { LoginResponse } from '../models/LoginResponse'
@ -15,6 +15,7 @@ import {
} from '../inputs/LoginUserInput'
import { apiPost, apiGet } from '../../apis/HttpRequest'
import { KlicktippController } from '../../apis/KlicktippController'
import { registerMiddleware } from '../../middleware/registerMiddleware'
@Resolver()
export class UserResolver {
@ -73,6 +74,7 @@ export class UserResolver {
}
@Query(() => String)
@UseMiddleware(registerMiddleware)
async create(
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
): Promise<string> {

View File

@ -0,0 +1,8 @@
import { MiddlewareFn } from 'type-graphql'
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
export const registerMiddleware: MiddlewareFn = async ({ root, args, context, info }, next) => {
const result = await next()
// do something here
return result
}

View File

@ -4,7 +4,7 @@
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */