Express exposes a method for every standard HTTP verb. This lesson explains what each one is conventionally used for and how app.route() helps you group them for the same path.
HTTP Methods as Express Functions
Express mirrors HTTP verbs directly as methods on app (and on express.Router() instances): app.get(), app.post(), app.put(), app.patch(), app.delete(), plus app.all() for matching any method.
Following REST conventions, each verb implies an intent, GET reads, POST creates, PUT/PATCH update, DELETE removes, which keeps your API predictable for anyone consuming it.
app.route(path) returns a chainable object for registering multiple methods on one path.
It avoids repeating the same path string across several separate calls.
Works the same way on an express.Router() instance as it does on app.
app.all(path, fn) runs for every HTTP method on that path.
HTTP Method Cheatsheet
Conventional meaning of each method Express supports, and when to use it.
Method
Convention
Typical Status Code
GET
Read a resource or collection
200 OK
POST
Create a new resource
201 Created
PUT
Replace a resource entirely
200 OK / 204 No Content
PATCH
Partially update a resource
200 OK
DELETE
Remove a resource
204 No Content
ALL
Match any method on a path
Depends on handler
PUT vs PATCH
PUT conventionally replaces the entire resource, the client is expected to send a complete representation. PATCH updates only the fields provided, leaving the rest of the resource untouched. Many real APIs are lenient about this distinction, but sticking to it makes your API's behavior predictable.
app.put('/users/:id', (req, res) => {
// expects the full user object
users[req.params.id] = req.body;
res.json(users[req.params.id]);
});
app.patch('/users/:id', (req, res) => {
// merges only provided fields
users[req.params.id] = { ...users[req.params.id], ...req.body };
res.json(users[req.params.id]);
});
Using app.all()
app.all() is useful for logic that should run regardless of method, maintenance mode checks, method-agnostic logging, or a catch-all for a deprecated endpoint that should return the same error no matter how it's called.
app.all('/legacy-endpoint', (req, res) => {
res.status(410).json({ error: 'This endpoint has been removed' });
});
Common Mistakes
Using GET requests to trigger data changes, breaking caching and REST expectations.
Treating PUT and PATCH as fully interchangeable across a whole API without documenting the choice.
Forgetting that app.all() matches every method, including ones you didn't intend to support.
Repeating the same path string across five separate app.METHOD() calls instead of using app.route().
Key Takeaways
Express provides a method per HTTP verb: get, post, put, patch, delete, and more.
REST conventions map GET to reads, POST to creates, PUT/PATCH to updates, DELETE to removals.
app.route(path) groups multiple methods for the same path into one chain.
app.all() matches a path for every HTTP method.
Pro Tip
Pick PUT or PATCH as your default "update" verb for a given resource and document it, consistency across endpoints matters more to API consumers than which one you chose.
You now know every Express route method and when to use each. Next, learn how to capture dynamic values from the URL in the Route Parameters lesson.