Startup

const SpringJS = require("js-spring");
new SpringJS({ name: "test" });

Options

Name

  • Kind: String

  • Example: name: "test"

  • Description: This will be used just for logging purposes

new SpringJS({ name: "test" });

Port

  • Kind: Integer (0-65536)

  • Example: port: 8080

  • Description: What port to run the web server on

new SpringJS({
  name: "test",
  port: 8080
});

We suggest port 8080 for development but you are free to use any port number between 0 and 65536

Log

  • Kind: Boolean

  • Example: log: true

  • Description: Whether or not to log requests to the console

new SpringJS({
  name: "test",
  port: 8080,
  log: true
});

Logging will show path of request, speed and status code sent

Mongo

  • Kind: String

  • Example: mongo: "mongodb://localhost:27017/"

  • Description: Mongo server to connect to your database

new SpringJS({
  name: "test",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/"
});

We use enmap and enmap-mongo for connecting and using your mongo database both of which work but are no longer supported.

Routes

  • Kind: Array

  • Example: routes: [{ url:'/', router: require('./api.js') }]

  • Description: For assigning routes to your application.

new SpringJS({
  name: "test",
  port: 8080,
  log: true,
  routes: [
    {
     url:'/api',
     router: require('./api.js')
    },
    {
     url:'/api2',
     router: require('./api2.js')
    }
  ],
  mongo: "mongodb://localhost:27017/"
});

Views Directory

  • Kind: String

  • Example: viewsDir: "./test/views"

  • Description: The views directory

new SpringJS({
  name: "test",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./test/views"
});

We recommend this option only if you are setting a view engine like ejs or pug

Public Directory

  • Kind: String

  • Example: publicDir: "./test/views"

  • Description: The public directory for express

new SpringJS({
  name: "test",
  port: 8080,
  log: true,
  mongo: "mongodb://localhost:27017/",
  viewsDir: "./test/views",
  publicDir: "./test/public"
});

Last updated