This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@randajan/just-api

1.2.0 • Public • Published

@randajan/just-api

NPM JavaScript Style Guide

Goal is to create simple extendable web interface using middlewares

Install

npm install @randajan/just-api

or

yarn add @randajan/just-api

Main methods

import createInterface, {
    logger,
    showError,
    showTime,
    addContext,
    formatInput,
    toJSON
} from "@randajan/just-api/sync";




const api = createInterface([
    toJSON(),
    logger(true),
    showTime(),
    showError(),
    addContext({any:"thing"}),
    formatInput(({query})=>query),
    ({request:{input}, context})=>{
        return input.foo + " | " + context.any;
    }
]);


console.log(api({query:{foo:"bar"}}));
//expected output - {"output":"bar | thing","time":{"start":"2023-01-03T02:02:00.723Z","end":"2023-01-03T02:02:00.723Z","duration":0}}

License

MIT © randajan

Readme

Keywords

Package Sidebar

Install

npm i @randajan/just-api

Weekly Downloads

10

Version

1.2.0

License

MIT

Unpacked Size

24.8 kB

Total Files

9

Last publish

Collaborators

  • randajan