diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2020-02-01 16:33:56 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2020-02-01 16:33:56 +0200 |
| commit | a5ae2653d8ccdaf00270c0c8c8a30b88d7955114 (patch) | |
| tree | bd265901dbda512fb1f6d717beb545234468d7ec /backend/src/index.js | |
| parent | fbf108595a00a7c9db5984158e4b02cc345b68d1 (diff) | |
Do stuff
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}!`)); |
