forked from jspruance/musician-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (24 loc) · 794 Bytes
/
app.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
31
const express = require('express');
const path = require('path');
const store = require('./store/datastore');
const initialStoreData = require('./store/data');
const Musician = require('./models/musician');
const musicianRoutes = require('./routes/musician');
const app = express();
const port = process.env.PORT || 3001;
// include routes
app.use('/musician', musicianRoutes);
app.use(express.static('public'));
// Index route
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client/build/index.html'));
});
// initialize store
const musician = new Musician(store);
musician.initStore(initialStoreData);
app.locals.musician = musician;
// start server
const server = app.listen(port, () => {
console.log("Server started on port " + port);
});
module.exports = server;