1 Star 0 Fork 0

SuperWindCloud/bun_elysia_postgresql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

🦊 Bun + Elysia + Postgres.js Clean Architecture Example

A clean architecture implementation using Bun, Elysia, and Postgres.js for building a robust and scalable API.

🌟 Overview

This project demonstrates a clean architecture approach to building a web API using modern JavaScript technologies. It leverages Bun as the runtime environment, Elysia as the web framework, and Postgres.js for database interactions. The application follows clean architecture principles, ensuring a clear separation of concerns and maintainability.

Key highlights:

  • Extremely fast startup times and test execution
  • Integrated debugging capabilities
  • Comprehensive Swagger documentation with strong typing
  • Scalable architecture achieved through careful structuring and Elysia's plugin system

While Elysia doesn't provide a scalable structure out of the box, this boilerplate shows how to achieve clean architecture with some additional effort, making it an excellent starting point for serious application development.

🏗 Project Structure

The project follows a clean architecture pattern with the following structure:

src/
├── auth/
│   ├── application/
│   ├── domain/
│   └── infrastructure/
├── notes/
│   ├── application/
│   ├── domain/
│   └── infrastructure/
├── shared/
│   └── infrastructure/
└── users/
    ├── domain/
    └── infrastructure/
  • auth/: Authentication-related modules
  • notes/: Note management modules
  • users/: User management modules
  • shared/: Shared utilities and configurations

Each module is divided into:

  • application/: Use cases and business logic
  • domain/: Domain entities and types
  • infrastructure/: External interfaces (controllers, repositories)

🛠 Setup

bun run start

✨ Features

🌐 Elysia Web Framework

The project uses Elysia, a modern and performant web framework for Bun. It provides a clean and intuitive API for building web applications.

🗄️ Postgres.js

Fastest full-featured node & deno client, Postgres.js is used for database operations, offering a simple and efficient way to interact with PostgreSQL databases.

🏛 Clean Architecture

The project follows clean architecture principles, separating concerns into distinct layers: Application, Domain, and Infrastructure.

🧹 ESLint + Prettier

Code quality and consistency are maintained using ESLint and Prettier with a standardized configuration.

📁 Import Sorting

Imports are automatically organized using the eslint-plugin-simple-import-sort plugin.

🔐 Environment Management

Environment variables are managed securely using a combination of .env files and the zod library for validation.

🗃 Database Migration

A simple database migration system is implemented using raw SQL scripts.

📚 Swagger Documentation

API documentation is automatically generated using Swagger, making it easy for developers to understand and interact with the API.

🧪 Testing

The project includes integration (E2E) tests to ensure the correct functionality of the API endpoints. Run the tests using:

bun test

空文件

简介

Bun + Elysia + Postgres.js 架构模版 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/SuperWindcloud/bun_elysia_postgresql.git
git@gitee.com:SuperWindcloud/bun_elysia_postgresql.git
SuperWindcloud
bun_elysia_postgresql
bun_elysia_postgresql
master

搜索帮助