shiori-request-helper
v2.3.2
Published
Ukagaka SHIORI request() handler wrapper and utilities
Downloads
3
Readme
shiori-request-helper.js
Ukagaka SHIORI request() handler wrapper and utilities
Install
npm:
npm install shiori-request-helper
Usage
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);
API Document
https://narazaka.github.io/shiori-request-helper.js/
License
This is released under Zlib License.