{"id":25046408,"url":"https://github.com/dung204/bunest","last_synced_at":"2025-08-03T10:07:12.255Z","repository":{"id":267219793,"uuid":"891908075","full_name":"dung204/bunest","owner":"dung204","description":"A NestJS starter template using Bun, for Bun runtime","archived":false,"fork":false,"pushed_at":"2024-12-11T03:20:25.000Z","size":62,"stargazers_count":40,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T17:52:06.121Z","etag":null,"topics":["bun","nestjs"],"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/dung204.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,"zenodo":null}},"created_at":"2024-11-21T07:06:31.000Z","updated_at":"2025-04-17T21:41:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"f058fe6e-3797-465d-b117-a89e662d7caa","html_url":"https://github.com/dung204/bunest","commit_stats":null,"previous_names":["dung204/bunest"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/dung204/bunest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dung204%2Fbunest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dung204%2Fbunest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dung204%2Fbunest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dung204%2Fbunest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dung204","download_url":"https://codeload.github.com/dung204/bunest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dung204%2Fbunest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262834787,"owners_count":23371849,"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","nestjs"],"created_at":"2025-02-06T06:40:38.390Z","updated_at":"2025-06-30T19:04:29.966Z","avatar_url":"https://github.com/dung204.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/bunest-icon.svg\" width=\"500\" alt=\"Nest Logo\" /\u003e\n\u003c/p\u003e\n\n  \u003cp align=\"center\"\u003eA \u003ca href=\"https://bun.sh/\"\u003eBun\u003c/a\u003e integration for \u003ca href=\"https://nestjs.com/\"\u003eNest\u003c/a\u003e, made with Bun, for Bun runtime\u003c/p\u003e\n\n## Table of contents\n\n- [Description](#description)\n- [Project setup](#project-setup)\n- [~~Compile \u0026~~ run the project](#compile--run-the-project)\n- [Build the project](#build-the-project)\n- [Run tests](#run-tests)\n- [Libraries Guides](#libraries-guides)\n  - [1. TypeORM](#1-typeorm)\n  - [2. Serving static files (`@nestjs/serve-static`)](#2-serving-static-files-nestjsserve-static)\n- [Support](#support)\n- [Stay in touch](#stay-in-touch)\n- [License](#license)\n\n## Description\n\nThe starter template for \u003ca href=\"https://bun.sh/\"\u003eNest\u003c/a\u003e with Bun runtime. This template utilizes the perks of Bun runtime \u0026 API to provide a seamless \u0026 performant development experience without taking away the familiarity of Nest \u0026 Node.js.\n\n\u003e ⚠️ **Warning**:\n\u003e\n\u003e - This template is still in development and may not be suitable for production use. Please report any issues you encounter.\n\u003e - **Do NOT** use [Nest CLI](https://www.npmjs.com/package/@nestjs/cli) with this template. A Nest-like, dedicated CLI tool for this template is currently in development.\n\n## Project setup\n\n```bash\n$ bun install\n```\n\n## ~~Compile \u0026~~ run the project\n\nBun can run TypeScript code directly, so there is no need to transpile the project before running it. At the same time, however, Bun **will NOT** perform any type-checking during development. Hence, [`tsc-watch`](https://www.npmjs.com/package/tsc-watch) \u0026 `tsc` is added to start scripts by default. Feel free to remove it if you want.\n\n```bash\n# development\n$ bun run start\n\n# watch mode\n$ bun run start:dev\n\n# production mode\n$ bun run start:prod\n```\n\n## Build the project\n\nThis template leverages a custom build script, located in [`scripts/build.ts`](./scripts/build.ts), using [Bun Build API](https://bun.sh/docs/bundler) to build the project. Feel free to modify the script to suit your needs.\n\n```bash\n$ bun run build # ⚠️ Be careful not to confuse this command with `bun build`.\n```\n\nThe build output will be located in the `dist` folder, containing JS files. Unlike the default Nest template, the JS code inside the `dist` folder includes bundled dependencies, thanks to Bun. The result is that the server starts almost twice as fast as the default Nest template \u0026 the `bun run start:dev` script. You can run the built output directly with Bun using the following command:\n\n```bash\n$ bun run dist/main.js\n```\n\nHowever, using the [`bun run start:prod`](./package.json) command is recommended, due to the `NODE_ENV` environment variable will be set to `production`.\n\n## Run tests\n\nBun is also a test runner and provides a Jest-like API for running tests. Hence, `jest` is not included in this template. You can run tests using the following commands:\n\n```bash\n# unit tests\n$ bun run test\n\n# e2e tests\n$ bun run test:e2e\n\n# test coverage\n$ bun run test:cov\n```\n\n## Libraries Guides\n\n### 1. [TypeORM](https://typeorm.io/)\n\nTypeORM can be used seamlessly with this template, just like any other Nest projects. However, by default, TypeORM CLI uses Node runtime, which requires you to install `ts-node` to execute TypeScript files. Therefore, using TypeORM CLI with Bun runtime is recommended, which can be achieved by passing the `--bun` flag like this:\n\n```bash\n# With bunx\n$ bunx --bun typeorm \u003ctypeorm-command\u003e\n\n# Or with `bun run`, only if you have TypeORM installed as a dependency\n$ bun run --bun typeorm \u003ctypeorm-command\u003e\n```\n\nIf you wish to transpile TypeORM's migrations to JS in order to use them in production, you can modify the build script (`scripts/build.ts`) to include the migration files:\n\n1. Retrieve all the names of migration files, in this case, from the `src/database/migrations` folder, using [Bun Glob API](https://bun.sh/docs/api/glob).\n\n```typescript\nimport { Glob } from 'bun';\n\nconst migrationFileNames = Array.from(\n  new Glob('./src/database/migrations/*.ts').scanSync(),\n).map((name) =\u003e name.replaceAll(/\\\\/g, '/'));\n```\n\n2. In the `Bun.build` function, add the migration files to the `entrypoints` array, and you are good to go:\n\n```typescript\nimport { build } from 'bun';\n\nconst result = await build({\n  entrypoints: ['./src/main.ts', ...migrationFileNames],\n  // ...\n```\n\n3. In order to execute TypeORM's CLI migration-related commands in production, you also have to specify the [datasource config file](https://typeorm.io/data-source-options#data-source-options-example) in the `entrypoints` array:\n\n```typescript\nconst result = await build({\n  entrypoints: [\n    './src/main.ts',\n    './src/database/migrations/ormconfig.ts', // Or path to your datasource config file\n    ...migrationFileNames\n  ],\n  // ...\n```\n\n\u003e ⚠️ **Warning**: While the entrypoint of the application is `main.ts` placed at `src/` folder, if the migrations are **NOT** placed in the `src/` folder, the build output `main.js` file will be **placed at `dist/src/`, not `dist/`**. The same goes for the datasource config file.\n\n### 2. [Serving static files (`@nestjs/serve-static`)](https://docs.nestjs.com/recipes/serve-static)\n\nTo serve static files in production, you must modify the build script to include them in the build output. There are two methods to achieve this:\n\n#### Method 1. Specify the path to the static files in the `entrypoints` array:\n\n```typescript\nimport { Glob, build } from 'bun';\n\nconst staticFileNames = Array.from(\n  new Glob('./src/static/*').scanSync(),\n).map((name) =\u003e name.replaceAll(/\\\\/g, '/'));\n\nconst result = await build({\n  entrypoints: ['./src/main.ts', ...staticFileNames],\n  // ...\n```\n\nJust like the warning with TypeORM, if the static files (folder) are **NOT** placed in the `src/` folder, the build output `main.js` file will be **placed at `dist/src/`, not `dist/**.\n\n#### Method 2. Copy the static files to the build output folder using [Bun Shell Scripting](https://bun.sh/docs/runtime/shell) and the good old `cp` command:\n\n```typescript\nimport { $ } from 'bun';\nimport { join } from 'node:path';\n\nawait $`cp -R ${join(__dirname, '../src/static')} ${join(__dirname, '../dist/static')}`;\n```\n\nUsing this method, you can place the static files (folder) anywhere you want.\n\n## Support\n\n- Support Nest [here](https://docs.nestjs.com/support).\n- Contribute to Bun [here](https://bun.sh/docs/project/contributing).\n\n## Stay in touch\n\n- Nest:\n\n  - Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)\n  - Website - [https://nestjs.com](https://nestjs.com/)\n  - Twitter - [@nestframework](https://twitter.com/nestframework)\n\n- Bun:\n\n  - Author - [oven-sh](https://github.com/oven-sh)\n  - Website - [https://bun.sh](https://bun.sh/)\n  - Twitter - [@bunjavascript](https://x.com/bunjavascript)\n\n- Me, the author of this template:\n  - GitHub - [@dung204](https://github.com/dung204)\n  - Twiter - [@mantrilogix](https://x.com/mantrilogix)\n\n## License\n\n- Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).\n- Bun is [MIT licensed](https://github.com/oven-sh/bun/blob/main/LICENSE.md)\n- This template is also [MIT licensed](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdung204%2Fbunest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdung204%2Fbunest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdung204%2Fbunest/lists"}