@@ -41,31 +41,42 @@ function makeHandler (method, component, config = {}) {
41
41
}
42
42
43
43
/**
44
- * TODO
44
+ * A middleware method invoked on all requests
45
45
*
46
46
* @typedef RequestHandler
47
47
* @type function
48
- * @param {object } req TODO
49
- * @param {object } res TODO
50
- * @param {function } next TODO
48
+ * @param {object } req HTTP(S) Request Object
49
+ * @param {object } res HTTP(S) Response Object
50
+ * @param {function } next Express `next()` callback to continue the chain
51
51
*/
52
52
53
53
/**
54
- * TODO
54
+ * A method that handles all responses
55
55
*
56
56
* @typedef ResponseHandler
57
57
* @type function
58
- * @param {object } req TODO
59
- * @param {object } res TODO
60
- * @param {function } next TODO
58
+ * @param {object } req HTTP(S) Request Object
59
+ * @param {object } res HTTP(S) Response Object
60
+ * @param {function } next Express `next()` callback to continue the chain
61
61
*/
62
62
63
63
/**
64
+ * Custom defined method that retrieves data/results for an endpoint
65
+ *
64
66
* @typedef ActionHandler
65
67
* @type function
66
68
* @param {object } component Instance of `Mapper`, `Container`, `SimpleStore`,
67
69
* or `DataStore`.
68
- * @param {object } req TODO
70
+ * @param {object } req HTTP(S) Request Object
71
+ *
72
+ * @example <caption>A custom action</caption>
73
+ * (component, req) => {
74
+ * return new Promise((resolve, reject) => {
75
+ * // ..some logic
76
+ * return resolve(results)
77
+ * })
78
+ * }
79
+ *
69
80
* @returns {Promise } Promise that resolves with the result.
70
81
*/
71
82
@@ -76,134 +87,123 @@ function makeHandler (method, component, config = {}) {
76
87
* or `DataStore`.
77
88
* @param {object } result The result of the endpoint's {@link ActionHandler}.
78
89
* @param {object } opts Configuration options.
79
- * @returns {* } The serialized result.
90
+ * @returns {object|array|undefined } The serialized result.
80
91
*/
81
92
82
93
/**
83
- * TODO
94
+ * create action configs
84
95
*
85
96
* @typedef CreateConfig
86
97
* @type object
87
- * @property {ActionHandler } action TODO
88
- * @property {RequestHandler } request TODO
89
- * @property {ResponseHandler } response TODO
90
- * @property {number } statusCode TODO
91
- * @property {Serializer|boolean } toJSON TODO
98
+ * @property {ActionHandler } [action] Custom action to retrieve data results
99
+ * @property {number } [statusCode] The status code to return with the response
100
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
92
101
*/
93
102
94
103
/**
95
- * TODO
104
+ * createMany action configs
96
105
*
97
106
* @typedef CreateManyConfig
98
107
* @type object
99
- * @property {ActionHandler } action TODO
100
- * @property {RequestHandler } request TODO
101
- * @property {ResponseHandler } response TODO
102
- * @property {number } statusCode TODO
103
- * @property {Serializer|boolean } toJSON TODO
108
+ * @property {ActionHandler } [action] Custom action to retrieve data results
109
+ * @property {number } [statusCode] The status code to return with the response
110
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
104
111
*/
105
112
106
113
/**
107
- * TODO
114
+ * destroy action configs
108
115
*
109
116
* @typedef DestroyConfig
110
117
* @type object
111
- * @property {ActionHandler } action TODO
112
- * @property {RequestHandler } request TODO
113
- * @property {ResponseHandler } response TODO
114
- * @property {number } statusCode TODO
115
- * @property {Serializer|boolean } toJSON TODO
118
+ * @property {ActionHandler } [action] Custom action to retrieve data results
119
+ * @property {number } [statusCode] The status code to return with the response
120
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
116
121
*/
117
122
118
123
/**
119
- * TODO
124
+ * destroyAll action configs
120
125
*
121
126
* @typedef DestroyAllConfig
122
127
* @type object
123
- * @property {ActionHandler } action TODO
124
- * @property {RequestHandler } request TODO
125
- * @property {ResponseHandler } response TODO
126
- * @property {number } statusCode TODO
127
- * @property {Serializer|boolean } toJSON TODO
128
+ * @property {ActionHandler } [action] Custom action to retrieve data results
129
+ * @property {number } [statusCode] The status code to return with the response
130
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
128
131
*/
129
132
130
133
/**
131
- * TODO
134
+ * find action configs
132
135
*
133
136
* @typedef FindConfig
134
137
* @type object
135
- * @property {ActionHandler } action TODO
136
- * @property {RequestHandler } request TODO
137
- * @property {ResponseHandler } response TODO
138
- * @property {number } statusCode TODO
139
- * @property {Serializer|boolean } toJSON TODO
138
+ * @property {ActionHandler } [action] Custom action to retrieve data results
139
+ * @property {number } [statusCode] The status code to return with the response
140
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
140
141
*/
141
142
142
143
/**
143
- * TODO
144
+ * findAll action configs
144
145
*
145
146
* @typedef FindAllConfig
146
147
* @type object
147
- * @property {ActionHandler } action TODO
148
- * @property {RequestHandler } request TODO
149
- * @property {ResponseHandler } response TODO
150
- * @property {number } statusCode TODO
151
- * @property {Serializer|boolean } toJSON TODO
148
+ * @property {ActionHandler } [action] Custom action to retrieve data results
149
+ * @property {number } [statusCode] The status code to return with the response
150
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
152
151
*/
153
152
154
153
/**
155
- * TODO
154
+ * update action configs
156
155
*
157
156
* @typedef UpdateConfig
158
157
* @type object
159
- * @property {ActionHandler } action TODO
160
- * @property {RequestHandler } request TODO
161
- * @property {ResponseHandler } response TODO
162
- * @property {number } statusCode TODO
163
- * @property {Serializer|boolean } toJSON TODO
158
+ * @property {ActionHandler } [action] Custom action to retrieve data results
159
+ * @property {number } [statusCode] The status code to return with the response
160
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
164
161
*/
165
162
166
163
/**
167
- * TODO
164
+ * UpdateAllConfig action configs
168
165
*
169
166
* @typedef UpdateAllConfig
170
167
* @type object
171
- * @property {ActionHandler } action TODO
172
- * @property {RequestHandler } request TODO
173
- * @property {ResponseHandler } response TODO
174
- * @property {number } statusCode TODO
175
- * @property {Serializer|boolean } toJSON TODO
168
+ * @property {ActionHandler } [action] Custom action to retrieve data results
169
+ * @property {number } [statusCode] The status code to return with the response
170
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
176
171
*/
177
172
178
173
/**
179
- * TODO
174
+ * updateMany action configs
180
175
*
181
176
* @typedef UpdateManyConfig
182
177
* @type object
183
- * @property {ActionHandler } action TODO
184
- * @property {RequestHandler } request TODO
185
- * @property {ResponseHandler } response TODO
186
- * @property {number } statusCode TODO
187
- * @property {Serializer|boolean } toJSON TODO
178
+ * @property {ActionHandler } [action] Custom action to retrieve data results
179
+ * @property {number } [statusCode] The status code to return with the response
180
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
181
+ */
182
+
183
+ /**
184
+ * Define endpoint path with custom logic
185
+ *
186
+ * @typedef Endpoint
187
+ * @type function
188
+ * @param {Object } mapper Component Mapper object
188
189
*/
189
190
190
191
/**
191
- * TODO
192
+ * Configuration options for endpoints, actions, & request/response
192
193
*
193
194
* @typedef Config
194
195
* @type object
195
- * @property {CreateConfig } [create] TODO
196
- * @property {CreateManyConfig } [createMany] TODO
197
- * @property {DestroyConfig } [destroy] TODO
198
- * @property {DestroyAllConfig } [destroyAll] TODO
199
- * @property {FindConfig } [find] TODO
200
- * @property {FindAllConfig } [findAll] TODO
201
- * @property {RequestHandler } request TODO
202
- * @property {ResponseHandler } response TODO
203
- * @property {Serializer|boolean } [toJSON] TODO
204
- * @property {UpdateConfig } [update] TODO
205
- * @property {UpdateAllConfig } [updateAll] TODO
206
- * @property {UpdateManyConfig } [updateMany] TODO
196
+ * @property {Endpoint } [getEndpoint] Define endpoints with custom method
197
+ * @property {CreateConfig } [create] create action configs
198
+ * @property {CreateManyConfig } [createMany] createMany action configs
199
+ * @property {DestroyConfig } [destroy] destroy action configs
200
+ * @property {DestroyAllConfig } [destroyAll] destroyAll action configs
201
+ * @property {FindConfig } [find] find action configs
202
+ * @property {FindAllConfig } [findAll] findAll action configs
203
+ * @property {Serializer|boolean } [toJSON] Define custom toJSON method for response results
204
+ * @property {UpdateConfig } [update] update action configs
205
+ * @property {UpdateAllConfig } [updateAll] updateAll action configs
206
+ * @property {UpdateManyConfig } [updateMany] updateMany action configs
207
207
*/
208
208
209
209
/**
0 commit comments