ironbar-persea/actions.js
2019-03-05 23:20:26 -06:00

39 lines
753 B
JavaScript

const {Responder} = require('./response.dev');
let responder = new Responder();
responder.start();
module.exports = () => ({
'@truss/http-get': async (action) => {
const {html, headers} = await responder.respond(action);
return {
status: 200,
headers: {
...defaultResponseHeaders(),
...headers
},
response: html,
};
},
'@truss/schema': () => ({
executors: ['@truss/http-get'],
}),
});
function defaultResponseHeaders() {
return {
date: (new Date()).toUTCString(),
connection: 'keep-alive',
};
}
if (module.hot) {
module.hot.accept('./response.dev', () => {
responder.stop();
responder = new require('./response.dev').Responder();
responder.start();
});
}