{"id":23885577,"url":"https://github.com/ruivalim/bmx-stack","last_synced_at":"2026-04-07T22:31:13.539Z","repository":{"id":265298793,"uuid":"895714727","full_name":"Ruivalim/bmx-stack","owner":"Ruivalim","description":"This modern boilerplate combines Bun, Mongoose, Express, and TypeScript to give you the thrill of speed and control while building web applications. Whether you're racing through REST APIs or performing tricks with static routes, BMX-Stack is here to help you land clean every time.","archived":false,"fork":false,"pushed_at":"2025-01-04T03:52:34.000Z","size":126,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T02:44:47.821Z","etag":null,"topics":["bun","docker","docker-compose","express","mongoose","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ruivalim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-28T18:35:43.000Z","updated_at":"2025-01-04T03:52:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4e14959-e5bf-437f-86ee-90306d3bb1de","html_url":"https://github.com/Ruivalim/bmx-stack","commit_stats":null,"previous_names":["ruivalim/bmx-stack"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruivalim%2Fbmx-stack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruivalim%2Fbmx-stack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruivalim%2Fbmx-stack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruivalim%2Fbmx-stack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ruivalim","download_url":"https://codeload.github.com/Ruivalim/bmx-stack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240261499,"owners_count":19773474,"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":["bun","docker","docker-compose","express","mongoose","typescript"],"created_at":"2025-01-04T05:44:18.191Z","updated_at":"2026-04-07T22:31:13.502Z","avatar_url":"https://github.com/Ruivalim.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **BMX-Stack**\n\nBMX-Stack: It's not just about riding bikes—it's about riding the **web development rails**! 🚴💻\n\nThis modern boilerplate combines **Bun**, **Mongoose**, **Express**, and **TypeScript** to give you the thrill of speed and control while building web applications. Whether you're racing through REST APIs or performing tricks with static routes, BMX-Stack is here to help you land clean every time.\n\n---\n\n## **Features**\n\n- **🛠️ REST Route Generator**: Automate the creation of models, controllers, and routes for REST APIs with built-in validation.\n- **📄 Static Route Generator**: Quickly scaffold HTML pages and serve them with Express.\n- **🖼️ Handlebars Support**: Dynamically render HTML templates using Handlebars for robust server-side rendering.\n- **🚀 Fast Runtime**: Powered by Bun for unparalleled speed and performance.\n- **💾 MongoDB Integration**: Effortless database connectivity and schema management with Mongoose.\n- **📜 TypeScript Support**: Type-safe development for smoother rides.\n- **📦 Docker Support**: Easily containerize your application using the provided Dockerfile and Docker Compose setup.\n- **📈 Production Optimization**: Build highly optimized production-ready Docker images.\n\n---\n\n## **Getting Started**\n\n### Prerequisites\n\n- **[Bun](https://bun.sh/)** installed\n- **MongoDB** instance (local or cloud)\n- **Docker** (super recommended for ease of setup and production builds)\n\n---\n\n### Installation\n\n1. **Create Project with Bun Create**\n\n   ```bash\n   bun create https://github.com/Ruivalim/bmx-stack ./myproj\n   cd ./myproj\n   ```\n\n2. **Set Up Environment Variables**\n\n   Create a `.env` file in the root directory and configure the following:\n\n   ```env\n   PORT=3000\n   MONGO_URI=mongodb://mongo:27017/bmx-stack\n   NODE_ENV=development\n   ```\n\n3. **Run the Project**\n\n   Start the development server:\n\n   ```bash\n   docker compose up --watch\n   ```\n\n   The server will start on `http://localhost:3000`.\n\n---\n\n### Project Structure\n\n```\nbmx-stack/\n├── Dockerfile                # Production-ready Docker configuration\n├── bun.lockb                 # Bun lock file\n├── dev.Dockerfile            # Docker configuration for development\n├── docker-compose.yaml       # Docker Compose setup\n├── public/                   # Static HTML files and assets\n├── scripts/                  # Utility scripts\n│   ├── build.sh              # Production build script\n│   ├── generate.ts           # Route and model generation script\n│   └── generateStaticRoutes.ts # Static route generator script\n├── src/                      # Application source code\n│   ├── app.ts                # Express app setup\n│   ├── config/               # Database configuration\n│   │   └── database.ts\n│   ├── controllers/          # Route controllers\n│   │   └── healthController.ts\n│   ├── middleware/           # Custom middleware\n│   │   └── validationMiddleware.ts\n│   ├── models/               # Mongoose models\n│   ├── routes/               # API and static routes\n│   │   └── healthRoute.ts\n│   ├── routesLoader.ts       # Dynamic route loader\n│   ├── server.ts             # Server entry point\n│   ├── validations/          # Reusable validation functions\n│   │   ├── boolean.ts\n│   │   ├── date.ts\n│   │   ├── email.ts\n│   │   ├── number.ts\n│   │   ├── objectId.ts\n│   │   └── string.ts\n│   └── views/                # Handlebars templates\n│       ├── home.handlebars   # Main page template\n│       ├── layouts/          # Handlebars layouts\n│       │   └── main.handlebars\n│       └── partials/         # Handlebars partials\n│           ├── footer.handlebars\n│           └── header.handlebars\n└── tsconfig.json             # TypeScript configuration\n```\n\n---\n\n## **Usage**\n\n### Generate a Static Route\n\nGenerate a new static route and HTML file:\n\n```bash\nbun run generate\n```\n\n1. Select **Static Route**.\n2. Enter the name of the route.\n3. The script will create:\n   - A static HTML file in `public/`.\n   - A route file in `src/routes/`.\n\n---\n\n### Generate a RESTful Route\n\nGenerate a RESTful route with a model, controller, and validation:\n\n```bash\nbun run generate\n```\n\n1. Select **REST Route**.\n2. Enter the name of the model (in PascalCase).\n3. The script will create:\n   - A Mongoose model in `src/models/`.\n   - A controller with CRUD operations in `src/controllers/`.\n   - A RESTful route with basic validation in `src/routes/`.\n\n---\n\n### Handlebars Support\n\nHandlebars templates are located in the `src/views/` directory, with support for layouts and partials.\n\n#### Example Usage:\nRender a Handlebars template in your route:\n```typescript\nres.render('home', { title: 'Welcome!', message: 'Hello, Handlebars!' });\n```\n\nUse the `main` layout (`layouts/main.handlebars`) and include reusable partials (e.g., `partials/header.handlebars`).\n\n---\n\n## **Production Optimization**\n\nThe `build.sh` script prepares your project for production by:\n- Compiling the application using **Bun**.\n- Minifying JavaScript and CSS assets.\n- Copying the necessary files to a `dist` directory.\n\n### Steps to Build a Production Image\n1. Build the Docker image:\n   ```bash\n   docker build . -t image:tag\n   ```\n\n2. Run the container:\n   ```bash\n   docker run -p 3000:3000 image:tag\n   ```\n\nThe resulting image is optimized for production.\n\n---\n\n## **Contributing**\n\nWe welcome contributions! If you'd like to improve BMX-Stack, please feel free to fork the repository, create a feature branch, and submit a pull request.\n\n---\n\n## **License**\n\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n\n## **Author**\n\nCreated by **[Rui Valim](https://github.com/Ruivalim)**.\nFeel free to reach out with suggestions, feedback, or just to say hi! 🚴💻\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruivalim%2Fbmx-stack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruivalim%2Fbmx-stack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruivalim%2Fbmx-stack/lists"}