Narazaka / shiori-request-helper.js

Ukagaka SHIORI request() handler wrapper and utilities
0 stars 0 forks source link
shiori ukagaka

shiori-request-helper.js

npm npm license npm download total npm download by month

Dependency Status devDependency Status Travis Build Status AppVeyor Build Status codecov.io

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.