This is `canary` version of documentation. It's still under construction and review.
Rescale logoNEMO

Configuration

Package configuration and explanation

Middlewares

Type: MiddlewareConfig

Chain type: "main"

The middlewares object is a key-value pair where the key is the route path and the value is an array of middleware functions. Each middleware function is an async function that takes a single argument, request, which is an object containing the request details.

middleware.ts
import { type  } from "@rescale/nemo";
 
const  = {
  "/:path*": async (, ) => {
    .("There is NEMO", ..);
  },
} satisfies ;

Global Middlewares

Type: GlobalMiddlewareConfig

Chain type: "before" | "after"

The globalMiddlewares object is a key-value pair where the key is the middleware type and the value is an async function. The middleware type can be either before or after. The before middleware function will be executed before any route middleware, and the after middleware function will be executed after any route middleware.

middleware.ts
import { type  } from "@rescale/nemo";
 
const  = {
  : async () => {
    .("Before all middlewares");
  },
  : async () => {
    .("After all middlewares");
  },
} satisfies ;

Config object

Type: NemoConfig

The config object is a key-value pair where the key is the configuration option and the value is the configuration value. The available configuration options are:

PropTypeDefault
debug
boolean
false
silent
boolean
false
enableTiming
boolean
false
errorHandler
ErrorHandler
undefined
middleware.ts
import { type NemoConfig } from "@rescale/nemo";
 
const  = {
  : true,
  : true,
  : true,
  : (, ) => {
    .(, );
  },
} satisfies NemoConfig;

Example

Getting all of above informations together makes for us NEMO's full configuration representing all usable properites.

The createNEMO() constructor is the entry point for the NEMO package. It allows you to create a middleware helper that can be used to define middleware functions for your Next.js application.

middleware.ts
import {
  ,
  type ,
  type ,
  type NemoConfig,
} from "@rescale/nemo";
 
const  = {
  "/:path*": async () => {
    // middleware functions for /api route
  },
} satisfies ;
 
const  = {
  : async () => {
    // global middleware function that will be executed before any route middleware
  },
  : async () => {
    // global middleware function that will be executed after any route middleware
  },
} satisfies ;
 
const  = {
  : true, // default is false
  : true, // default is false
  : true, // default is false
  : (, ) => {
    // custom error handler
  },
} satisfies NemoConfig;
 
export const  = (
  ,
  ,
  ,
);
 
export const  = {
  : ["/((?!_next/|_static|_vercel|[\\w-]+\\.\\w+).*)"],
};

On this page