
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@beforeyoubid/error-adapter
Advanced tools
A module to standardize error handling across the BYB platform
This is an error handling module that supports multiple error types and the handling of each type accordingly using Sentry.
This module does not set up a Sentry client, therefore a client must already be set up and initialized.
This module provides functions to handle the formatting of GraphQL errors and sending errors to Sentry based on the error type.
Error Type | Alert Raised in Sentry |
---|---|
Server Error | Yes |
Not Authorized | Yes |
Not Authenticated | No |
Not Found | No |
Validation Error | No |
Payment Error | No |
User Input Error | No |
Conflict Error | No |
yarn add @beforeyoubid/error-adapter
formatError
Using formatError
function to format errors in preparation for Sentry by passing formatError
function into GraphQL
handler.
import { ApolloServer } from 'apollo-server-lambda';
import withSentry from 'serverless-sentry-lib';
import schema from '../graphql';
import { formatError } from '@beforeyoubid/error-adapter';
const server = new ApolloServer({
schema,
formatError,
context: async ({ event, context }): Promise<ApplicationContext> => {
const headers = {};
let gqcontext = {};
if (event.headers) {
const sourceUserAgent =
_.get(event, 'headers.x-source-user-agent') || _.get(event, 'headers.X-Source-User-Agent');
gqcontext = {
sourceUserAgent,
};
}
return {
// cache,
functionName: context.functionName,
headers,
...gqcontext,
};
},
});
const graphqlHandler = server.createHandler({
cors: {
origin: '*',
methods: ['POST'],
},
});
export default withSentry(graphqlHandler);
handleErrorSentryOptions
Using handleErrorSentryOptions
function to send errors to Sentry by passing handleErrorSentryOptions
function into
Lambda GraphQL handler.
import { ApolloServer } from 'apollo-server-lambda';
import withSentry from 'serverless-sentry-lib';
import schema from '../graphql';
import { formatError, handleErrorSentryOptions } from '@beforeyoubid/error-adapter';
const server = new ApolloServer({
schema,
formatError,
context: async ({ event, context }): Promise<ApplicationContext> => {
const headers = {};
let gqcontext = {};
if (event.headers) {
const sourceUserAgent =
_.get(event, 'headers.x-source-user-agent') || _.get(event, 'headers.X-Source-User-Agent');
gqcontext = {
sourceUserAgent,
};
}
return {
// cache,
functionName: context.functionName,
headers,
...gqcontext,
};
},
});
const graphqlHandler = server.createHandler({
cors: {
origin: '*',
methods: ['POST'],
},
});
export default withSentry(handleErrorSentryOptions, graphqlHandler);
import withSentry from 'serverless-sentry-lib';
import { handleErrorSentryOptions, NotFound } from '@beforeyoubid/error-adapter';
export const cronHandler = withSentry(handleErrorSentryOptions, async (event, context) => {
console.log('EVENT: \n' + JSON.stringify(event, null, 2));
throw new Error('This error will be raised in Sentry');
throw new NotFound('This error will NOT be raised in Sentry');
return context.logStreamName;
});
FAQs
A module to standardize error handling across the BYB platform
The npm package @beforeyoubid/error-adapter receives a total of 103 weekly downloads. As such, @beforeyoubid/error-adapter popularity was classified as not popular.
We found that @beforeyoubid/error-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.