Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/refzlund/sveltekit-zero-api
Provides type-safety between front- and backend, and contains utility functions for handling errors and searchparameters
https://github.com/refzlund/sveltekit-zero-api
Last synced: about 8 hours ago
JSON representation
Provides type-safety between front- and backend, and contains utility functions for handling errors and searchparameters
- Host: GitHub
- URL: https://github.com/refzlund/sveltekit-zero-api
- Owner: Refzlund
- License: mit
- Created: 2021-10-16T10:23:47.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-12-12T17:24:02.000Z (28 days ago)
- Last Synced: 2025-01-02T05:09:01.716Z (7 days ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sveltekit-zero-api
- Size: 2.63 MB
- Stars: 41
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Seamless type-safety means better developer experience.
## Quick Start
npm i -D sveltekit-zero-api
/
pnpm add -D sveltekit-zero-api
```ts
// vite.config.ts
import { zeroAPI } from 'sveltekit-zero-api'const config: UserConfig = {
plugins: [
sveltekit(),
zeroAPI()
]
}// .gitignore
**/sveltekit-zero-api.d.ts
```
What is SvelteKit Zero API?
Zero API attempts to sow the gap between the frontend and backend. This includes typing backend response codes and their content and dealing with them effectively using callback functions. This may also include error handling.- Body and query is typed seemlessly in both frontend, and endpoints
- Queries are easier to use with querySpread which supports objects as query parameters
- Endpoint routes are automatically typed
- [Generic endpoints](https://github.com/Refzlund/sveltekit-zero-api/wiki/1.-Backend#generic-endpoints)
- [Typed endpoint pipeline](https://github.com/Refzlund/sveltekit-zero-api/wiki/3.-Endpoint-Pipe-function)
- The returned content of endpoints are typed
- Supports slugged routes
- Can be used in the page `Load` function
- You can type-define variables with endpoint responses
- Has handy backend utility functions; [querySpread](https://github.com/Refzlund/sveltekit-zero-api/wiki/1.-Backend#queryspread) and [Error Handling](https://github.com/Refzlund/sveltekit-zero-api/wiki/1.-Backend#error-handling)![Assigning variables directly](https://github.com/Refzlund/sveltekit-zero-api/blob/master/assign-var.gif)
![Intellisense with API calls](https://github.com/Refzlund/sveltekit-zero-api/blob/master/frontend-intellisense.gif)---
Installation, usage and utility types can all be fond on the GitHub Wiki
Getting Started
Backend - Setting up endpoints
Frontend - Using the API
## Acknowledgments
Thank you [ymzuiku](https://github.com/ymzuiku) for igniting the initial concept and codebase [svelte-zero-api](https://github.com/ymzuiku/svelte-zero-api). And naturally, a big thanks to the Vite and Svelte family for the worlds best framework!💘