Examples

Advanced example

const SpringJS = require("js-spring");
const { app, database } = new SpringJS({
  name: "advanced",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./views",
  publicDir: "./public"
});

app.get("/", function(req, res) {
  database.set("Startup", new Date());
  res.send("You visited at " + database.get("Startup"));
});

EJS

const SpringJS = require("js-spring");
const { app, database } = new SpringJS({
  name: "advanced",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./views",
  publicDir: "./public"
});

app.set("view engine", "ejs");

app.get("/", function(req, res) {
  res.render("index", { time: new Date() });
});

Session

Last updated

Was this helpful?