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?
Backend/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.
34 lines (24 sloc)
905 Bytes
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
//import koa | |
var Koa = require('koa'); | |
//import koa-router which is used to route user request to its path | |
var Router = require('koa-router'); | |
const cors = require('@koa/cors'); | |
const { userAgent } = require('koa-useragent'); //for getting user agent | |
//create a koa instance and store it in app variable | |
var app = new Koa(); | |
app.proxy=true //to get the users ip | |
var router = new Router(); | |
app.use(userAgent); //gets the user agent | |
//http://localhost:3000/api/v1.0 -> at this route, display logIn | |
//Routes will go here | |
var logIn = require('./routes/logIn.js') | |
var admin = require('./routes/admin.js') | |
var home = require('./routes/home.js') | |
app.use(cors()); | |
app.use(logIn.routes()); | |
app.use(admin.routes()); | |
app.use(home.routes()); | |
//set to be the environment/deployment port number or 3000 if there isnt one | |
var port = process.env.PORT || 5000; | |
//run the werver on port 3000 | |
app.listen(port); |