https://github.com/mhdzhhan/bun-basket
๐ฏ Zero ORM, SQL experiments with Bun + PostgreSQL
https://github.com/mhdzhhan/bun-basket
bun bun-sql express neon postgresql
Last synced: 11 months ago
JSON representation
๐ฏ Zero ORM, SQL experiments with Bun + PostgreSQL
- Host: GitHub
- URL: https://github.com/mhdzhhan/bun-basket
- Owner: mhdZhHan
- Created: 2025-05-04T18:59:12.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-05-04T19:10:37.000Z (11 months ago)
- Last Synced: 2025-05-07T02:07:02.681Z (11 months ago)
- Topics: bun, bun-sql, express, neon, postgresql
- Language: TypeScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐๏ธ Bun Basket
A lightweight, secure, and scalable REST API for managing products, built with **Express**, **TypeScript**, and **Bun**. It includes a powerful migration script, input validation, and structured logging out of the box.
## ๐ Features
- ๐งฑ Type-safe environment config using Zod
- ๐ Security with Helmet
- ๐งพ Structured logging via Pino
- โ
Request validation with Zod schemas
- โก Ultra-lightweight SQL queries using `bun-sql`
- ๐ฆ Products CRUD API
- ๐งโโ๏ธ Superpowered `migrate.ts` for handling database migrations (with advisory locks!)
## ๐ง Setup
1. **Clone the repo**
```bash
git clone https://github.com/mhdZhHan/bun-basket
cd bun-basket
```
2. **Install dependencies**
```bash
bun install
```
3. **Set up environment variables**
Create a `.env` file based on `env.ts` schema:
```env
DATABASE_URL=
PGHOST=
PGDATABASE=
PGUSER=
PGPASSWORD=
ARCJET_KEY=
ARCJET_ENV=
```
4. **Run migrations**
```bash
bun run migrate.ts up
```
5. **Start the server**
```bash
bun run index.ts
```
## ๐ง Migrations
This project includes a custom migration system:
- `bun run migrate.ts up` โ Apply new migrations
- `bun run migrate.ts down` โ Rollback applied migrations
- Uses **PostgreSQL advisory locks** to prevent race conditions
- Tracks executed migrations in a custom table
Migration files live in:
```bash
server/db/migrations/
```
## โ
Example Request
```bash
curl http://localhost:8080/api/products
```