seal-helper
v0.0.0-4
Published
helper every seal needed
Downloads
1
Readme
seal-helper
Tired of writing repetitive code? Dun worry seal-helper will help you
how to use
- yarn add seal-helper
- import where you need it
import {
request,
cookie,
replaceInput,
} from 'seal-helper'
- make request
const cbSuccess = res => {}
const cbError = err => {}
request({
req: {
type: 'POST',
headers: {...},
data: {},
qs: {},
routes: '/v1/user',
endpoint: 'https://abc.com',
},
successCriteria: {
header: 200,
hasData: true,
hasColumn: 'id',
typeofData: 'array',
},
onSuccess: (res) => cbSuccess(res),
onError: (err) => cbError(err),
})
- cookie method (get, getAll, set, remove)
get
const userCookie = cookie.get({ name: 'user' })
getAll
const allCookies = cookie.getAll()
remove cookie
cookie.remove({ name: 'user' })
set cookie options (object): Support all the cookie options from RFC 6265 path (string): cookie path, use / as the path if you want your cookie to be accessible on all pages expires (Date): absolute expiration date for the cookie maxAge (number): relative max age of the cookie from when the client receives it in second domain (string): domain for the cookie (sub.domain.com or .allsubdomains.com) secure (boolean): Is only accessible through HTTPS? httpOnly (boolean): Is only the server can access the cookie? sameSite (boolean|lax|strict): Strict or Lax enforcement
cookie.set({ name, value, options })
- replace input
const newInput = replaceInput({
value: '',
regex: 'url', // regex name: url, number, string, autonumeric,
replacer: 'x', // value that didnt match regex will be replaced by x
})
input
replaceInput({
"value": "H3LL0",
"regex": "alpha",
"replacer": ""
})
replaceInput({
"value": "hello",
"regex": "numeric",
"replacer": "0"
})
output
HLL
00000