sveltekit-zero-api
TypeScript icon, indicating that this package has built-in type declarations

0.15.7 • Public • Published

SurrealDB Icon

Seamless type-safety   means   better developer experience.

 

Quick Start

npm i -D sveltekit-zero-api  /  pnpm add -D sveltekit-zero-api

// 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
  • Typed endpoint pipeline
  • 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 and Error Handling

Assigning variables directly Intellisense with API calls


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 for igniting the initial concept and codebase svelte-zero-api. And naturally, a big thanks to the Vite and Svelte family for the worlds best framework!💘



Package Sidebar

Install

npm i sveltekit-zero-api

Weekly Downloads

29

Version

0.15.7

License

MIT

Unpacked Size

118 kB

Total Files

39

Last publish

Collaborators

  • refzlund