![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.
Abstraction for standard API responses based on this post by Andrey Petrov
{
"code": 200,
"status": "ok",
"messages": [],
"result": {
"user": {
"id": 123,
"name": "shazow"
}
}
}
Install
$ npm install ayeepi --save
Usage
const ayeepi = require('ayeepi');
// ... some restify setup or whatever
app.post('/foo', (req, res) => {
const id = req.body.id;
let message;
doSomething(id)
.then((data) => {
message = `It worked for ${id}!`;
ayeepi.ok(res, message);
})
.catch((err) => {
log.error(err.message);
message = `An error occures while doing that thing for ${id}`;
ayeepi.error(res, message);
})
})
/**
* Sends a 200 `OK` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 200,
* "status": "OK",
* "messages": [`Whatever you did worked`]
* }
*
*/
ok(res, messages)
/**
* Sends a 500 `Internal Server Error` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer. Error
* message(s) should go here
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 500,
* "status": "Internal Server Error",
* "messages": [`something broke!`]
* }
*
*/
error(res, messages)
/**
* Sends a 403 `Forbidden` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 403,
* "status": "Forbidden",
* "messages": [`can't touch this!`]
* }
*
*/
forbidden(res, messages)
/**
* Sends a 404 `Not Found` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 404,
* "status": "Not Found",
* "messages": [`couldn't find it`]
* }
*
*/
notFound(res, messages)
/**
* Sends a 501 `Not Implemented` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 501,
* "status": "Not Implemented",
* "messages": [`this isn't ready!`]
* }
*
*/
notImplemented(res, msgs)
/**
* Sends a 401 `Unauthorized` response
*
* @param {Response} A response object
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 403,
* "status": "Unauthorized",
* "messages": [`I don't know you!`]
* }
*
*/
unauthorized(res, msgs)
/**
* Sends a 200 `OK` response with a data payload
*
* @param {Response} A response object
* @param {Object} The data to be sent to the client
* @param {Array|String} A string or array of strings to be used to
* transport messages to the API consumer
* @return {Object} The payload that was sent to the client
*
* @example
* {
* "code": 200,
* "status": "OK",
* "messages": [`Here's the result of the stuff`],
* "result": {} // your data
* }
*
*/
send(res, data, msgs)
Tests
$ npm test
Totally welcome. Create a PR, create a passing test, adhere to .jshint rules and if it makes sense - I'm happy to merge it!
FAQs
- Abstraction for standard API responses
The npm package ayeepi receives a total of 0 weekly downloads. As such, ayeepi popularity was classified as not popular.
We found that ayeepi 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.