Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@monteway/next

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@monteway/next

Utilities for Monterail projects based on Next.js

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@monteway/next

Useful utilities for Next.js apps.
Also a production-ready Dockerfile for Next.js projects.

Install

npm i @moneway/next

Usage

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

Docker

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-argDescription
BEFORE_INSTALL_COMMANDRun before npm install
AFTER_INSTALL_COMMANDRun after npm install
BEFORE_BUILD_COMMANDRun before npm run build
AFTER_BUILD_COMMANDRun 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 .

Keywords

FAQs

Package last updated on 27 Apr 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc