Startup
1
const SpringJS = require("js-spring");
2
new SpringJS({ name: "test" });
Copied!

Options

Name

    Kind: String
    Example: name: "test"
    Description: This will be used just for logging purposes
1
new SpringJS({ name: "test" });
Copied!

Port

    Kind: Integer (0-65536)
    Example: port: 8080
    Description: What port to run the web server on
1
new SpringJS({
2
name: "test",
3
port: 8080
4
});
Copied!
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
1
new SpringJS({
2
name: "test",
3
port: 8080,
4
log: true
5
});
Copied!
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
1
new SpringJS({
2
name: "test",
3
port: 8080,
4
log: true,
5
mongo: "mongodb://localhost:27017/"
6
});
Copied!
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.
1
new SpringJS({
2
name: "test",
3
port: 8080,
4
log: true,
5
routes: [
6
{
7
url:'/api',
8
router: require('./api.js')
9
},
10
{
11
url:'/api2',
12
router: require('./api2.js')
13
}
14
],
15
mongo: "mongodb://localhost:27017/"
16
});
Copied!

Views Directory

    Kind: String
    Example: viewsDir: "./test/views"
    Description: The views directory
1
new SpringJS({
2
name: "test",
3
port: 8080,
4
log: true,
5
mongo: "mongodb://localhost:27017/",
6
viewsDir: "./test/views"
7
});
Copied!
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
1
new SpringJS({
2
name: "test",
3
port: 8080,
4
log: true,
5
mongo: "mongodb://localhost:27017/",
6
viewsDir: "./test/views",
7
publicDir: "./test/public"
8
});
Copied!
Last modified 2yr ago