import { Request, Response } from 'express';
import { KnexCrudOptions } from './KnexCrudOptions';
import { CrudHandler } from './CrudHandler';
export class KnexCrudHandler implements CrudHandler {
protected table: string;
protected columns: Array<string>;
protected options: KnexCrudOptions;
public constructor (
table: string,
columns: Array<string>,
options: KnexCrudOptions = {}
) {
this.table = table;
this.columns = columns;
this.options = options;
}
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> {