Removing all "any" from back.
To do this, I used generic-type-guard package which generates both an interface AND a valid type guard from code. With this, we are 100% sure that the messages we receive are validated at runtime! The client cannot pass us an object that is invalid! \o/
This commit is contained in:
parent
ac0b7a7361
commit
a373626e24
11 changed files with 113 additions and 59 deletions
|
@ -4,6 +4,11 @@ import {BAD_REQUEST, OK} from "http-status-codes";
|
|||
import {SECRET_KEY, URL_ROOM_STARTED} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
||||
import { uuid } from 'uuidv4';
|
||||
|
||||
export interface TokenInterface {
|
||||
name: string,
|
||||
userId: string
|
||||
}
|
||||
|
||||
export class AuthenticateController {
|
||||
App : Application;
|
||||
|
||||
|
@ -24,7 +29,7 @@ export class AuthenticateController {
|
|||
}*/
|
||||
//TODO check user email for The Coding Machine game
|
||||
const userId = uuid();
|
||||
const token = Jwt.sign({name: param.name, userId: userId}, SECRET_KEY, {expiresIn: '24h'});
|
||||
const token = Jwt.sign({name: param.name, userId: userId} as TokenInterface, SECRET_KEY, {expiresIn: '24h'});
|
||||
return res.status(OK).send({
|
||||
token: token,
|
||||
mapUrlStart: URL_ROOM_STARTED,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue