define context interface

This commit is contained in:
Moriz Wahl 2022-04-11 15:50:02 +02:00
parent a5e10c2ed9
commit 7ec35bbfb2

View File

@ -1,9 +1,18 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Role } from '@/auth/Role'
import { User as dbUser } from '@entity/User'
const context = (args: any) => {
export interface Context {
token: string | null
setHeaders: { key: string, value: string }[]
role?: Role
user?: dbUser
}
const context = (args: any): Context => {
const authorization = args.req.headers.authorization
let token = null
let token: string | null = null
if (authorization) {
token = authorization.replace(/^Bearer /, '')
}