working on AuthController + CreateAuth

ref #12
This commit is contained in:
2020-12-04 22:43:41 +01:00
parent c4b7ece974
commit 6cb01090d0
2 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
import { Body, JsonController, Post } from 'routing-controllers';
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
import { InvalidCredentialsError } from '../errors/AuthError';
import { UserNotFoundError } from '../errors/UserErrors';
import { CreateAuth } from '../models/creation/CreateAuth';
@JsonController('/auth')
export class AuthController {
constructor() {
}
@Post("/login")
@ResponseSchema(InvalidCredentialsError)
@ResponseSchema(UserNotFoundError)
@OpenAPI({ description: 'Create a new access token object' })
async post(@Body({ validate: true }) createAuth: CreateAuth) {
let auth;
try {
auth = await createAuth.toAuth();
console.log(auth);
} catch (error) {
return error;
}
return auth
}
}