The server-side framework
The common blueprint of a server-side framework, read on Express and Spring Boot: routes, middleware or filters, controller, injection, data access, convention over configuration, and the path of a request.
- 25 cards
- 6 topics
- Free
The outline, topic by topic
Each topic is weighted the way the exam weighs it.
- Concepts
- Questions
- Sort and link
- On the diagram
- Scenarios
- Understand
A few cards from the deck
Middleware: what is it?
Show the answer
A function placed on a request's path, which reads or changes it then hands over to the next one, or answers itself.
In Express:
(req, res, next). If it neither answers nor callsnext(), the request hangs and the client waits until its timeout.In what order do the lines come out for a
GET /?
```javascript
app.use((req, res, next) => { console.log("A avant"); next(); console.log("A après"); });
app.use((req, res, next) => { console.log("B avant"); next(); console.log("B après"); });
app.get("/", (req, res) => { console.log("route"); res.send("ok"); });`A avant,B avant,route,B après,A aprèsA avant,A après,B avant,B après,routeA avant,B avant,route,A après,B aprèsroute,A avant,B avant,B après,A après
Show the answer
A avant,B avant,route,B après,A aprèsnext()calls the next link and only returns once that link has finished running: the “after” lines therefore come out in the reverse order of the “before” lines, like nested function calls.In Express, a middleware that has finished its job hands over to the next one by calling …; without that call and without a response, the request ….
Show the answer
In Express, a middleware that has finished its job hands over to the next one by calling next(); without that call and without a response, the request hangs.
next()is the function supplied by the framework: it is the one that knows which link of the chain comes next.Route table: what is it?
Show the answer
A list of rules associating an HTTP method and a path with the function that must handle the matching request.
In Express, the rules are tried in the order they are declared and the first match answers: a broad route placed too early hides the ones after it.