You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

next-rest-framework

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-rest-framework - npm Package Compare versions

Comparing version

to
0.6.0

6

dist/types/config.d.ts

@@ -13,2 +13,8 @@ import { OpenAPIV3_1 } from 'openapi-types';

swaggerUiPath?: string;
swaggerUiConfig?: {
title?: string;
description?: string;
faviconHref?: string;
logoHref?: string;
};
exposeOpenApiSpec?: boolean;

@@ -15,0 +21,0 @@ middleware?: Middleware<GlobalMiddlewareResponse>;

@@ -19,2 +19,8 @@ "use strict";

swaggerUiPath: '/api',
swaggerUiConfig: {
title: 'Next REST Framework | SwaggerUI',
description: 'Next REST Framework SwaggerUI',
faviconHref: 'https://raw.githubusercontent.com/blomqma/next-rest-framework/main/docs/static/img/favicon.ico',
logoHref: 'https://raw.githubusercontent.com/blomqma/next-rest-framework/d02224b38d07ede85257b22ed50159a947681f99/packages/next-rest-framework/logo.svg'
},
exposeOpenApiSpec: true,

@@ -21,0 +27,0 @@ errorHandler: logging_1.logNextRestFrameworkError,

2

dist/utils/open-api.d.ts

@@ -6,3 +6,3 @@ import http from 'http';

import { ValidMethod } from '../constants';
export declare const getHTMLForSwaggerUI: ({ headers, config: { openApiJsonPath, openApiYamlPath, swaggerUiPath } }: {
export declare const getHTMLForSwaggerUI: ({ headers, config: { openApiJsonPath, openApiYamlPath, swaggerUiPath, swaggerUiConfig: { title, description, faviconHref, logoHref } } }: {
headers: http.IncomingHttpHeaders;

@@ -9,0 +9,0 @@ config: NextRestFrameworkConfig;

@@ -12,6 +12,6 @@ "use strict";

const fs_1 = require("fs");
const getHTMLForSwaggerUI = ({ headers, config: { openApiJsonPath, openApiYamlPath, swaggerUiPath } }) => {
const getHTMLForSwaggerUI = ({ headers, config: { openApiJsonPath, openApiYamlPath, swaggerUiPath, swaggerUiConfig: { title, description, faviconHref, logoHref } = {} } }) => {
const proto = headers['x-forwarded-proto'] ?? 'http';
const host = headers.host;
const url = `${proto}://${host}/api/openapi.yaml`;
const url = `${proto}://${host}/${openApiYamlPath}`;
return `<!DOCTYPE html>

@@ -22,7 +22,8 @@ <html lang="en" data-theme="light">

<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>${title}</title>
<meta
name="description"
content="SwaggerUI"
content="${description}"
/>
<title>Next REST Framework | SwaggerUI</title>
<link rel="icon" type="image/x-icon" href="${faviconHref}">
<link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.5.0/swagger-ui.css" />

@@ -42,4 +43,4 @@ <link

<img
src="https://raw.githubusercontent.com/blomqma/next-rest-framework/d02224b38d07ede85257b22ed50159a947681f99/packages/next-rest-framework/logo.svg"
alt="Next REST Framework logo"
src="${logoHref}"
alt="Logo"
class="w-32"

@@ -46,0 +47,0 @@ />

{
"name": "next-rest-framework",
"version": "0.5.1",
"version": "0.6.0",
"description": "Next REST Framework - write type-safe, self-documenting REST APIs in Next.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -52,2 +52,3 @@ <p align="center">

- [Method error handler](#method-error-handler)
- [SwaggerUI config](#swaggerui-config)
- [Changelog](#changelog)

@@ -61,2 +62,5 @@ - [Contributing](#contributing)

- [Live demo](https://next-rest-framework-demo.vercel.app/api)
- [Docs](https://next-rest-framework.vercel.app)
This is a monorepo containing the following packages / projects:

@@ -171,3 +175,3 @@

query: z.object({
page: z.number()
page: z.string()
})

@@ -218,2 +222,3 @@ },

| `swaggerUiPath` | Custom path for service Swagger UI. Defaults to `/api`. |
| `swaggerUiConfig` | A [SwaggerUI config](#swagger-ui-config) object for customizing the generated SwaggerUI. |
| `exposeOpenApiSpec` | Setting this to `false` will serve none of the OpenAPI documents neither the Swagger UI. Defaults to `true`. |

@@ -253,7 +258,7 @@ | `middleware` | A global middleware for all of your API routes. See [Global middleware](#global-middleware) for more information. |

| Name | Description | Required |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `contentType` | The content type that the request must have - request with no content type or incorrect content type will get an error response. | `true` |
| `body` | A [Zod](https://github.com/colinhacks/zod) or [Yup](https://github.com/jquense/yup) schema describing the format of the request body. | `true` |
| `query` | A [Zod](https://github.com/colinhacks/zod) or [Yup](https://github.com/jquense/yup) schema describing the format of the query parameters. | `false` |
| Name | Description | Required |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `contentType` | The content type that the request must have - request with no content type or incorrect content type will get an error response. | `true` |
| `body` | A [Zod](https://github.com/colinhacks/zod) or [Yup](https://github.com/jquense/yup) schema describing the format of the request body. | `true` |
| `query` | A [Zod](https://github.com/colinhacks/zod) or [Yup](https://github.com/jquense/yup) schema describing the format of the query parameters. Note that Next.js parses the query string into an object containing either strings or arrays of strings. | `false` |

@@ -368,2 +373,13 @@ #### [Output object](#output-object)

## [SwaggerUI config](#swagger-ui-config)
The SwaggerUI config object can be used to customize the generated Swagger UI:
| Name | Description |
| ------------- | --------------------------------------- |
| `title` | Custom page title meta tag value. |
| `description` | Custom page description meta tag value. |
| `logoHref` | An href for a custom logo. |
| `faviconHref` | An href for a custom favicon. |
## [Changelog](#changelog)

@@ -370,0 +386,0 @@

Sorry, the diff of this file is not supported yet