-
Notifications
You must be signed in to change notification settings - Fork 0
/
brunch-server.js
executable file
·37 lines (28 loc) · 1.16 KB
/
brunch-server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Originally created by Antoine Beauvais-Lacasse
const apostrophe = require('apostrophe');
const aposConfig = require('./apos-config');
module.exports = initializeApos;
/**
* Brunch custom server function
* See https://brunch.io/docs/config#server for details
*
* @param brunchConfig - Brunch config
* @param readyCallback - Callback to tell Brunch that server is up
* @returns {*} - Express object to close on exit
*/
function initializeApos(brunchConfig, readyCallback) {
// Register the `ready` callback on apostrophe
aposConfig.afterListen = readyCallback;
// Raw argv -- since we are running with Brunch, avoid passing them as-is.
// Otherwise, it thinks we want to run a task.
// (See apostrophe's entry-point: apostrophe/index.js)
const argv = require('yargs').argv;
aposConfig.argv = Object.assign(argv, { _: [] });
// Start apostrophe with tweaked config:
const aposRoot = apostrophe(aposConfig);
// Attach the root apos object to the function expression,
// so that our brunch hooks can get a reference to it if needed.
initializeApos.aposRoot = aposRoot;
// Return the express object as required by brunch:
return aposRoot.app;
}