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?
QuizMaker/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.
48 lines (34 sloc)
1.15 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
'use strict'; | |
//import koa | |
var Koa = require('koa'); | |
const cors = require('@koa/cors'); | |
const passport = require('koa-passport'); | |
//const AccessControl = require('accesscontrol'); | |
var welcome = require('./routes/welcome.js'); | |
var admin = require('./routes/admin.js'); | |
var users = require('./routes/users.js'); | |
var quiz = require('./routes/quiz.js'); | |
var questions = require('./routes/questions.js'); | |
var answers = require('./routes/answers.js'); | |
//create a koa instance and store it in app variable | |
var app = new Koa(); | |
app.use(cors()); | |
require('./auth'); | |
app.use(passport.initialize()); | |
app.use(welcome.routes()); | |
app.use(admin.routes()); | |
app.use(users.routes()); | |
app.use(quiz.routes()); | |
app.use(questions.routes()); | |
app.use(answers.routes()); | |
if (process.env.NODE_ENV === 'production') { | |
// Serve any static files | |
app.use(express.static(path.join(__dirname, 'client/build'))); | |
// Handle React routing, return all requests to React app | |
app.get('*', function(req, res) { | |
res.sendFile(path.join(__dirname, 'client/build', 'index.html')); | |
}); | |
} | |
var port = process.env.PORT || 3000; | |
//run the server on port 3000 | |
app.listen(port); |