Skip to content

Instantly share code, notes, and snippets.

@VinzGhyz

VinzGhyz/app.js Secret

Created August 22, 2016 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VinzGhyz/fa511b72bb38656fa4fb1f94b393041f to your computer and use it in GitHub Desktop.
Save VinzGhyz/fa511b72bb38656fa4fb1f94b393041f to your computer and use it in GitHub Desktop.
'use strict';
const path = require('path');
const serveStatic = require('feathers').static;
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const feathers = require('feathers');
const configuration = require('feathers-configuration');
const hooks = require('feathers-hooks');
const rest = require('feathers-rest');
const bodyParser = require('body-parser');
const socketio = require('feathers-socketio');
const middleware = require('./middleware');
const services = require('./services');
const app = feathers();
app.configure(configuration(path.join(__dirname, '..')));
const whitelist = app.get('corsWhitelist');
const corsOptions = {
origin(origin, callback){
const originIsWhitelisted = whitelist.indexOf(origin) !== -1;
callback(null, originIsWhitelisted);
}
};
app.use(compress())
.options('*', cors(corsOptions))
.use(cors(corsOptions))
.use(favicon( path.join(app.get('public'), 'favicon.ico') ))
.use('/', serveStatic( app.get('public') ))
.use(bodyParser.json())
.use(bodyParser.urlencoded({ extended: true }))
.configure(hooks())
.configure(rest())
.configure(socketio())
.configure(services)
.use(require('forest-express-sequelize').init({
modelsDir: __dirname + '/services',
secretKey: app.get('forest').secretKey,
authKey: app.get('forest').authKey,
sequelize: app.get('sequelize')
}))
.configure(middleware);
module.exports = app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment