0.0.2-h • Published 5 months ago
@boon4681/citron-ts v0.0.2-h
Citron-ts
Turn your @hono/zod-openapi or openapi.json not confirm to typescript fetch types.
import { $Types, Citron } from "./citron"
const k = fetch
export const GetPet = Citron("/api/pet/{id}").get(
(path, fetch = k) => {
return fetch(b`/api/pet/${path.id}`).then(res=>res.json())
}
);
console.log(await GetPet({ id: 1 }))Why?
i used to write code in my style to that why this happended.
Installation
# install with npm
npm install "@boon4681/citron-ts"
# install with yarn
yarn add "@boon4681/citron-ts"Usage
- Setup config in citron.config.ts
import { defineConfig } from "./src";
export default defineConfig({
schema: {
url: 'http://localhost:3000/openapi.json',
cookie: process.env['OPENAPI-COOKIE']
},
out:'./src'
})- Generate the schema from config:
citron pull- Use your types :
import { $Types, Citron } from "./citron"
const k = fetch
export const GetPet = Citron("/api/pet/{id}").get(
(path, fetch = k) => {
return fetch(b`/api/pet/${path.id}`).then(res=>res.json())
}
);
console.log(await GetPet({ id:1 }))Contributing
Ideas and contributions to the project are welcome.