git ssb

1+

dinoworm ๐Ÿ› / catstack



Tree: 696df41be4f33081ef1725068283ee4357daf764

Files: 696df41be4f33081ef1725068283ee4357daf764 / features / support / hooks.js

1013 bytesRaw
1require('css-modules-require-hook')({})
2require('babel-register')
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 proxy: require('app/proxy')
15 }, function (module) {
16 return module.createServer(config)
17 })
18
19 function start (cb) {
20 parallel(
21 _.map(servers, function (server, name) {
22 return function (callback) {
23 server.listen(config[name].port, callback)
24 }
25 }),
26 cb
27 )
28 }
29
30 function close (cb) {
31 parallel(
32 _.map(servers, function (server, name) {
33 return function (callback) {
34 server.close(callback)
35 }
36 }),
37 cb
38 )
39 }
40
41 this.registerHandler('BeforeFeatures', function (ev, cb) {
42 start(cb)
43 })
44
45 this.registerHandler('AfterFeatures', function (ev, cb) {
46 close(cb)
47 })
48}
49

Built with git-ssb-web