@vermilio/koneko
v0.3.0
Published
koneko provides a file-based routing strategy for fastify.
Readme
koneko
koneko provides a file-based routing strategy for fastify.
npm i @vermilio/koneko
npm i fastify fastify-type-provider-zod zodConfiguration
Create a file with the name koneko.config.ts in the root directory of your project.
import { config } from '@vermilio/koneko'
export default config({
// define your configuration
})Routes
All route files should be placed in the folder /api or /src/api.
Files that start with an underscore (e.g. _example.ts) or end in .d.ts are automatically ignored.
./api/foo/index.ts->/foo./api/foo/[bar].ts->/foo/:bar./api/foo/bar.ts->/foo/bar
A route file is as simple as the following:
import { Route } from '@vermilio/koneko'
import { z } from 'zod'
export const Get = new Route({
schema: {
body: z.object({
data: z.unknown()
})
}
}, async (req, res) => {
// do something
})Available methods:
DeleteGetPatchPostPut
Building
The only thing you need to do is run koneko in the root directory of your project and koneko will do the rest.
