انتقل إلى المحتوى
#0833
Exec

The route was a line of code; now it's a filename

Forty Express routes on a Heroku dyno. The migration plan was a rewrite. The migration is a copy.

Exec accepts the Express signature as-is: module.exports = async (req, res) => { … }. req.body is already parsed JSON. res.status(201).json(...) chains the way it does in Express; res.redirect, res.send, res.setHeader are there. What disappears is the line above each handler: app.get('/users/:id', …): because the file is the route: users/[id].ts, with :id arriving as metadata.parameters.id. Handlers move one file at a time. There is no app.listen, no port, no process to keep alive; exec is the server.

A dyno was $7 a month for one process. On a $29 bare metal box the forty routes are forty files, next to whatever else you put there. The route was a line of code; now it's a filename, and the handler didn't change.

The route was a line of code; now it's a filename, and the handler didn't change.