UNPKG

2.22 kBJavaScriptView Raw
1/**
2 * @typedef {Object} ControllerOptions
3 *
4 * @property {string} [root]
5 * @property {string} [name]
6 * @property {Object} [router]
7 * @property {boolean} [ajax]
8 * @property {Object} [map]
9 * @property {ControllerBeforeCallback} [before]
10 */
11
12
13
14/**
15 * @typedef {string|routeHandler} ControllerBeforeCallback
16 */
17
18
19
20/**
21 * @callback errorHandler
22 * @param {Error} error
23 * @param {IFRequest} request
24 * @param {IFResponse} response
25 * @param {function} next
26 */
27
28/**
29 * @callback routeHandler
30 * @param {IFRequest} request
31 * @param {IFResponse} response
32 * @param {function} next
33 */
34
35/**
36 * @typedef {T_IFRequest|IncomingMessage} IFRequest
37 */
38/**
39 * @typedef {T_IFResponse|ServerResponse} IFResponse
40 */
41
42/**
43 * @typedef {Object} T_IFRequest
44 *
45 * @property {Object} params
46 * @property {?Object} data
47 */
48
49/**
50 * @callback request_ok
51 * @param {Buffer|Array|String|Object} [data] Set status 200 and return data
52 */
53/**
54 * @callback request_fail
55 * @param {Buffer|Array|String|Object} [data] Set status 400 and return data
56 */
57/**
58 * @callback request_error
59 * @param {Buffer|Array|String|Object} [data] Set status 500 and return data
60 */
61/**
62 * @callback request_unauthorized
63 * @param {Buffer|Array|String|Object} [data] Set status 401 and return data
64 */
65/**
66 * @callback request_forbidden
67 * @param {Buffer|Array|String|Object} [data] Set status 403 and return data
68 */
69/**
70 * @callback request_not_found
71 * @param {Buffer|Array|String|Object} [data] Set status 404 and return data
72 */
73
74/**
75 * @typedef {Object} T_IFResponse
76 *
77 * @property {request_ok} ok
78 * @property {request_fail} fail
79 * @property {request_fail} bad_request
80 * @property {request_fail} badRequest
81 * @property {request_error} error
82 * @property {request_error} err
83 * @property {request_unauthorized} unauthorized
84 * @property {request_forbidden} forbidden
85 * @property {request_not_found} not_found
86 * @property {request_not_found} notFound
87 */