santa-fe
v0.1.0
Published
A tiny zero-dependency web framework for Node, in one file
Maintainers
Readme
santa-fe
A tiny web framework for Node. Zero dependencies, one file, ~300 lines.
const santafe = require("santa-fe");
const app = santafe();
app.use((req, res, next) => {
// runs on every request, in order added
console.log(req.method, req.path);
next(); // or respond and don't call it
});
app.static("public"); // falls through to routes if no file
app.get("/hello/:name", (req, res) => res.json({ hello: req.params.name }));
app.post("/echo", (req, res) => res.json(req.body));
app.listen(); // process.env.PORT, or 8080API
app.get .post .put .patch .delete .head .options .use(fn)
.static(dir, [{index}]) .listen([{port, host}], [cb])
| req | | res | |
| -------------------------- | --------------------------- | ------------------------------ | ----------- |
| .path .query .params | URL pieces | .status(code) | chainable |
| .body | parsed JSON, or undefined | .send(body) .json(value) | |
| .protocol | scheme the user used | .redirect(url, [code]) | default 302 |
| .ip | client address | .sendFile(path) .set(k, v) | |
Node's own req/res properties are all still there.
Paths match segment by segment; :name captures into req.params. No wildcards or regex —
that restraint is most of the size budget.
