const koa = require('koa')
const logger = require('koa-logger')
const route = require('koa-route')

const db = require('./utils/db')
const migration = require('./utils/migration')
const config = require('./utils/config')
const constants = require('./utils/constants/path-constants')
const songController = require('./controllers/song-controller')

const server = module.exports = koa()
server.name = config.get('app:name')
server.use(logger())

server.use(route.get(constants.API_SONGS, songController.getAllSongs))
server.use(route.get(`${constants.API_SONGS}/:id`, songController.getSong))
server.use(route.get(constants.API_SONGS_RANDOM, songController.getRandomSong))

server.listen(process.env.PORT || config.get('app:port') || 8080, () => {
    db.init(config.get('db:config'))
      .then(() => !!config.get('db:migration:enabled') && migration.initData(config.get('db:migration:url')))
    console.log(`${server.name} application started!`)
})

@@ -530,19 +530,16 @@
 ute.get(
-%60$%7B
 constant
@@ -553,14 +553,15 @@
 ONGS
-%7D/:id%60
+_RANDOM
 , so
@@ -576,16 +576,22 @@
 ller.get
+Random
 Song))%0As
@@ -602,32 +602,35 @@
 r.use(route.get(
+%60$%7B
 constants.API_SO
@@ -624,39 +624,38 @@
 stants.API_SONGS
-_RANDOM
+%7D/:id%60
 , songController
@@ -654,30 +654,24 @@
 ntroller.get
-Random
 Song))%0A%0Aserv

reorder routes