{"id":26289952,"url":"https://github.com/aashari/boilerplate-rest-api-bun","last_synced_at":"2025-03-14T23:17:27.984Z","repository":{"id":215389047,"uuid":"738811596","full_name":"aashari/boilerplate-rest-api-bun","owner":"aashari","description":"This repository contains a boilerplate for building a REST API using the Bun runtime, an alternative to Node.js designed to be faster and more efficient. The project is structured using Elysia, a minimalist web framework for Bun, and mongoose for MongoDB object modeling.","archived":false,"fork":false,"pushed_at":"2025-03-01T03:27:16.000Z","size":21,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-01T04:20:49.623Z","etag":null,"topics":["api","boilerplate","bun","docker","elysia","elysiajs","mongodb","mongoose","rest-api","typescript"],"latest_commit_sha":null,"homepage":"https://aashari.github.io/boilerplate-rest-api-bun","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aashari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-04T05:20:05.000Z","updated_at":"2025-03-01T03:29:27.000Z","dependencies_parsed_at":"2024-01-05T17:29:14.788Z","dependency_job_id":"3ef36e8b-566f-4031-9768-ddfaa85e2de4","html_url":"https://github.com/aashari/boilerplate-rest-api-bun","commit_stats":null,"previous_names":["aashari/boilerplate-rest-api-bun"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashari%2Fboilerplate-rest-api-bun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashari%2Fboilerplate-rest-api-bun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashari%2Fboilerplate-rest-api-bun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashari%2Fboilerplate-rest-api-bun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aashari","download_url":"https://codeload.github.com/aashari/boilerplate-rest-api-bun/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658257,"owners_count":20326467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","boilerplate","bun","docker","elysia","elysiajs","mongodb","mongoose","rest-api","typescript"],"created_at":"2025-03-14T23:17:27.405Z","updated_at":"2025-03-14T23:17:27.977Z","avatar_url":"https://github.com/aashari.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boilerplate REST API using Bun\n\nThis repository contains a beginner-friendly boilerplate for building a REST API using the [Bun](https://bun.sh/) runtime, \nan alternative to Node.js designed to be faster and more efficient. The project is structured using `Elysia`, \na minimalist web framework for Bun, and `mongoose` for MongoDB object modeling.\n\n## Features\n\n- **Bun Runtime**: Ultra-fast JavaScript runtime as an alternative to Node.js\n- **Elysia Framework**: Lightweight and fast web framework for handling HTTP requests\n- **MongoDB Integration**: Complete setup with Mongoose models for authors and posts\n- **Docker Support**: Ready-to-use Docker Compose setup for MongoDB and Mongo Express\n- **TypeScript**: Full TypeScript support for better developer experience\n- **Error Handling**: Built-in middleware for error handling and response standardization\n- **Environment Variables**: Configured to use environment variables for easy configuration\n- **Helper Scripts**: Includes a convenient script for managing the API and MongoDB\n- **Detailed Guide**: Comprehensive guide for running and testing the API\n\n## Prerequisites\n\n- [Bun](https://bun.sh/) installed on your system\n- [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) (optional, for running MongoDB)\n\n## Quick Start\n\n### Step 1: Clone the repository\n\n```sh\ngit clone https://github.com/aashari/boilerplate-rest-api-bun.git\ncd boilerplate-rest-api-bun\n```\n\n### Step 2: Set up environment variables\n\n```sh\n# Copy the example environment file\ncp .env.example .env\n```\n\n### Step 3: Start MongoDB using Docker Compose\n\n```sh\n# Start MongoDB and Mongo Express\n./api.sh mongo-up\n\n# You can access Mongo Express at http://localhost:8081\n```\n\n### Step 4: Install dependencies\n\n```sh\nbun install\n```\n\n### Step 5: Start the development server\n\n```sh\n# Start the API in the background\n./api.sh start\n\n# Check the logs\n./api.sh logs\n```\n\nThe server will start at http://localhost:3000 by default.\n\n## Using the Helper Script\n\nThis project includes a helper script (`api.sh`) to make it easier to manage the API and MongoDB:\n\n```sh\n# Show available commands\n./api.sh help\n\n# Start the API\n./api.sh start\n\n# Check if the API is running\n./api.sh status\n\n# View API logs\n./api.sh logs\n\n# Stop the API\n./api.sh stop\n\n# Start MongoDB containers\n./api.sh mongo-up\n\n# Stop MongoDB containers\n./api.sh mongo-down\n```\n\n## Detailed Guide\n\nFor a comprehensive guide on running and testing the API, see the [GUIDE.md](GUIDE.md) file.\n\n## API Endpoints\n\n### Posts\n\n- `GET /posts` - Get all posts\n- `POST /posts` - Create a new post\n- `GET /posts/:id` - Get a post by ID\n- `PUT /posts/:id` - Update a post by ID\n- `DELETE /posts/:id` - Delete a post by ID\n\n### Authors\n\n- `GET /authors` - Get all authors\n- `POST /authors` - Create a new author\n- `GET /authors/:id` - Get an author by ID\n- `PUT /authors/:id` - Update an author by ID\n- `DELETE /authors/:id` - Delete an author by ID\n\n### Root\n\n- `GET /` - Returns a simple \"hello world\" message\n\n## Project Structure\n\n```\n.\n├── src/\n│   ├── _mongo/              # MongoDB connection and models\n│   │   ├── index.ts         # MongoDB connection setup\n│   │   ├── model.author.ts  # Author model\n│   │   └── model.post.ts    # Post model\n│   ├── authors/             # Author-related components\n│   │   ├── dto.ts           # Author Data Transfer Object\n│   │   ├── index.ts         # Author routes\n│   │   └── service.ts       # Author service functions\n│   ├── posts/               # Post-related components\n│   │   ├── dto.ts           # Post Data Transfer Object\n│   │   ├── index.ts         # Post routes\n│   │   └── service.ts       # Post service functions\n│   ├── index.ts             # Main application entry point\n│   └── type.ts              # Common types and interfaces\n├── .env.example             # Example environment variables\n├── api.sh                   # Helper script for managing the API\n├── docker-compose.yml       # Docker Compose configuration\n├── GUIDE.md                 # Comprehensive guide for running and testing\n├── package.json             # Project dependencies\n└── tsconfig.json            # TypeScript configuration\n```\n\n## Development\n\n### Running in Development Mode\n\n```sh\nbun run dev\n```\n\nThis will start the server with hot reloading enabled.\n\n### Environment Variables\n\nThe following environment variables can be configured in the `.env` file:\n\n- `PORT`: The port on which the server will run (default: 3000)\n- `SERVER_NAME`: The name of the server (default: boilerplate-rest-api-bun)\n- `MONGODB_URI`: The MongoDB connection URI (default: mongodb://localhost:27017)\n- `MONGODB_DATABASE`: The MongoDB database name (default: boilerplate_db)\n- `NODE_ENV`: The environment mode (development, production, etc.)\n\n## MongoDB Management\n\nThis project includes [Mongo Express](https://github.com/mongo-express/mongo-express), a web-based MongoDB admin interface. When you start the Docker Compose setup, you can access Mongo Express at http://localhost:8081.\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faashari%2Fboilerplate-rest-api-bun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faashari%2Fboilerplate-rest-api-bun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faashari%2Fboilerplate-rest-api-bun/lists"}