Express
We use express to start a web server and to control it. We also use body parsing, cookie parsing and helmet to keep the server secure and functional so you don't have to.
// 1
const app = require("js-spring").app;
// 2
const SpringJS = require("js-spring");
const { app } new SpringJS({ name: "test" });Example usage
const SpringJS = require("js-spring");
const { app } new SpringJS({ name: "test" });
app.use(function(req, res, next) {
req.session.name = "DanCodes";
console.log("Middleware rocks! just like Spring.js");
next();
});
app.get("/", function(req, res) {
res.status(200).send("I'm awake!");
});
app.post("/body", function(req, res) {
res.status(200).send(req.body);
});
app.get("/session", function(req, res) {
res.status(200).send(req.session.name)
});Last updated
Was this helpful?