3 /* For development only */
5 /* Configure winston before all else! */
6 var env = require('gitter-web-env');
7 var winston = env.logger;
9 winston.info('Starting server/static.js');
11 var express = require('express');
12 var http = require('http');
13 var cors = require('cors');
16 var server = http.createServer(app);
18 // Sanity check whether the server is up and running so it doesn't fail silently
20 if (!server.listening) {
21 winston.info('Static server failed to startup after 5 seconds, ' + server.listening);
28 methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
29 maxAge: 600, // 10 minutes
30 allowedHeaders: ['content-type', 'x-access-token', 'authorization', 'accept'],
32 // Rate limiting with dolph
34 'X-RateLimit-Remaining',
39 app.use(cors(corsOptions));
40 app.options('*', cors(corsOptions));
42 require('./web/express-static').install(app);
44 var port = process.env.PORT || 5001;
46 server.listen(port, function(err) {
48 winston.error('An error occurred during static server startup: ' + err, { exception: err });
51 winston.info('Listening on ' + port);