2020-10-13 11:39:07 +02:00
|
|
|
import {HttpRequest, HttpResponse} from "uWebSockets.js";
|
|
|
|
import {ADMIN_API_TOKEN} from "../Enum/EnvironmentVariable";
|
2020-09-28 18:52:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
export class BaseController {
|
|
|
|
protected addCorsHeaders(res: HttpResponse): void {
|
|
|
|
res.writeHeader('access-control-allow-headers', 'Origin, X-Requested-With, Content-Type, Accept');
|
|
|
|
res.writeHeader('access-control-allow-methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
|
|
|
res.writeHeader('access-control-allow-origin', '*');
|
|
|
|
}
|
2020-10-13 11:39:07 +02:00
|
|
|
|
|
|
|
protected checkAdminToken(req: HttpRequest): void {
|
|
|
|
//TODO
|
|
|
|
/*if(req.getHeader('Authorization') !== ADMIN_API_TOKEN){
|
|
|
|
throw 'Error token api';
|
|
|
|
}*/
|
|
|
|
}
|
2020-09-28 18:52:54 +02:00
|
|
|
}
|