diff options
Diffstat (limited to 'backend/src/index.js')
| -rw-r--r-- | backend/src/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/backend/src/index.js b/backend/src/index.js new file mode 100644 index 0000000..128ed60 --- /dev/null +++ b/backend/src/index.js @@ -0,0 +1,22 @@ +const express = require('express'); +const bodyParser = require('body-parser'); +const cookieParser = require('cookie-parser'); +const morgan = require('morgan'); +const routes = require('./routes'); + +const app = express(); + +app.use(morgan('dev')); +app.use(bodyParser.json()); +app.use(cookieParser()); +app.use((req, res, next) => { + res.set('Access-Control-Allow-Origin', 'http://localhost:3000'); + res.set('Access-Control-Allow-Headers', 'Content-Type'); + res.set('Access-Control-Allow-Credentials', true); + next(); +}); +app.use(routes.normalRouter); +app.use(routes.authedRouter); + +const port = 4000; +app.listen(port, () => console.log(`App listening on http://localhost:${port}!`)); |
