0.0.2-h • Published 5 months ago

@boon4681/citron-ts v0.0.2-h

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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

  1. 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'
})
  1. Generate the schema from config:
citron pull
  1. 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.

0.0.2-h

5 months ago

0.0.2-g

7 months ago

0.0.2-f

7 months ago

0.0.2-e

7 months ago

0.0.2-d

7 months ago

0.0.2-c

7 months ago

0.0.2-b

7 months ago

0.0.2-a

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago