Advertisement
Guest User

Untitled

a guest
Sep 14th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const favicon = require('serve-favicon');
  3. const compress = require('compression');
  4. const helmet = require('helmet');
  5. const cors = require('cors');
  6. const logger = require('./logger');
  7.  
  8. const feathers = require('@feathersjs/feathers');
  9. const configuration = require('@feathersjs/configuration');
  10. const express = require('@feathersjs/express');
  11. const socketio = require('@feathersjs/socketio');
  12. const redirectToHTTPS = require('express-http-to-https').redirectToHTTPS
  13.  
  14. const botRoute = require('./botRoute');
  15.  
  16. const middleware = require('./middleware');
  17. const services = require('./services');
  18. const appHooks = require('./app.hooks');
  19. const channels = require('./channels');
  20.  
  21. const sequelize = require('./sequelize');
  22.  
  23. const authentication = require('./authentication');
  24.  
  25. const app = express(feathers());
  26.  
  27. // Load app configuration
  28. app.configure(configuration());
  29. // Enable security, CORS, compression, favicon and body parsing
  30. app.use(redirectToHTTPS());
  31. app.use(helmet());
  32. app.use(cors());
  33. app.use(compress());
  34. app.use(express.json());
  35. app.use(express.urlencoded({ extended: true }));
  36. app.use(favicon(path.join(app.get('public'), 'favicon.ico')));
  37. // Host the public folder
  38. app.use('/', express.static(app.get('public')));
  39.  
  40. app.use('/bot', botRoute);
  41.  
  42. // Set up Plugins and providers
  43. app.configure(express.rest());
  44. app.configure(socketio());
  45.  
  46. app.configure(sequelize);
  47. // Configure other middleware (see `middleware/index.js`)
  48. app.configure(middleware);
  49. app.configure(authentication);
  50. // Set up our services (see `services/index.js`)
  51. app.configure(services);
  52. // Set up event channels (see channels.js)
  53. app.configure(channels);
  54.  
  55. // Configure a middleware for 404s and the error handler
  56. app.use(express.notFound());
  57. app.use(express.errorHandler({ logger }));
  58.  
  59. app.hooks(appHooks);
  60.  
  61. module.exports = app;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement