const express = require('express'); const bodyParser = require('body-parser'); import { CreateSongEndpointHandler } from './endpoints/CreateSongEndpointHandler'; import { CreateArtistEndpointHandler } from './endpoints/CreateArtistEndpointHandler'; import { ListSongsEndpointHandler } from './endpoints/ListSongsEndpointHandler'; import { ListArtistsEndpointHandler } from './endpoints/ListArtistsEndpointHandler'; const models = require('./models'); import * as api from '../client/src/api'; const app = express(); // TODO: configurable port const port = process.env.PORT || 5000; app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); // Set up REST API endpoints app.post(api.CreateSongEndpoint, CreateSongEndpointHandler); app.get(api.ListSongsEndpoint, ListSongsEndpointHandler); app.post(api.CreateArtistEndpoint, CreateArtistEndpointHandler); app.get(api.ListArtistsEndpoint, ListArtistsEndpointHandler); models.sequelize.sync().then(() => { app.listen(port, () => console.log(`Listening on port ${port}`)); }) export { }