npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wonkledge/okatsu

v0.0.9

Published

Node JS API Framework domain okatsu functional

Readme

OKATSU : Emphasize Domain

​ OKATSU has been created to focus on domain part rather than technical part of an API. It takes an approach from functional programming and try to bring domain into spot light.

feature function is the core of OKATSU. Through this function you'll be able to express verbosely what your endpoint has to do.

Here an example of implementation with OKATSU framework : https://github.com/wonkledge/okatsu-api-example

Medium article on okatsu https://medium.com/@alexandre.wonkledge.leroy/create-nodejs-api-embrace-your-domain-with-express-mongoose-and-okatsu-c51c30dcb54a

Okatsu has been made to work with Express and Mongoose.

If you have questions, ideas or just want to discuss about it you can reach me out :

@wonkledge on twitter

@wonkledge on stackOverflow

Documentation

feature

​ Resolve every function from right to left.

Be careful

​ Last function must be sendResponse otherwise your API will not respond.

Signature

@wonkledge/okatsu/lib/promise/feature -> ...functions -> input -> Promise

Example
const validators = [];
const mapper = [];

//fetchData is a call to a DB

const getAllData = (req, res) => {
  feature(sendResponse(res), mapFields(mapper), query(fetchData), checkParameters(validators))(req)
}

resolved

​ Returns promise resolved with data passed in.

Signature

@wonkledge/okatsu/lib/promise/resolved -> data -> Promise.resolve

Example
const sum3 = input => resolved(input + 3)
// output : new Promise((resolve) => resolve(data));

rejected

​ Returns promise rejected with data passed in.

Signature

@wonkledge/okatsu/lib/promise/rejected -> data -> Promise.reject

Example
const sum3 = input => rejected(input + 3)
// output : new Promise((resolve, reject) => reject(data));

combine

​ Returns an object with type combine and an array of functions passed in.

Signature

@wonkledge/okatsu/lib/operator/combine -> ...functions -> object

Example
const sum3 = input => input + 3;
const times2 = input => input * 2;

const sum3Times2 = combine(times2, sum3);
//output : { type: combine, combinations: [times2, sum3] }

either

​ Returns an object with type either, left part contains function that will be called if previous promise is resolved, right part contains function that will be called if previous promise is rejected.

Signature

@wonkledge/okatsu/lib/operator/either -> (left, right) -> object

Example
const sum3 = input => input + 3;
const times2 = input => input * 2;

const times2OrSum3 = either(times2, sum3);
//output : { type: either, left: times2, right: sum3 }

checkParameters

​ checkParameters will raise errors if field provided are missing or predicate failed. Errors are raised into promise reject.

​ checkParameters will return params checked into promise resolve.

Be careful

​ That function must be used inside feature function

Signature

@wonkledge/okatsu/lib/validator/checkParameters -> validators -> params -> Promise.resolved || Promise.rejected

Example
const validators = [
    {
        field: 'id',
        predicate: id => id.toString().match(/^[0-9]+$/),
        errorMessage: 'id must be integer'
    }
];

checkParameters(validators) // output : Promise resolve with params or Promise reject with error raised

mapFields

Be careful

​ This function must be used inside feature function.

Signature

@wonkledge/okatsu/lib/datamapper/mapFields -> mapping -> data -> Promise.resolved

Example
const mapping = [
    {
        source: 'bestSeller',
        target: 'best_seller'
    },
    {
        source: 'sales',
        target: 'sales',
        transform: (sales) => sales > 100000 ? "Damn it, you're famous" : "Who are you ?"
    }
];

mapFields(mapping); //output : Promise resolve with data mapped

sendResponse

Signature

@wonkledge/okatsu/lib/response/sendResponse -> res -> either

Example
// variable res is given by express to respond.
sendResponse(res) // output : { type: either, left: handleResponse, right: handleErrorResponse } 

query

Signature

@wonkledge/okatsu/lib/mongooseAdapter/query -> callback -> combine

Example
// Consider Data is a model of mongoose library
const fetchData = (params) => Data.find();
query(fetchData)

httpResponseWrapper

Signature

@wonkledge/okatsu/lib/httpCode/httpResponseWrapper -> (httpCode, payload) -> object

Example
httpResponseWrapper(HTTP_CODE_500, 'Something bad happen') // output : { code: 500, payload : 'Something bad happen'}