{"id":29219788,"url":"https://github.com/devrizz/bun_rest_api","last_synced_at":"2025-07-03T02:07:31.881Z","repository":{"id":302313088,"uuid":"1011939895","full_name":"DevRizz/bun_rest_api","owner":"DevRizz","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-01T17:45:35.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-01T17:49:18.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/DevRizz.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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-01T15:01:50.000Z","updated_at":"2025-07-01T17:45:38.000Z","dependencies_parsed_at":"2025-07-01T17:59:32.439Z","dependency_job_id":null,"html_url":"https://github.com/DevRizz/bun_rest_api","commit_stats":null,"previous_names":["devrizz/bun_rest_api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DevRizz/bun_rest_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevRizz%2Fbun_rest_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevRizz%2Fbun_rest_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevRizz%2Fbun_rest_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevRizz%2Fbun_rest_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevRizz","download_url":"https://codeload.github.com/DevRizz/bun_rest_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevRizz%2Fbun_rest_api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245316,"owners_count":23436515,"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":[],"created_at":"2025-07-03T02:07:31.307Z","updated_at":"2025-07-03T02:07:31.859Z","avatar_url":"https://github.com/DevRizz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Bun + Elysia.js REST API Starter with a Git Submodule Workflow\n\n![Bun Logo](https://bun.sh/logo.svg)\n\nThis repository is a starter project for building a REST API using the incredibly fast **Bun** runtime and the **Elysia.js** framework.\n\nMore importantly, it serves as a practical example of a clean Git workflow using **Git Submodules** to manage a project within another project. This approach avoids the common \"nested Git repository\" problem.\n\n---\n\n## 🏛️ Project Structure\n\nThis repository uses a submodule to keep the API code separate and independently version-controlled.\n\n```\nbun_init/ (Main Repository)\\\n├── .git/\\\n├── .gitmodules \u003c-- This file tells Git about the submodule\\\n├── bun_rest_api/ \u003c-- This is the Git Submodule (a pointer to another repo)\\\n│ └── (Contents of the bun_rest_api repository)\\\n└── README.md \u003c-- You are here!\n```\n\n*   **`bun_init/`**: The main \"container\" repository. Its only job is to hold the overall project structure and point to the `bun_rest_api` project.\n*   **`bun_rest_api/`**: A completely separate, standalone Git repository that contains the actual Elysia.js API code. It is included here as a submodule.\n\n---\n\n## 🔧 The Git Workflow Journey: From Problem to Solution\n\nWhen I started, I just created a `bun_rest_api` folder inside my main project. This led to a common problem.\n\n### The Problem: The \"Nested Git Repository\" Trap\n\nIf you run `git init` inside a folder that is already tracked by an outer Git repository, you create a nested repo.\n\n**What happens?**\nThe outer repository (`bun_init`) does **not** track the files *inside* `bun_rest_api`. It only tracks the existence of that folder and the specific commit hash of its `HEAD`. When you push the outer repo, the inner repo's code is not included! On GitHub, it will just show as a gray, un-clickable folder.\n\n### The Solution: `git submodule`\n\nA Git submodule is the correct way to include another repository within a project. It acts as a **pointer** to a specific commit in another repo.\n\n**Our Workflow:**\n1.  Create the main repository (`bun_init`) and push it to GitHub.\n2.  Create the API repository (`bun_rest_api`) as a completely separate project and push it to GitHub.\n3.  In the local `bun_init` repository, run the command:\n    ```bash\n    git submodule add https://github.com/DevRizz/bun_rest_api.git\n    ```\n4.  This command does two things:\n    *   Clones the `bun_rest_api` repository into a folder of the same name.\n    *   Creates a `.gitmodules` file to track the submodule's path and URL.\n5.  Commit and push the changes. Now, the main repo is correctly linked to a specific version of the API repo.\n\n---\n\n## 🧠 Key Git Concepts in This Workflow\n\nUnderstanding these concepts is key to maintaining a clean and understandable project history.\n\n### Commit History: Your Project's Story\nThink of your commit history as the story of your project. Each commit is a chapter. A clean, linear history is easy for you and others to read and understand later.\n\n### Merge vs. Rebase: Two Ways to Combine Work\n\nLet's say you have a `main` branch and a `feature` branch.\n\n*   **`git merge` (The Default):**\n    *   This creates a new \"merge commit\" in your `main` branch that ties the two histories together.\n    *   **Pros:** Preserves the exact history of what happened and when. It's non-destructive.\n    *   **Cons:** Can lead to a messy, branching history that's hard to read if used frequently for small features.\n    *   **Diagram:**\n        ```\n              A---B---C (feature)\n             /         \\\n        D---E-----------F---G (main, with merge commit F)\n        ```\n\n*   **`git rebase` (The Cleaner):**\n    *   This takes your `feature` branch commits and **re-plays** them one-by-one on top of the latest `main` branch. It rewrites history to be linear.\n    *   **Pros:** Creates a perfectly straight, easy-to-read commit history. No merge commits cluttering the log.\n    *   **Cons:** It rewrites commit hashes. **The Golden Rule:** Never rebase a branch that has been pushed and is being used by others (like `main`). Use it only on your local, private feature branches.\n    *   **Diagram:**\n        ```\n        Before Rebase:\n              A---B---C (feature)\n             /\n        D---E---F (main)\n\n        After Rebase (`git rebase main` on `feature` branch):\n                      A'--B'--C' (feature)\n                     /\n        D---E---F (main)\n        ```\n\n### Pull Requests (PRs): More Than Just Merging\nA Pull Request is a formal request to merge your branch into another (e.g., `feature` -\u003e `main`). Its purpose is to:\n1.  **Trigger Code Review:** Allow teammates to review your changes, ask questions, and suggest improvements.\n2.  **Run Automated Checks:** Kick off CI/CD pipelines to run tests and linters.\n3.  **Provide a Record:** Document a specific change and the discussion around it.\n\n---\n\n## 🚀 Getting Started\n\nTo clone this repository and its submodule, you need to use a special flag.\n\n1.  **Clone the repository and initialize the submodule at the same time:**\n    ```bash\n    git clone --recurse-submodules https://github.com/DevRizz/bun_init.git\n    ```\n    *If you already cloned it without the flag, run `git submodule update --init --recursive` inside the project.*\n\n2.  **Navigate into the API directory:**\n    ```bash\n    cd bun_init/bun_rest_api\n    ```\n\n3.  **Install dependencies using Bun:**\n    ```bash\n    npm install --save-dev @types/bun\n    ```\n\n4.  **Run the development server:**\n    ```bash\n    bun run src/index.ts or,\n    bun --hot run src/index.ts      # for hot reloading\n    ```\n\n5. **To get started with this template, simply paste this command into your terminal:**\n    ```bash\n    bun create elysia bun_rest_api\n    ```\n\nThe API will now be running at `http://localhost:3000`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrizz%2Fbun_rest_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevrizz%2Fbun_rest_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevrizz%2Fbun_rest_api/lists"}