ironbar-persea/actions.js
2018-09-03 02:03:23 -05:00

36 lines
738 B
JavaScript

const {invokeHookSerial} = require('@truss/truss');
const {Responder} = require('./response.dev');
const responder = new Responder();
module.exports = () => ({
'truss/http-get': (action) => {
const {payload: {headers}} = action;
delete headers.host;
delete headers.connection;
return responder.respond(action).then((html) => {
return invokeHookSerial('truss/web-response', {
status: 200,
headers: defaultHeaders(),
html,
}, headers);
});
},
'truss/schema': () => {
return {executors: ['truss/http-get']};
},
});
function defaultHeaders() {
return {
Date: (new Date()).toUTCString(),
Connection: 'keep-alive',
'Transfer-Encoding': 'chunked',
};
}