Getting Started
This tutorial takes you from zero to a small HTTP API backed by SQLite, running on Bun.
Prerequisites
Section titled “Prerequisites”- Bun v1.3+ — install from bun.sh.
- Optional: Node.js v18+ for some native dependencies.
Install
Section titled “Install”-
Create a project and add the kits you need:
Terminal window mkdir my-iskra-api && cd my-iskra-apibun init -ybun add @iskra-bun/core @iskra-bun/web-kit @iskra-bun/db-kit drizzle-orm -
Define a database schema:
src/db/schema.ts import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';export const users = sqliteTable('users', {id: integer('id').primaryKey({ autoIncrement: true }),name: text('name').notNull(),email: text('email').notNull().unique(),}); -
Wire up the app with a web server and the database driver:
src/main.ts import { App } from '@iskra-bun/core';import { WebPlugin, HealthCheckFeature, successResponse } from '@iskra-bun/web-kit';import { DbDriver } from '@iskra-bun/db-kit';import { Hono } from 'hono';import { users } from './db/schema';const db = new DbDriver();const router = new Hono();router.get('/api/users', (c) => {const all = db.db.select().from(users).all();return c.json(successResponse(all));});router.post('/api/users', async (c) => {const body = await c.req.json();db.db.insert(users).values(body).run();return c.json(successResponse(body), 201);});const app = new App({name: 'MyIskraApi',db: { driver: 'sqlite', url: 'app.db' },});app.register(db);app.register(new WebPlugin({ port: 3000, router, features: [new HealthCheckFeature()] }));app.start().catch((err) => app.logger.error({ err }, 'Failed to start'));
bun run src/main.tsThen, in another terminal:
# Create a usercurl -X POST http://localhost:3000/api/users \ -H 'content-type: application/json' \ -d '{"name":"Ada","email":"ada@example.com"}'
# List userscurl http://localhost:3000/api/users
# Health checkcurl http://localhost:3000/healthBun ships with a built-in test runner. Create a smoke test:
import { describe, it, expect } from 'bun:test';import { App } from '@iskra-bun/core';
describe('app', () => { it('starts and stops cleanly', async () => { const app = new App({ name: 'Test' }); await app.start(); await app.stop(); expect(app).toBeDefined(); });});Run it:
bun testNext steps
Section titled “Next steps”- Learn the design model in Architecture.
- Add features (CORS, auth, rate limiting) from the Web Kit.
- Start from a template instead of scaffolding by hand.