Skip to content

arnonym/type-safe-from-sql-to-ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

From SQL to UI: The Type-Safe Journey

The Backend

A type-safe SQL query builder for TypeScript. Types are inferred from the database schema, providing full type safety and autocompletion when building queries.

Types are generated using kysely-codegen

Type-safe HTTP framework for building APIs with TypeScript.

OpenApi Spec (only available when running the backend): http://localhost:3000/api-docs

The Frontend

Just an Angular application with API imported from OpenAPI spec (with oazapfts) generated by oRPC.

Running the application

Install dependencies

bun install --cwd ./backend 
bun install --cwd ./frontend 

Starting all the things

Database is started with docker compose:

docker compose -f ./backend/docker-compose.yml up

Backend

bun --cwd ./backend start

Frontend

bun --cwd ./frontend start

Handy commands

Run migration

bun --cwd ./backend migrate

Generate types from database schema

bun --cwd ./backend generate:database-types

Generate client from OpenAPI spec

bun --cwd ./frontend generate:client

About

A brief example of how to be type-safe from the database to the front-end.

Resources

Stars

Watchers

Forks