-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
Charlie Mitchell edited this page Sep 30, 2018
·
1 revision
Configuration is achieved using the config.js file. Here you will describe database connection info as well as various other aspects of your installation.
- port number
- host
- defaultBodyParser
- defaultBodyParserOptions
- whether or not to expose models globally
- whether or not to log http requests
- cookie configuration
- Redis connection info
- MongoDB connection info
- defaultViewEngine
- ORM info
An example is as follows.
module.exports = {
port: process.env.SERVER_PORT || 4242,
host: process.env.HOST || "0.0.0.0",
logHTTP: true,
defaultBodyParser: "json",
exposeModelsGlobally: true,
defaultBodyParserOptions: {
limit: "0.5mb",
type: "json"
},
redis: {
host: process.env.REDIS_HOST || 'localhost',
port: process.env.REDIS_PORT || '6379'
},
cookie: {
name: "sess",
secret: process.env.SESSION_KEY || 'developmentSessionKey',
maxAge: 86400000
},
session: {
storage: "redis",
},
mongodb: {
host: process.env.DB_HOST || 'localhost',
port: process.env.DB_PORT || '27017',
database: process.env.DB_NAME || 'myDB'
},
defaultViewEngine : 'pug',
orm: "mongoose"
}
You can specify either { host, port, database } OR { url }. If url is found, Glad will connect to the database using the url option regardless of if port, host or database is used.
You can specify anything you'd like here that is supported by the redis package found on npm