-
-
Save VinzGhyz/fa511b72bb38656fa4fb1f94b393041f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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