girgir is a express.js middleware that checks input types.
Install it using npm
npm install --save girgir
Install it using yarn
yarn add girgir
girgir will uses rest api backend systems
const express = require("express");
const app = express();
app.use(express.json());
app.use(girgir({}));
const nickName = {
type: "string",
maxLen: 14,
minLen: 2,
},
const routes = {
get: {
":user": {
isPoint: true,
user: INPUT,
id: INPUT,
},
},
};
If isObject
is used, girgir will check deep params.
const routes = {
adres: {
isObject: true,
il: {
isObject: true,
slug: { type: "string" },
},
ilce: {
isObject: true,
slug: { type: "string" },
},
mahalle: {
isObject: true,
slug: { type: "string" },
},
},
};
If isCollection
is used, girgir will check object list (a.k.a collection).
const routes = {
adres: {
isObject: true,
names:{
isCollection:true,
slug:{
type:'string'
}
},
},
};
If isArray
is used, girgir will check array.
const routes = {
adres: {
isObject: true,
arr:{
isArray:true,
type:"string"
},
},
};
If isDisabled
is used, girgir will ignore results for these section.
const routes = {
adres: {
isObject: true,
il: {
isObject: true,
slug: { type: "string" },
},
ilce: {
isObject: true,
slug: { type: "string" },
},
mahalle: {
isDisabled: true,
slug: { type: "string" },
},
},
};
Girgir using .girgirrc.js
from project root path
├── /
├── post
└─┬ user
└── login
module.exports = {
users: {
public: {
get: {
":user": {
isPoint: true,
user: {
type: "string",
maxLen: 14,
minLen: 2,
},
},
id: {
isPoint: true,
id: {
type: "number",
min: 0,
max: 99,
},
},
},
},
del: {
":id": {
isPoint: true,
id: {
type: "number",
min: 0,
max: 99,
},
},
},
},
posts: {
get: {
":id": {
isPoint: true,
id: {
type: "string",
},
},
},
},
};