git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 52f3c40a60eb0332de1dad2a79d0a7063dc2b127

Files: 52f3c40a60eb0332de1dad2a79d0a7063dc2b127 / features / support / hooks.js

985 bytesRaw
1require('babel-core/register')
2require('css-modules-require-hook')
3
4const _ = require('lodash')
5const parallel = require('run-parallel')
6
7const config = require('app/config')
8
9module.exports = function () {
10 const servers = _.mapValues({
11 static: require('app/static'),
12 api: require('app/api'),
13 render: require('app/render')
14 }, function (module) {
15 return module.createServer(config)
16 })
17
18 function start (cb) {
19 parallel(
20 _.map(servers, function (server, name) {
21 return function (callback) {
22 server.listen(config[name].url.port, callback)
23 }
24 }),
25 cb
26 )
27 }
28
29 function close (cb) {
30 parallel(
31 _.map(servers, function (server, name) {
32 return function (callback) {
33 server.close(callback)
34 }
35 }),
36 cb
37 )
38 }
39
40 this.registerHandler('BeforeFeatures', function (ev, cb) {
41 start(cb)
42 })
43
44 this.registerHandler('AfterFeatures', function (ev, cb) {
45 close(cb)
46 })
47}
48

Built with git-ssb-web