Ukagaka SHIORI request() handler wrapper and utilities
npm:
npm install shiori-request-helper
import * as ShioriJK from "shiorijk";
import {
BadRequest,
InternalServerError,
NoContent,
OK,
Response,
wrapRequestCallback,
} from "../lib/shiori-request-helper";
function myRequestCallback(request: ShioriJK.Message.Request) {
switch (request.headers.ID) {
case "OnBoot": return "\\h\\s[0]hello.\\e";
case "OnHoge": return OK("\\h\\s[0]hmm.\\e");
case "OnComm": return OK("\\h\\s[0]how are you?\\e", "sakura");
case "OnEmpty": return;
case "OnFoo": return BadRequest();
case "OnBar": return InternalServerError();
default: return NoContent();
}
}
const defaultHeaders = { Charset: "UTF-8", Sender: "foo" };
export default wrapRequestCallback(myRequestCallback, defaultHeaders);
https://narazaka.github.io/shiori-request-helper.js/
This is released under Zlib License.