-
Notifications
You must be signed in to change notification settings - Fork 15
/
web.js
124 lines (109 loc) · 2.79 KB
/
web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* eslint no-process-env: 0 */
'use strict'
/**
* Server Configuration
* (app.config.web)
*
* Configure the Web Server
*
* @see {@link http://trailsjs.io/doc/config/web}
*/
module.exports = {
express: require('express'),
/**
* CORS options
* Can be true/false or an object of CORS options
* @see {@link https://github.com/expressjs/cors#configuring-cors}
*/
cors: false,
/**
* Init method, can be used to customize express instance
*/
//init: (trailsApp, expressApp) => {},
/**
* Middlewares to load (in order)
*/
middlewares: {
/*
//middlewares loading order
order: [
'addMethods',
'cookieParser',
'session',
'bodyParser',
'compression',
'methodOverride',
'www',
'router',
'404',
'500'
]*/
/**
* Middlewares to load for body parsing
bodyParser: [
bodyParser.json(),
bodyParser.urlencoded({extended: false})
]
*/
},
/***************************************************************************
* *
* The number of seconds to cache flat files on disk being served by *
* Express static middleware (by default, these files are in `.tmp/public`) *
* *
* The HTTP static cache is only active in a 'production' environment, *
* since that's the only time Express will cache flat-files. *
* *
***************************************************************************/
cache: 31557600000,
/**
* The port to bind the web server to
*/
port: process.env.PORT || 3000,
/**
* The host to bind the web server to
*/
host: process.env.HOST || '0.0.0.0'
/**
* Alternate method to add multiple template engine, for single view template use config.views.engine
*/
/*
views: {
engines: {
// html: require('some-view-engine')
},
path: 'views'
},
*/
/**
* External configuration
* Must return a promise with the native http/https server instance
* @return Promise
*/
/*
externalConfig: (trailsApp, expressApp) => {
},
*/
/**
* SSL options
* Cert and key or pfx to create HTTPS server
*/
/*
ssl: {
key: fs.readFileSync('path/to/private.key'),
cert: fs.readFileSync('path/to/certificate.pem')
//OR pfx: fs.readFileSync('path/to/server.pfx')
},
*/
/**
* Automatically redirect HTTP to HTTPS
* Create an HTTP server who redirect to HTTPS server
* Work only if SSL is enabled
*/
//redirectToHttps: false,
/**
* Http port to use if you want to enable http and https
* SSL need to be enabled
*/
//portHttp: 80
}