UNPKG

635 BJavaScriptView Raw
1"use strict";
2
3const _ = require('lodash');
4
5const fetchCmsMeta = require('./helpers/fetchCmsMeta');
6
7const startApp = require('./helpers/app');
8
9module.exports = async port => {
10 // Initialize JSON RPC.
11 const fetched = await fetchCmsMeta();
12 const mapped = {};
13 fetched.forEach(([map, jsonRpcResponse]) => {
14 Object.keys(map).forEach(variableName => {
15 const variableValue = _.get(jsonRpcResponse, ['result', ...map[variableName].split('.')]);
16
17 mapped[variableName] = variableValue;
18 });
19 }); // Proxy for the JSON API server in Contenta CMS.
20
21 const app = await startApp(mapped);
22 return app.listen(port);
23};
\No newline at end of file