View on GitHub

reading-notes

CodeFellows Class Reading Notes

Routes can be managed in separate modules from the main server, allowing us to extract that logic and wiring to be more topical.

How does this change the server’s role? For one thing, this should make our code more DRY and readable.

index.js - Entry Point server.js - Hub, Exported Server models/categories.js, etc - Data Models routes/categories.js, etc - Routers and Handlers

Routing

Response Method Description
res.download() Prompt a file to be downloaded
res.end() End the response process
res.json() Send a JSON response
res.jsonp() Send a JSON response with JSONP support
res.redirect() Redirect a request
res.render() Render a view template
res.send() Send a response of various types
res.sendFile() Send a file as an octet stream
res.sendStatus() Set the response status code and send its string representation as the response body

Home