April 2020
Intermediate to advanced
292 pages
6h 50m
English
It’s an application, so we start with our standard application preamble:
| | function createAdminApplication ({ db, messageStoreDb }) { |
| | const queries = createQueries({ db, messageStoreDb }) |
| | const handlers = createHandlers({ queries }) |
| | |
| | const router = express.Router() |
| | |
| | router.route('/users').get(handlers.handleUsersIndex) |
| | router.route('/users/:id').get(handlers.handleShowUser) |
| | return { |
| | handlers, |
| | queries, |
| | router |
| | } |
| | } |
| | |
| | module.exports = createAdminApplication |
Set up the queries, handlers, and router. We’re going to start with two routes. The first is for the master list of users, and the second is for a particular user. ...