Skip to Content

Introduction

What Suku is and how its pieces fit together.

Suku is a lightweight TypeScript backend framework built from four ideas: routes, features, middlewares and services. Routes are typed by their schemas, and services come from a dependency injection container modelled on .NET's.

main.ts
import { Routes, Suku, feature, route, singleton } from '@sukujs/core';
import { nodeAdapter } from '@sukujs/platform-node';
import { z } from 'zod';

class UsersService {
  find(id: number) {
    return { id, name: 'Ada' };
  }
}

@Routes('/users')
class UsersRoutes {
  constructor(private readonly users: UsersService) {}

  findOne = route.get('/:id', {
    params: z.object({ id: z.coerce.number() }),
    handle: ({ params }) => this.users.find(params.id),   // params.id is a number
  });
}

const UsersFeature = feature('users', {
  routes: [UsersRoutes],
  services: [singleton(UsersService)],
});

const app = await Suku.create({ features: [UsersFeature], adapter: nodeAdapter() });
await app.listen(3000);

The four ideas

Packages

PackagePurpose
@sukujs/coreRoutes, features, middlewares, validation, config, logger.
@sukujs/diThe container. Usable on its own, without HTTP.
@sukujs/cryptoJWT, passwords, signed and encrypted values. Works on its own.
@sukujs/securityCORS, security headers, CSRF protection, rate limiting.
@sukujs/graphqlClass-based GraphQL resolvers. Optional.
@sukujs/platform-nodeAdapter for node:http.
@sukujs/platform-bunAdapter for Bun.serve.

None of them has a runtime dependency. @sukujs/core re-exports the container's decorators and registration helpers, so application code usually imports from one place.

Status

Suku 0.1.0

All packages are on npm under @sukujs. Install with bun add @sukujs/core (and the platform adapter you need). The API is still early: lifecycle hooks, OpenAPI output and a typed client are planned and not documented here.

On this page