Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
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
2023-10-16
FAQs
Client for SCRUD style rest APIs
The npm package get-scrud receives a total of 46 weekly downloads. As such, get-scrud popularity was classified as not popular.
We found that get-scrud demonstrated a not healthy version release cadence and project activity because the last version was released 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.