A simple project demonstrating how to build a type-safe API using a fully integrated Bun.js stack: Elysia, Bun's native SQLite driver, Kysely, and Vite.
-
Install Bun: This project is optimized for the Bun runtime. If you don't have it, install it:
curl -fsSL https://bun.sh/install | bash -
Install Dependencies:
bun install
-
Run Migrations: Create the
chordtable in yourchords.dbfile by running the migration script with Bun.bun db:migrate
-
Generate Database Types: Run
kysely-codegento generate TypeScript types from your database schema. This uses thebun-sqlitedialect.bun db:generate-types
This project uses Vite to serve the frontend client and Elysia for the backend API.
-
Start the Development Server: This single command will start both the Elysia backend (with hot-reloading via
--watch) and the Vite dev server for the client.bun dev
-
Open in Browser: Open your browser and navigate to the URL provided by the Vite dev server (usually
http://localhost:5173).
- Click the "Start Audio" button to enable sound.
- Type musical notes into the text area. The music will update as you type.
- Enter a name for your pattern in the "Pattern Name" input field.
- Click "Save Pattern" to save your creation to the database.
- Use the dropdown menu to load a previously saved pattern back into the editor.