🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

next-rest-framework

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.2.2

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

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

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

const todoSchema = object({
const todoSchema = z.object({
id: z.string(),

@@ -139,3 +139,3 @@ name: z.string(),

GET: {
responses: [
output: [
{

@@ -148,4 +148,6 @@ status: 200,

handler: ({ res }) => {
// Using any other content type, status code or response data format will lead to TS error.
// Any other content type will lead to TS error.
res.setHeader('content-type', 'application/json');
// Any other status or JSON format will lead to TS error.
res.status(200).json([

@@ -161,3 +163,3 @@ {

POST: {
request: {
input: {
contentType: 'application/json',

@@ -168,3 +170,3 @@ schema: z.object({

},
responses: [
output: [
{

@@ -184,6 +186,10 @@ status: 201,

}) => {
const todo = createYourTodo(name);
// Any other content type will lead to TS error.
res.setHeader('content-type', 'application/json');
// Any other status or JSON format will lead to TS error.
res.status(201).json({
data: todo
id: 'foo',
name,
completed: false
});

@@ -214,3 +220,3 @@ }

In addition to your method handlers, `middleware` and `errorHandler`, you can also configure OpenAPI [Path Item Object](https://swagger.io/specification/#path-item-object) parameters for your API route and they will automatically become part of your auto-generated OpenAPI spec The following options can be passed as a parameter for your `defineCatchAllHandler` and `defineEndpoints` in an object:
The route config parameters define an individual route, applicable for all endpoints (methods) that are using that route:

@@ -226,2 +232,4 @@ | Name | Description | Required |

The method handler parameters define an individual endpoint:
| Name | Description | Required |

@@ -228,0 +236,0 @@ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |