app.js 855 B

123456789101112131415161718192021222324252627
  1. //© 2019 Dublin City University, Trinity College Dublin. All rights reserved. This material may not be reproduced, displayed, modified or distributed without the express prior written permission of the copyright holder.
  2. import express from 'express';
  3. import cors from 'cors';
  4. import bodyParser from 'body-parser';
  5. import router from './routes';
  6. import mongoose from 'mongoose';
  7. import httpContext from 'express-http-context';
  8. const app = express();
  9. mongoose.connect('mongodb://localhost/knowledgeBaseDB', { useNewUrlParser: true });
  10. mongoose.Promise = global.Promise;
  11. //app.use(httpContext.middleware);
  12. app.use(cors());
  13. // Parse incoming requests data
  14. app.use(bodyParser.json());
  15. app.use(bodyParser.urlencoded({ extended: false }));
  16. app.use(router);
  17. const PORT = 5000;
  18. app.listen(PORT, () => {
  19. console.log(`server running on port ${PORT}`);
  20. });