mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { RequestMethod, VERSION_NEUTRAL } from '@nestjs/common';
|
|
import type { VersionValue } from '@nestjs/common/internal';
|
|
|
|
export const MODULE_INIT_MESSAGE = (
|
|
text: TemplateStringsArray,
|
|
module: string,
|
|
) => `${module} dependencies initialized`;
|
|
|
|
export const ROUTE_MAPPED_MESSAGE = (path: string, method: string | number) =>
|
|
`Mapped {${path}, ${RequestMethod[method]}} route`;
|
|
|
|
export const VERSIONED_ROUTE_MAPPED_MESSAGE = (
|
|
path: string,
|
|
method: string | number,
|
|
version: VersionValue,
|
|
) => {
|
|
const controllerVersions = Array.isArray(version) ? version : [version];
|
|
const versions = controllerVersions
|
|
.map(version => (version === VERSION_NEUTRAL ? 'Neutral' : version))
|
|
.join(',');
|
|
|
|
return `Mapped {${path}, ${RequestMethod[method]}} (version: ${versions}) route`;
|
|
};
|
|
|
|
export const CONTROLLER_MAPPING_MESSAGE = (name: string, path: string) =>
|
|
`${name} {${path}}:`;
|
|
|
|
export const VERSIONED_CONTROLLER_MAPPING_MESSAGE = (
|
|
name: string,
|
|
path: string,
|
|
version: VersionValue,
|
|
) => {
|
|
const controllerVersions = Array.isArray(version) ? version : [version];
|
|
const versions = controllerVersions
|
|
.map(version => (version === VERSION_NEUTRAL ? 'Neutral' : version))
|
|
.join(',');
|
|
|
|
return `${name} {${path}} (version: ${versions}):`;
|
|
};
|
|
|
|
export const INVALID_EXECUTION_CONTEXT = (
|
|
methodName: string,
|
|
currentContext: string,
|
|
) =>
|
|
`Calling ${methodName} is not allowed in this context. Your current execution context is "${currentContext}".`;
|