Jijejo is a universal and easy api for all yours applications or libraries. Jijejo is a human and light alternative of json:api, json-ld, hal, openapi, graphql, joi, zod, yup, hydra ... Back to basics to get ahead in your business.
jijejo = (j)son (i)n + (j)son (e)rr + (j)son (o)ut
jijejo's specifications can be summarized in 4 rules, nothing else to learn.
When you call a function, first param is a json with always/only two attributs .meta
={...}
, .in
=<any>
(second param is zero or many adapters, Hexagonal architecture)
{
"in": [] | {} | "string" | true | false | null, // 'in' payload
"meta": {}, // optionnal meta content
}
- see schema json schemas/jijejo.in.schema.json
- see also jijejo-node to quickly write jsonin() or validate jicheck() your (j)son (i)n
When function detect an error then it always/only return a json with 4 attributs .meta
={...}
, .isout
=false
, .iserr
=true
, .err
=<any>
, .
{
"isout": false, // if error then .isout always 'false'
"iserr": true, // if error then .iserr always 'true'
"err": [] | {} | "string" | true | false | null, // 'err' payload
"meta": {}, // optionnal meta content
}
- see schema json schemas/jijejo.err.schema.json
- see also jijejo-node to quickly write jsonerr() or validate jecheck() your (j)son (e)rr
When function run without error then it always/only return a json with 4 attributs .meta
={...}
, .isout
=true
, .iserr
=false
, .out
=<any>
.
{
"iserr": false, // if ok then .iserr always 'false'
"isout": true, // if ok then .isout always 'true'
"out": [] | {} | "string" | true | false | null, // 'out' payload
"meta": {}, // optionnal meta content
}
- see schema json schemas/jijejo.out.schema.json
- see also jijejo-node to quickly write jsonout() or validate jocheck() your (j)son (o)ut
You must catch all unpredictables errors and return a json that respects a (j)son (e)rr.
Javascript example:
try{
throw new Error("unpredictable error");
} catch(error) {
return { err: { message: error.message }, iserr: true, isout: false, meta: { ... } }
}
- never trust incoming (j)son (i)n, always validate it before usage.
- never trust your (j)son (e)rr, always validate it before return.
- never trust your (j)son (o)out, always validate it before return.
- jijejo-node helps to quickly create jsonerr, jsonout jsonin, or to validate them.
Jijejo's specifications are under license CC-BY-NC-ND-4.0