Permalink
Cannot retrieve contributors at this time
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?
Student-CV/index.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56 lines (39 sloc)
1.37 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* eslint-disable linebreak-style */ | |
// Routes File | |
'use strict' | |
/* MODULE IMPORTS */ | |
const Koa = require('koa') | |
const Router = require('koa-router') | |
const logger = require('koa-logger') | |
const session = require('koa-session') | |
const staticDir = require('koa-static') | |
const hbs = require('koahub-handlebars') | |
const bodyParser = require('koa-bodyparser') | |
require('dotenv').config() | |
const app = new Koa() | |
const router = new Router() | |
/* CONFIGURING THE MIDDLEWARE */ | |
app.keys = ['darkSecret'] | |
app.use(session(app)) | |
app.use(staticDir('public')) | |
app.use(logger()) | |
app.use(bodyParser()) | |
app.use(hbs.middleware({ | |
extname: '.handlebars', | |
viewPath: `${__dirname}/views`, | |
layoutsPath: `${__dirname}/views/layouts`, | |
partialsPath: `${__dirname}/views/partials` | |
})) | |
const defaultPort = 8080 | |
const port = process.env.PORT || defaultPort | |
router.use('/', require('./routers/main')) | |
router.use('/authentication', require('./routers/authentication/login')) | |
router.use('/register', require('./routers/authentication/signup')) | |
router.use('/contact', require('./routers/contact')) | |
router.use('/cv', require('./routers/cv')) | |
router.use('/about', require('./routers/about')) | |
router.use('/seenBy', require('./routers/seenBy')) | |
router.use('/result', require('./routers/search')) | |
app.use(router.routes()) | |
module.exports = app.listen(port, async() => console.log(`listening on port ${port}`)) |