mirror of
				https://github.com/KevinMidboe/leifsbackend.git
				synced 2025-10-29 17:50:20 +00:00 
			
		
		
		
	Routes moved from /routes to routes.js. app.js updated accordingly.
This commit is contained in:
		| @@ -2,11 +2,14 @@ const express = require('express') | ||||
| const logger = require('morgan') | ||||
| const bodyParser = require('body-parser') | ||||
|  | ||||
| const routes = require('./routes') | ||||
|  | ||||
| const app = express(); | ||||
|  | ||||
| app.use(logger('dev')); | ||||
| app.use(bodyParser.json()); | ||||
| app.use(bodyParser.urlencoded({ extended: false })); | ||||
| routes(app) | ||||
|  | ||||
| app.options("/*", function(req, res, next){ | ||||
|   res.header('Access-Control-Allow-Origin', 'http://localhost:8080'); | ||||
| @@ -20,8 +23,6 @@ app.all('/*', function(req, res, next) { | ||||
|   next(); | ||||
| }) | ||||
|  | ||||
| require('./routes')(app); | ||||
|  | ||||
| app.get('*', (req, res) => res.status(200).send({ | ||||
|   message: 'Welcome to the beginning of nothingness', | ||||
| })); | ||||
|   | ||||
| @@ -1,7 +1,17 @@ | ||||
| const adventureController = require('../controllers').Adventure; | ||||
| const calendarController = require('../controllers').Calendar; | ||||
| const locationController = require('../controllers').Location; | ||||
| const imageController = require('../controllers').Image; | ||||
| const adventureController = require('./controllers').Adventure; | ||||
| const calendarController = require('./controllers').Calendar; | ||||
| const locationController = require('./controllers').Location; | ||||
| const imageController = require('./controllers').Image; | ||||
| 
 | ||||
| const proxy = require('http-proxy-middleware') | ||||
| 
 | ||||
| const proxyOptions = { | ||||
|   target: 'http://localhost:5001', | ||||
|   changeOrigin: false, | ||||
|   onProxyReq: imageController.uploadRequest, | ||||
|   onProxyRes: imageController.uploadHandler | ||||
| } | ||||
| var uploadProxy = proxy(proxyOptions); | ||||
| 
 | ||||
| module.exports = (app) => { | ||||
|   app.get('/api', (req, res) => res.status(200).send({ | ||||
| @@ -14,8 +24,6 @@ module.exports = (app) => { | ||||
|    | ||||
|   app.get('/api/adventure/location', adventureController.location); | ||||
|   app.get('/api/adventure/:id', adventureController.get); | ||||
|    | ||||
|   app.post('/api/upload/', adventureController.uploadHandler); | ||||
| 
 | ||||
|   // Dates
 | ||||
|   app.get('/api/dates', calendarController.list) | ||||
| @@ -26,4 +34,7 @@ module.exports = (app) => { | ||||
|   // images
 | ||||
|   app.get('/api/images', imageController.all) | ||||
|   app.get('/api/images/:adventureId', imageController.list) | ||||
|    | ||||
|   app.post('/api/upload/:id', uploadProxy) | ||||
|   app.delete('/api/images/', imageController.delete) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user