Skip to content
Permalink
1446a06346
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
48 lines (39 sloc) 1.14 KB
#!/usr/bin/env node
'use strict'
/* MODULE IMPORTS */
const Koa = require('koa')
const views = require('koa-views')
const staticDir = require('koa-static')
const bodyParser = require('koa-bodyparser')
const session = require('koa-session')
const fileRoutes = require('./routs/filesRouts')
const userRoutes = require('./routs/userRouts')
//const jimp = require('jimp')
const koaBody = require('koa-body')
const app = new Koa()
/* CONFIGURING THE MIDDLEWARE */
app.keys = ['darkSecret']
app.use(staticDir('public'))
app.use(staticDir('./private'))
app.use(koaBody())
app.use(bodyParser())
app.use(session(app))
app.use(views(`${__dirname}/views`, {
extension: 'handlebars',
options: {
partials: {
navbar: `${__dirname}/views/partials/nav.handlebars`,
footer: `${__dirname}/views/partials/footer.handlebars`
}
},
map: {
handlebars: 'handlebars'
}
}))
const defaultPort = 8080
const port = process.env.PORT || defaultPort
app.use(fileRoutes.routes())
app.use(userRoutes.routes())
app.use(fileRoutes.allowedMethods())
app.use(userRoutes.allowedMethods())
module.exports = app.listen(port, async() => console.log(`listening on port ${port}`))