Skip to content
Permalink
master
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
//import koa
var koa=require('koa');
//import koa-router which is used to router user request to its path
var Router=require('koa-router');
//import koa-bodyparser which is used to extract parameters from requests
//create a koa instance and store it in app variable
var app=new koa();
var router=new Router();
router.get('/api/v1.0',welcomeapi);
//use the root routes
app.use(router.routes());
//run server on port 3000
app.listen(3000);
//import the router we defined in articles.js
var articles = require('./routes/articles.js');
//apply thhe routes as a middleware
app.use(articles.routes());
function welcomeapi(cnx,next)
{
cnx.body={message:'Welcome to Oktob API version 1.0'};
}