You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
30 lines
1.0 KiB
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 { } |