Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
get-scrud
Advanced tools
Changelog
2023-10-16
Readme
Client for SCRUD style rest APIs
$ npm install --save get-scrud
This is a very breaking change, switching to ES Modules and eliminating babel. If you are targeting older browsers you will need to include this module in any babel-ification you're doing.
const apiCall = require('get-scrud')(*opts)
'jsonplaceholder.typicode.com'
)80
)http
)'api'
or '/api'
)'3m'
)'abc123'
)true
the defaults are applied
[{ api: 'user', action: 'read' }]
[['user', 'read']]
['user:read']
Promise
that resolves with JSON parsed response dataapiCall(*resource, *action, [*id, *body, *jwt])
'posts'
)'search'
)1
){userId: 5}
)'abc123'
)apiCall[action](...)
apiCall.[search, create, read, update, delete](*resource, [*id, *body, *jwt])
'posts'
)1
){userId: 5}
)'abc123'
)If you need to change any options on an existing instance, you can call the main function with a single argument, which is the new options you want to merge (Object.assign) with the original. That call will be synchronous.
apiCall(*opts)
const opts = {
host: 'jsonplaceholder.typicode.com',
port: 443,
timeout: '3m', // or '180s' or 180000
jwt: `abc123`
}
const apiCall = require('get-scrud')(opts)
const body = {userId: 1, title: `get scrud yo`, body: `you're scrud`}
const jwt = `def456`
async function callApis () {
/* no jwt passed, uses jwt set in init if one was set */
// SEARCH
let search = await apiCall('posts', 'search', {userId: 1})
// CREATE
let create = await apiCall('posts', 'create', body)
// READ
let read = await apiCall('posts', 'read', 1)
// UPDATE
let update = await apiCall('posts', 'update', 1, {userId: 5})
// DELETE
let deleted = !!(await apiCall('posts', 'delete', 2))
/* passing in jwt to call, overrides jwt set in init if one was set */
// SEARCH
let search = await apiCall('posts', 'search', {userId: 1}, jwt)
// CREATE
let create = await apiCall('posts', 'create', body, jwt)
// READ
let read = await apiCall('posts', 'read', 1, jwt)
// UPDATE
let update = await apiCall('posts', 'update', 1, {userId: 5}, jwt)
// DELETE
let deleted = !!(await apiCall('posts', 'delete', 2, jwt))
}
scrud - Super opinionated, minimalistic, PG centric API fabric
MIT © Andrew Carpenter
FAQs
Client for SCRUD style rest APIs
The npm package get-scrud receives a total of 2 weekly downloads. As such, get-scrud popularity was classified as not popular.
We found that get-scrud demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.