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?
hellnodejs/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.
21 lines (16 sloc)
549 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 all the routes | |
var special = require('./routes/welcome'); | |
var admin = require('./routes/admin'); | |
var articles = require('./routes/articles.js'); | |
//create a koa instance and store it in app variable | |
var app = new Koa(); | |
////apply the routes as a middleware | |
app.use(special.routes()); | |
app.use(articles.routes()); | |
//if there is no environment variable set for port number | |
//use a default value of 3000 | |
var port = process.env.PORT || 3000; | |
//run the werver on port 3000 | |
app.listen(port); |