Skip to content

Commit a76ecd9

Browse files
crobinson42jmdobry
authored andcommitted
JsDocs & Readme (#22)
* chore(jsdoc): update jsdocs * chore(readme): update readme * chore(lint): remove blank line
1 parent 06ddcc0 commit a76ecd9

File tree

2 files changed

+82
-79
lines changed

2 files changed

+82
-79
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ app.use('/api' queryParser)
4040
// Mount store at "/api"
4141
app.use('/api', new Router(store).router)
4242

43-
var api = app.route('/api')
44-
// Mount queryParser at "/api"
43+
// Create an express Router instance
44+
const api = express().Router()
45+
// Mount queryParser
4546
api.use(queryParser)
4647
// Mount UserMapper at "/api/user"
4748
api.use('/user', new Router(UserMapper).router)
4849
// Mount UserMapper at "/api/comment"
4950
api.use('/comment', new Router(CommentMapper).router)
51+
// Use api Router in an existing express app instance
52+
app.use('/api', api)
5053
```
5154

5255
## Links

src/index.js

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,42 @@ function makeHandler (method, component, config = {}) {
4141
}
4242

4343
/**
44-
* TODO
44+
* A middleware method invoked on all requests
4545
*
4646
* @typedef RequestHandler
4747
* @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
5151
*/
5252

5353
/**
54-
* TODO
54+
* A method that handles all responses
5555
*
5656
* @typedef ResponseHandler
5757
* @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
6161
*/
6262

6363
/**
64+
* Custom defined method that retrieves data/results for an endpoint
65+
*
6466
* @typedef ActionHandler
6567
* @type function
6668
* @param {object} component Instance of `Mapper`, `Container`, `SimpleStore`,
6769
* 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+
*
6980
* @returns {Promise} Promise that resolves with the result.
7081
*/
7182

@@ -76,134 +87,123 @@ function makeHandler (method, component, config = {}) {
7687
* or `DataStore`.
7788
* @param {object} result The result of the endpoint's {@link ActionHandler}.
7889
* @param {object} opts Configuration options.
79-
* @returns {*} The serialized result.
90+
* @returns {object|array|undefined} The serialized result.
8091
*/
8192

8293
/**
83-
* TODO
94+
* create action configs
8495
*
8596
* @typedef CreateConfig
8697
* @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
92101
*/
93102

94103
/**
95-
* TODO
104+
* createMany action configs
96105
*
97106
* @typedef CreateManyConfig
98107
* @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
104111
*/
105112

106113
/**
107-
* TODO
114+
* destroy action configs
108115
*
109116
* @typedef DestroyConfig
110117
* @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
116121
*/
117122

118123
/**
119-
* TODO
124+
* destroyAll action configs
120125
*
121126
* @typedef DestroyAllConfig
122127
* @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
128131
*/
129132

130133
/**
131-
* TODO
134+
* find action configs
132135
*
133136
* @typedef FindConfig
134137
* @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
140141
*/
141142

142143
/**
143-
* TODO
144+
* findAll action configs
144145
*
145146
* @typedef FindAllConfig
146147
* @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
152151
*/
153152

154153
/**
155-
* TODO
154+
* update action configs
156155
*
157156
* @typedef UpdateConfig
158157
* @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
164161
*/
165162

166163
/**
167-
* TODO
164+
* UpdateAllConfig action configs
168165
*
169166
* @typedef UpdateAllConfig
170167
* @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
176171
*/
177172

178173
/**
179-
* TODO
174+
* updateMany action configs
180175
*
181176
* @typedef UpdateManyConfig
182177
* @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
188189
*/
189190

190191
/**
191-
* TODO
192+
* Configuration options for endpoints, actions, & request/response
192193
*
193194
* @typedef Config
194195
* @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
207207
*/
208208

209209
/**

0 commit comments

Comments
 (0)