New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fets

Package Overview
Dependencies
Maintainers
1
Versions
707
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fets - npm Package Compare versions

Comparing version 0.0.5-alpha-20230306141834-0d7569e to 0.0.5-alpha-20230306142212-208208e

2

package.json
{
"name": "fets",
"version": "0.0.5-alpha-20230306141834-0d7569e",
"version": "0.0.5-alpha-20230306142212-208208e",
"description": "TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -38,3 +38,3 @@ # FETS

FETS also doesn't need a code generation like tRPC, but FETS also allows you to export an OpenAPI
FETS also doesn't need a code generation like tRPC doesn't, but FETS also allows you to export an OpenAPI
document based on the JSON Schema definitions if you don't want to share TypeScript definitions

@@ -115,4 +115,4 @@ between the client and the server. tRPC uses a programmatic solution like `zod` but FETS uses a more

}
} as const // schemas should always be const
},
}
} as const /* schemas should always be const */,
handler: ({ params }) => {

@@ -150,3 +150,3 @@ const user = users.find(user => user.id === params.id);

const client = createClient<router>({
const client = createClient<typeof router>({
endpoint: 'https://example.com',

@@ -198,3 +198,4 @@ });

handler: request => {
// It doesn't reach here if the request doesn't have an `Authorization` header.
// It doesn't reach here if the request doesn't have an `Authorization` header.
}
});

@@ -387,10 +388,10 @@ ```

}
} as const,
handler: async request => {
// This part is fully typed
const { title, completed } = await request.json()
// ...
return Response.json({ message: 'ok' })
}
},
async request => {
// This part is fully typed
const { title, completed } = await request.json()
// ...
return Response.json({ message: 'ok' })
}
)

@@ -420,12 +421,12 @@ ```

}
} as const,
handler: async request => {
// This part is fully typed
const apiKey = request.headers.get('x-api-key')
// Would fail on TypeScript compilation
const wrongHeaderName = request.headers.get('x-api-key-wrong')
// ...
return Response.json({ message: 'ok' })
}
},
async request => {
// This part is fully typed
const apiKey = request.headers.get('x-api-key')
// Would fail on TypeScript compilation
const wrongHeaderName = request.headers.get('x-api-key-wrong')
// ...
return Response.json({ message: 'ok' })
}
)

@@ -455,10 +456,10 @@ ```

}
} as const,
handler: async request => {
// This part is fully typed
const { id } = request.params
// ...
return Response.json({ message: 'ok' })
}
},
async request => {
// This part is fully typed
const { id } = request.params
// ...
return Response.json({ message: 'ok' })
}
)

@@ -488,10 +489,11 @@ ```

}
} as const,
handler: async request => {
// This part is fully typed
const { limit, offset } = request.query
// You can also use `URLSearchParams` API
const limit = request.parsedURL.searchParams.get('limit')
// ...
return Response.json({ message: 'ok' })
}
}, async request => {
// This part is fully typed
const { limit, offset } = request.query
// You can also use `URLSearchParams` API
const limit = request.parsedURL.searchParams.get('limit')
// ...
return Response.json({ message: 'ok' })
})

@@ -547,21 +549,21 @@ ```

}
} as const,
handler: async request => {
const apiKey = request.headers.get('x-api-key')
if (!apiKey) {
return Response.json(
{ message: 'API key is required' },
{
status: 401
}
)
}
const todos = await getTodos({
apiKey
})
// This part is fully typed
return Response.json(todos, {
status: 200
})
}
},
async request => {
const apiKey = request.headers.get('x-api-key')
if (!apiKey) {
return Response.json(
{ message: 'API key is required' },
{
status: 401
}
)
}
const todos = await getTodos({
apiKey
})
// This part is fully typed
return Response.json(todos, {
status: 200
})
}

@@ -590,5 +592,6 @@ )

const router = createRouter({
title: 'Todo List Example',
description: 'A simple todo list example with fets',
version: '1.0.0'
// Details for the generated OpenAPI document
title: 'Todo List Example',
description: 'A simple todo list example with fets',
version: '1.0.0'
// You can access the Swagger UI at `/docs`

@@ -620,3 +623,3 @@ swaggerUIPath: '/docs',

}
}
} as const
})

@@ -656,6 +659,6 @@ ```

You need to save the OpenAPI document to a code file like below;
You need to save the OpenAPI document to a code file like below and export OAS with `as const`;
```ts
export default { openapi: '3.0.1' /* ... */ }
export default { openapi: '3.0.1' /* ... */ } as const
```

@@ -721,3 +724,3 @@

const client = createClient({
const client = createClient<typeof router>({
fetchFn: router.fetch,

@@ -724,0 +727,0 @@ endpoint: 'http://localhost:3000'

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc