![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
an opinionated client for interacting with JSON rest endpoints
npm i --save-dev kno-rest
This client has several opinions, and was initially built for quickly working with rails JSON apis that I often end up building. The conventions it follows work well with my workflow, but your mileage may vary.
As an example of this, see the src/default_headers.js
file where you'll see
that all the rest calls include the X-CSRF-Token
header which is plucked from
the rails page on which the application lives. Also, we always set the Accept
header to application/json
Create a new instance and call a crud endpoint:
cont ENDPOINT = "/api/v1/messages"
async function getMessages() {
let messageService = new KRest(ENDPOINT)
let messages = await messagesService.index() // makes a GET call to endpoint
return messages
}
index
Run a GET call against endpoint:
kRest.index()
create
Run a POST call against endpoint:
kRest.create({message: {title: "hi", user_id: 3}})
show
Run a GET call against member route of endpoint with an id
kRest.show(45)
update
Run a PUT call against member route of endpoint with an id
let message = {id: 45, title:"hello", user_id: 3}
kRest.update(message.id, {message})
destroy
Run a DELETE call against member route of endpoint with an id
kRest.destroy(45)
returns true
if call was successful, false
if not
The above methods all take advantage of two methods on the kno-rest object.
collection
and member
. Using them you can buildup endpoint urls and execute
ajax calls to non-standard REST endpoints as well
For example assume you have typical REST crud stuff for a Foo at /api/v1/foo
,
but you also have a member route at /api/v1/foo/:id/bars
. You can use the
member
method to hit it with various method requests.
let ENDPOINT = "/api/v1/foo"
krest = new KnoRest(ENDPOINT)
let bar = {name: 'baz'}
kRest.member('POST', 32, {bar}, 'bar')
// sends POST to '/api/v1/foo/32/bar' with the {bar} object
Same for collection routes:
let ENDPOINT = "/api/v1/foo"
krest = new KnoRest(ENDPOINT)
krest.collection('GET', {from: '7d', to: '2d'}, 'sort')
// calls GET on /api/v1/foo/sort with the from and to params
FAQs
simple rest client helper
We found that kno-rest 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.