-
Notifications
You must be signed in to change notification settings - Fork 0
/
express-rest-generator.d.ts
35 lines (31 loc) · 1.08 KB
/
express-rest-generator.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
declare module 'express-rest-generator' {
import * as express from 'express';
/**
* Custom database error handle
* @param {any} err - The database error
*/
type ErrorHandler = (err: any) => void;
/**
* Hook executed over data before db insertion
* @param {any} data - The incoming data from client
* @return {any} The final data to insert in database
*/
type beforeInsert = (data: {[id: string]: any}) => {[id: string]: any}
/**
* Hook executed over data before sending data to client
* @param {any} data - The incoming data from database
* @return {any} The final data to send to the client
*/
type beforeSend = (data: {[id: string]: any}) => {[id: string]: any}
interface IOptions extends {[id: string]: any} {
db: any;
error?: ErrorHandler;
beforeInsert?: beforeInsert;
beforeSend?: beforeSend;
}
/**
* Generate a restfull resources
* @param {Object} options - Configure the service. db, error, beforeInsert, beforeSend
*/
export default function expressRestGenerator (options: IOptions) => express.Router;
}