Skip to content

Commit fe71be6

Browse files
committed
moved to koa
1 parent 8c35c21 commit fe71be6

24 files changed

Lines changed: 130 additions & 260 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ node_modules/
2626
tmp/
2727

2828
# Brunch output folder.
29-
public/
29+
www/
3030

3131
# Bower stuff.
3232
bower_components/

app.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
'use strict';
1+
"use strict";
22

3-
/**
4-
* Module dependencies.
5-
*/
6-
var log = require('lib/log')(module);
7-
var config = require('config');
3+
const log = require('lib/log')(module);
4+
const config = require('config');
85

9-
var express = require('express');
10-
var bootable = require('bootable');
6+
const koa = require('koa');
117

12-
// End of dependencies.
8+
require('models');
139

10+
const app = koa();
1411

15-
var app = module.exports = bootable(express());
12+
require('setup/static')(app);
1613

14+
require('setup/errors')(app);
1715

18-
/**
19-
* syntax: bootable.initializers('folder', context);
20-
*/
21-
app.phase(bootable.initializers('./models', app));
22-
app.phase(bootable.initializers('./setup', app));
16+
require('setup/logger')(app);
17+
require('setup/bodyParser')(app);
18+
require('setup/session')(app);
19+
require('setup/render')(app);
20+
require('setup/router')(app);
21+
22+
require('./routes')(app);
2323

2424
module.exports = app;

app/stylesheets/main.scss

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/stylesheets/main.styl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* :-) */
2+
h1
3+
font-style italic
4+

bin/www

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@
33

44
var app = require('app');
55
var log = require('lib/log')(module);
6+
var config = require('config');
67

7-
8-
app.set('port', process.env.PORT || 3000);
9-
// При деплое на некоторых хостингах кроме порта нужно слушать еще и хост
10-
app.set('host', process.env.HOST || '0.0.0.0');
11-
12-
13-
app.boot(function(err) {
14-
if (err) { throw err; }
15-
app.listen(app.get('port'), app.get('host'), function() {
16-
log.info('Express listen %s:%d', app.get('host'), app.get('port'));
17-
});
8+
app.listen(config.port, config.host, function() {
9+
log.info('App listen %s:%d', config.host, config.port);
1810
});

config/base.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = function() {
22
return {
3-
"port": 3000,
3+
"port": process.env.PORT || 3000,
4+
"host": process.env.HOST || '0.0.0.0',
45
"mongoose": {
56
"uri": "mongodb://localhost/javascript",
67
"options": {
@@ -13,16 +14,14 @@ module.exports = function() {
1314
}
1415
},
1516
"session": {
16-
"secret": "KillerIsJim",
17-
"key": "sid",
18-
"cookie": {
19-
"path": "/",
20-
"httpOnly": true,
21-
"maxAge": null
22-
}
17+
"keys": ["KillerIsJim"]
2318
},
24-
"log": {
25-
"format": "default"
19+
template: {
20+
path: process.cwd() + '/views',
21+
options: {
22+
'default': 'jade',
23+
'cache': true
24+
}
2625
}
2726
}
2827
};

config/env/development.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
var _ = require('lodash');
22

33
module.exports = function(config) {
4-
return _.merge(config, {
5-
"log": {
6-
"format": "dev"
7-
}
8-
});
4+
return config;
95
};

controllers/frontpage.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
exports.get = function *get (next) {
3+
yield this.render('index', {
4+
title: 'Hello, world'
5+
});
6+
};
7+

models/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var fs = require("fs");
2+
3+
fs.readdirSync(__dirname).forEach(function(file) {
4+
if (file == 'index.js') return;
5+
require("./" + file);
6+
});

models/session.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)