forked from globant-ui/NodeAngularWorkshop-Express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (22 loc) · 864 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
const PORT = 1338;
const cors = require('cors');
const Datastore = require('nedb');
const express = require('express');
const bodyParser = require('body-parser');
const api = require('./api');
const albumsApi = require('./api/albums')
const commentsSrv = require('./core/services/comments');
const db = new Datastore({
filename: 'datastore/workshop.db',
autoload: true
});
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use('/bands', api.bandsRoutes(db, new commentsSrv(db)));
app.use('/albums', api.albumsRoutes(db, new commentsSrv(db)));
app.use('/tracks', api.tracksRoutes(db, new commentsSrv(db)));
app.use('/artists', api.artistsRoutes(db, new commentsSrv(db)));
app.use('/comments', api.commentsRoutes(new commentsSrv(db)));
app.listen(PORT, () => console.log(`App started and listening on port ${PORT}`));