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.
@monteway/next
Advanced tools
Useful utilities for Next.js apps.
Also a production-ready Dockerfile for Next.js projects.
npm i @moneway/next
errorPropsResponse
Return an object that is compatible with the result of getServerSideProps
/ getStaticProps
and includes an internal property marking the response as having some error.
import { errorPropsResponse } from '@monteway/next/error';
import type { GetServerSidePropsContext } from 'next';
export async function getServerSideProps(context: GetServerSidePropsContext) {
try {
// Pretend we have a call here to some API that can throw
// an error when user has no access to the page.
} catch {
// This responds with HTTP 403 status
// and returns
// {
// props: {
// error: 'You cannot access this page',
// __isErrorProps__: true
// },
// }
return errorPropsResponse(context.res, {
statusCode: 403,
error: 'You cannot access this page',
});
}
}
isErrorProps
Checks if the argument is from errorPropsResponse
.
import { errorPropsResponse, isErrorProps } from '@monteway/next/error';
const response = errorPropsResponse(null, {
statusCode: 403,
error: 'You cannot access this page',
});
isErrorProps(response.props);
// true
This package includes also a official Dockerfile for Next.js project which is production ready.
We have extended it with some optional build arguments that can be used to extend the image.
--build-arg | Description |
---|---|
BEFORE_INSTALL_COMMAND | Run before npm install |
AFTER_INSTALL_COMMAND | Run after npm install |
BEFORE_BUILD_COMMAND | Run before npm run build |
AFTER_BUILD_COMMAND | Run after npm run build |
Example usage of the Dockerfile (make sure the Docker context is root of the Next.js app):
docker build \
--build-arg BEFORE_INSTALL_COMMAND="exit 0" \
--build-arg AFTER_INSTALL_COMMAND="exit 0" \
--build-arg BEFORE_BUILD_COMMAND="exit 0" \
--build-arg AFTER_BUILD_COMMAND="exit 0" \
--tag ${IMAGE_TAG} \
--file node_modules/@monteway/next/dockerfile .
FAQs
Utilities for Monterail projects based on Next.js
The npm package @monteway/next receives a total of 12 weekly downloads. As such, @monteway/next popularity was classified as not popular.
We found that @monteway/next 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.