@forinda/kickjs
v10.14.1
Published
Modern type-safe backend framework, powered by Vite. Built for developer experience, pluggable as you need — runs on Express, Fastify or h3.
Maintainers
Readme
@forinda/kickjs
Modern type-safe backend framework, powered by Vite. Built for developer experience, and pluggable as you need: DI, modules, a typed request context, validation and generators, on Express (default), Fastify or h3, and on Workers, Bun and Deno through a web-standard entry.
Install
npx @forinda/kickjs-cli new my-api && cd my-api && pnpm devOr add it to an existing project:
pnpm add @forinda/kickjs express reflect-metadata zod
pnpm add -D @forinda/kickjs-cli @forinda/kickjs-viteQuick example
// src/modules/users/user.controller.ts
import { Autowired, Controller, Get, Post, Service, type Ctx } from '@forinda/kickjs'
import { z } from 'zod'
@Service()
export class UserService {
list() {
return [{ id: '1', name: 'Alice' }]
}
}
@Controller()
export class UserController {
@Autowired() private readonly users!: UserService
@Get('/')
list() {
return this.users.list()
}
@Post('/', { body: z.object({ name: z.string().min(1) }) })
create(ctx: Ctx<KickRoutes.UserController['create']>) {
ctx.created({ id: '2', name: ctx.body.name })
}
}// src/index.ts
import 'reflect-metadata'
import { bootstrap, defineModule, defineModules } from '@forinda/kickjs'
import { UserController } from './modules/users/user.controller'
const UserModule = defineModule({
name: 'UserModule',
build: () => ({ routes: () => ({ path: '/users', controller: UserController }) }),
})
export const app = await bootstrap({ modules: defineModules().mount(UserModule()) })GET /api/v1/users returns the list. KickRoutes comes from kick typegen, which kick dev runs for you. To use another engine, pass runtime: fastifyRuntime() (from @forinda/kickjs/fastify) or h3Runtime() to bootstrap().
Documentation
kickjs.app. Good places to start:
- Getting Started
- Modules, Controllers, Dependency Injection
- HTTP Runtimes, Edge Deployment
- Context Decorators, Adapters, Plugins
- BYO Recipes: auth, GraphQL, OpenTelemetry, cron, mailer, multi-tenancy
License
MIT
