No description
Find a file Use this template
2025-01-25 15:08:13 +00:00
drizzle docs, formatting, tests 2025-01-21 12:18:03 +06:00
src docs, formatting, tests 2025-01-21 12:18:03 +06:00
test docs, formatting, tests 2025-01-21 12:18:03 +06:00
.env.example Update .env.example 2025-01-25 15:08:13 +00:00
.env.services.example modified example 2025-01-25 13:06:32 +06:00
.gitignore modified example 2025-01-25 13:06:32 +06:00
bun.lockb added prettier formatting 2025-01-20 22:37:03 +06:00
docker-compose.services.yaml docs, formatting, tests 2025-01-21 12:18:03 +06:00
docker-compose.yaml added prettier formatting 2025-01-20 22:37:03 +06:00
Dockerfile added more 2025-01-15 15:00:54 +06:00
drizzle.config.ts Notes route 2025-01-16 12:37:06 +06:00
package.json spelling mistake 2025-01-21 12:44:35 +06:00
README.md modified example 2025-01-25 13:06:32 +06:00
tsconfig.json added prettier formatting 2025-01-20 22:37:03 +06:00

Microservice Start

A microservice starter template built with Bun, Elysia, PostgreSQL, and MinIO.

Prerequisites

  • Bun installed
  • Docker and Docker Compose
  • Node.js (for development tools)

Tech Stack

  • Runtime: Bun
  • Framework: Elysia
  • Database: PostgreSQL
  • Object Storage: MinIO
  • Authentication: better-auth
  • Email Templates: React Email
  • Database Tools: Drizzle ORM

Project Setup

  1. Clone the repository:
git clone ssh://git@git.planpostai.com:2222/planpostai/template-elysia.git microservice-start
cd microservice-start
  1. Set up environment files:
# Copy environment examples
cp .env.example .env
cp .env.services.example .env.services
  1. Configure the environment variables:

.env

PORT=3000
SERVICE_NAME=microservice_start
# DATABASE_URL FORMAT: "postgresql://<username>:<password>@<host>:<port>/<db_name>"
DATABASE_URL="postgresql://postgres:hellodev@localhost:5432/postgres"
MINIO_ACCESS_KEY=
MINIO_SECRET_KEY=
MINIO_ENDPOINT_URL=127.0.0.1
MINIO_PORT=9000
MINIO_BUCKET_NAME=projectname
BETTER_AUTH_SECRET=a_must_change_randm_word

# DO NOT CHANGE
BETTER_AUTH_URL=http://127.0.0.1:${PORT}

.env.services

DB_USER=postgres
DB_PASSWORD=hellodev
DB_PORT=5432

MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=miniopassword

Running the Project

  1. Start the required services (PostgreSQL, MinIO):
bun run services:up
  1. Configure MinIO:

    • Access MinIO console at http://localhost:9000
    • Log in using the credentials set in .env.services
    • Create an access key and secret key
    • Update the .env file with the generated MinIO credentials:
      • MINIO_ACCESS_KEY
      • MINIO_SECRET_KEY
  2. Install dependencies and start the development server:

bun install
bun dev

Development Tools

Database Management

  • Open Database Studio:
bun run db:studio
  • Check database schema:
bun run db:check
  • Generate database migrations:
bun run db:generate
  • Run migrations:
bun run db:migrate
  • Pull database schema:
bun run db:pull
  • Push database changes:
bun run db:push

Other Commands

  • Run tests:
bun test
  • Format code:
bun run format
  • Generate auth configuration:
bun run auth:generate
  • Development email server:
bun run email
  • Build for production:
bun run build

Service Management

  • Start services:
bun run services:up
  • Stop services:
bun run services:down

Contributing

[Add your contribution guidelines here]

License

[Add your license information here]