This commit is contained in:
Timo Hocker 2020-04-09 10:31:15 +02:00
parent 7a9e12e62d
commit 999d493c68
4 changed files with 14 additions and 14 deletions

View File

@ -1,5 +1,5 @@
export default class Session { export default class Session {
public user_id: number; public user_id?: number;
public user_name: string; public user_name?: string;
public permissions: Array<string>; public permissions?: Array<string>;
} }

View File

@ -9,7 +9,7 @@ export default class Status {
return this._status; return this._status;
} }
public set status (value: number): void { public set status (value: number) {
this._status = value; this._status = value;
} }

View File

@ -1,4 +1,4 @@
import { Request, Response } from '@types/express'; import { Request, Response } from 'express';
import Status from './Status'; import Status from './Status';
import Session from './Session'; import Session from './Session';
@ -12,7 +12,7 @@ export default class Transaction {
public get req (): Request { return this._req; } public get req (): Request { return this._req; }
public get res (): Response { return this._res; } public get res (): Response { return this._res; }
public get status (): Status { return this._status; } public get status (): Status { return this._status; }
public session: Session; public session?: Session;
/* constructor */ /* constructor */
public constructor (req: Request, res: Response) { public constructor (req: Request, res: Response) {
@ -22,8 +22,8 @@ export default class Transaction {
} }
/* methods */ /* methods */
public finalize (): void { public finalize (data: any): void {
if (this._status.has_status ()) if (this._status.has_status)
this._res.status (this.status.status); this._res.status (this.status.status);
this._res.end (data); this._res.end (data);
} }

View File

@ -1,4 +1,4 @@
import { App } from '@types/express'; import { App } from 'express';
import Handler from './classes/Handler'; import Handler from './classes/Handler';
/** /**
@ -9,13 +9,13 @@ import Handler from './classes/Handler';
*/ */
export default function load_handlers ( export default function load_handlers (
app: App, app: App,
handlers: array<Handler> handlers: Array<Handler>
): void { ): void {
for (const h of handlers) for (const h of handlers)
app.use (h.path, h.run_http_handler); app.use (h.path, h.run_http_handler);
} }
export * from './classes/Session.ts'; export * from './classes/Session';
export * from './classes/Status.ts'; export * from './classes/Status';
export * from './classes/Transaction.ts'; export * from './classes/Transaction';
export * from './classes/Handler.ts'; export * from './classes/Handler';