Skip to content

Instantly share code, notes, and snippets.

@fiveisprime
Last active August 29, 2015 13:57
Show Gist options
  • Save fiveisprime/9772211 to your computer and use it in GitHub Desktop.
Save fiveisprime/9772211 to your computer and use it in GitHub Desktop.
Koa Scaffold
var koa = require('koa');
var path = require('path');
var route = require('koa-route');
var render = require('koa-swig');
var app = koa();
render(app, {
root: path.join(__dirname, 'views'),
autoescape: true,
cache: 'memory',
ext: 'html'
});
app.use(require('koa-logger')());
app.use(require('koa-favi')());
app.use(require('koa-body')());
app.use(require('koa-static')(path.join(__dirname, 'public')));
app.use(route.get('/', function *(){
yield this.render('index');
}));
app.listen(process.env.PORT || 3000);
{
"name": "koa-scaffold",
"version": "0.0.0",
"description": "Scaffold application using Koa.",
"main": "app.js",
"scripts": {
"start": "node --harmony app"
},
"engines": {
"node": "0.11.x"
},
"author": "Matt Hernandez <[email protected]>",
"license": "ISC",
"dependencies": {
"koa": "^0.5.2",
"koa-route": "^1.1.1",
"koa-logger": "^1.2.0",
"koa-swig": "^0.3.0",
"koa-static": "^1.4.3",
"koa-favi": "^0.1.0",
"koa-body": "0.0.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment