UNPKG

551 BJavaScriptView Raw
1/* eslint-env node */
2// @flow
3const path = require('path');
4
5/* ::
6type Options = {
7 dir?: string,
8 env?: 'development' | 'production',
9};
10*/
11
12module.exports = (args /*: ?Options */) => {
13 const {dir = process.cwd(), env = 'production'} = args || {};
14 // $FlowFixMe
15 const getHandler = require(path.join(
16 dir,
17 `.fusion/dist/${env}/server/server-main.js`
18 )).default;
19 const handlerPromise = getHandler(dir);
20 return (req /*: any */, res /*: any */) => {
21 return handlerPromise.then(h => {
22 return h(req, res);
23 });
24 };
25};