next-rest-framework
Version:
Next REST Framework - Type-safe, self-documenting APIs for Next.js
288 lines (285 loc) • 8.7 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// package.json
var require_package = __commonJS({
"package.json"(exports2, module2) {
module2.exports = {
name: "next-rest-framework",
version: "6.1.1",
description: "Next REST Framework - Type-safe, self-documenting APIs for Next.js",
keywords: [
"nextjs",
"rest",
"api",
"next-rest-framework"
],
homepage: "https://next-rest-framework.vercel.app",
bugs: {
url: "https://github.com/blomqma/next-rest-framework/issues",
email: "blomqma@omg.lol"
},
license: "ISC",
author: "Markus Blomqvist <blomqma@omg.lol>",
files: [
"dist"
],
main: "dist/index.js",
module: "dist/index.mjs",
types: "dist/index.d.ts",
repository: {
type: "git",
url: "https://github.com/blomqma/next-rest-framework.git",
directory: "packages/next-rest-framework"
},
scripts: {
lint: "tsc",
test: "jest",
"test:watch": "jest --watch",
build: "tsup --dts"
},
bin: {
"next-rest-framework": "./dist/cli/index.js"
},
dependencies: {
chalk: "4.1.2",
commander: "10.0.1",
formidable: "^3.5.1",
lodash: "4.17.21",
prettier: "3.0.2",
qs: "6.14.1"
},
devDependencies: {
"@types/formidable": "^3.4.5",
"@types/jest": "29.5.4",
"@types/lodash": "4.14.197",
"@types/qs": "6.9.11",
esbuild: "0.19.11",
jest: "29.6.4",
next: "*",
"node-mocks-http": "1.13.0",
"openapi-types": "12.1.3",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
tsup: "8.0.1",
typescript: "*",
zod: "^4.1.13",
"zod-form-data": "3.0.1"
}
};
}
});
// src/constants.ts
var constants_exports = {};
__export(constants_exports, {
DEFAULT_DESCRIPTION: () => DEFAULT_DESCRIPTION,
DEFAULT_ERRORS: () => DEFAULT_ERRORS,
DEFAULT_FAVICON_URL: () => DEFAULT_FAVICON_URL,
DEFAULT_LOGO_URL: () => DEFAULT_LOGO_URL,
DEFAULT_OG_TYPE: () => DEFAULT_OG_TYPE,
DEFAULT_TITLE: () => DEFAULT_TITLE,
ERROR_MESSAGE_SCHEMA: () => ERROR_MESSAGE_SCHEMA,
FORM_DATA_CONTENT_TYPES_THAT_SUPPORT_VALIDATION: () => FORM_DATA_CONTENT_TYPES_THAT_SUPPORT_VALIDATION,
HOMEPAGE: () => HOMEPAGE,
INVALID_MEDIA_TYPE_RESPONSE: () => INVALID_MEDIA_TYPE_RESPONSE,
INVALID_PATH_PARAMETERS_RESPONSE: () => INVALID_PATH_PARAMETERS_RESPONSE,
INVALID_QUERY_PARAMETERS_RESPONSE: () => INVALID_QUERY_PARAMETERS_RESPONSE,
INVALID_REQUEST_BODY_RESPONSE: () => INVALID_REQUEST_BODY_RESPONSE,
INVALID_RPC_REQUEST_RESPONSE: () => INVALID_RPC_REQUEST_RESPONSE,
MESSAGE_WITH_ERRORS_SCHEMA: () => MESSAGE_WITH_ERRORS_SCHEMA,
UNEXPECTED_ERROR_RESPONSE: () => UNEXPECTED_ERROR_RESPONSE,
VERSION: () => VERSION,
ValidMethod: () => ValidMethod
});
module.exports = __toCommonJS(constants_exports);
var DEFAULT_ERRORS = {
unexpectedError: "An unknown error occurred, trying again might help.",
methodNotAllowed: "Method not allowed.",
notFound: "Not found.",
notImplemented: "Not implemented.",
invalidMediaType: "Invalid media type.",
operationNotAllowed: "Operation not allowed.",
invalidRequestBody: "Invalid request body.",
invalidQueryParameters: "Invalid query parameters.",
invalidPathParameters: "Invalid path parameters."
};
var ValidMethod = /* @__PURE__ */ ((ValidMethod2) => {
ValidMethod2["GET"] = "GET";
ValidMethod2["PUT"] = "PUT";
ValidMethod2["POST"] = "POST";
ValidMethod2["DELETE"] = "DELETE";
ValidMethod2["OPTIONS"] = "OPTIONS";
ValidMethod2["HEAD"] = "HEAD";
ValidMethod2["PATCH"] = "PATCH";
return ValidMethod2;
})(ValidMethod || {});
var VERSION = require_package().version;
var HOMEPAGE = require_package().homepage;
var DEFAULT_TITLE = "Next REST Framework";
var DEFAULT_OG_TYPE = "website";
var DEFAULT_DESCRIPTION = "This is an autogenerated documentation by Next REST Framework.";
var DEFAULT_FAVICON_URL = "https://raw.githubusercontent.com/blomqma/next-rest-framework/main/docs/static/img/favicon.ico";
var DEFAULT_LOGO_URL = "https://raw.githubusercontent.com/blomqma/next-rest-framework/d02224b38d07ede85257b22ed50159a947681f99/packages/next-rest-framework/logo.svg";
var FORM_DATA_CONTENT_TYPES_THAT_SUPPORT_VALIDATION = ["multipart/form-data", "application/x-www-form-urlencoded"];
var MESSAGE_WITH_ERRORS_SCHEMA = {
type: "object",
properties: {
message: { type: "string" },
errors: {
type: "array",
items: {
type: "object",
required: ["code", "path", "message"],
properties: {
code: {
type: "string",
description: "Discriminator field for the Zod issue type."
},
path: {
type: "array",
items: {
oneOf: [
{
type: "string"
},
{
type: "number"
}
]
},
description: "Path to the error in the validated object, represented as an array of strings and/or numbers."
},
message: {
type: "string",
description: "Human-readable message describing the validation error."
}
},
additionalProperties: true
}
}
},
required: ["message"],
additionalProperties: false
};
var INVALID_REQUEST_BODY_RESPONSE = {
description: DEFAULT_ERRORS.invalidRequestBody,
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/MessageWithErrors`
}
}
}
};
var ERROR_MESSAGE_SCHEMA = {
type: "object",
properties: {
message: { type: "string" }
},
additionalProperties: false
};
var UNEXPECTED_ERROR_RESPONSE = {
description: DEFAULT_ERRORS.unexpectedError,
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/ErrorMessage`
}
}
}
};
var INVALID_RPC_REQUEST_RESPONSE = {
description: "Error response.",
content: {
"application/json": {
schema: {
oneOf: [
{
description: DEFAULT_ERRORS.invalidRequestBody,
$ref: `#/components/schemas/MessageWithErrors`
},
{
description: DEFAULT_ERRORS.unexpectedError,
$ref: `#/components/schemas/ErrorMessage`
}
]
}
}
}
};
var INVALID_MEDIA_TYPE_RESPONSE = {
description: DEFAULT_ERRORS.invalidMediaType,
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/ErrorMessage`
}
}
},
headers: {
Allow: {
schema: {
type: "string"
}
}
}
};
var INVALID_QUERY_PARAMETERS_RESPONSE = {
description: DEFAULT_ERRORS.invalidQueryParameters,
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/MessageWithErrors`
}
}
}
};
var INVALID_PATH_PARAMETERS_RESPONSE = {
description: DEFAULT_ERRORS.invalidPathParameters,
content: {
"application/json": {
schema: {
$ref: `#/components/schemas/MessageWithErrors`
}
}
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DEFAULT_DESCRIPTION,
DEFAULT_ERRORS,
DEFAULT_FAVICON_URL,
DEFAULT_LOGO_URL,
DEFAULT_OG_TYPE,
DEFAULT_TITLE,
ERROR_MESSAGE_SCHEMA,
FORM_DATA_CONTENT_TYPES_THAT_SUPPORT_VALIDATION,
HOMEPAGE,
INVALID_MEDIA_TYPE_RESPONSE,
INVALID_PATH_PARAMETERS_RESPONSE,
INVALID_QUERY_PARAMETERS_RESPONSE,
INVALID_REQUEST_BODY_RESPONSE,
INVALID_RPC_REQUEST_RESPONSE,
MESSAGE_WITH_ERRORS_SCHEMA,
UNEXPECTED_ERROR_RESPONSE,
VERSION,
ValidMethod
});