This repository has been archived on 2020-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
requestor/lib/KnexCrudHandler.ts

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-04-16 11:09:04 +02:00
import { Request, Response } from 'express';
import { KnexCrudOptions } from './KnexCrudOptions';
2020-04-16 09:44:43 +02:00
import { CrudHandler } from './CrudHandler';
export class KnexCrudHandler implements CrudHandler {
2020-04-16 09:46:06 +02:00
protected table: string;
protected columns: Array<string>;
2020-04-16 11:09:04 +02:00
protected options: KnexCrudOptions;
2020-04-16 09:44:43 +02:00
public constructor (
table: string,
columns: Array<string>,
2020-04-16 11:09:04 +02:00
options: KnexCrudOptions = {}
2020-04-16 09:44:43 +02:00
) {
this.table = table;
this.columns = columns;
this.options = options;
}
2020-04-16 11:09:04 +02:00
private call_auth (auth?: Function, req: Request, res: Response): boolean {
if (typeof auth === 'undefined')
return true;
const promise = new Promise ((resolve) => {
const result = auth (req, res, resolve);
});
}
public async create (req: Request, res: Response): Promise<void> {
if (typeof req.body === 'undefined')
throw new Error ('request body is undefined. is body-parser running?');
const data = JSON.parse (req.body);
}
public async read (req: Request, res: Response): Promise<void> {
}
public async update (req: Request, res: Response): Promise<void> {
}
public async delete (req: Request, res: Response): Promise<void> {
}
2020-04-16 09:44:43 +02:00
}