Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Nest.js guide #4096

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions docs/guides/ecosystem/nestjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Build a fullstack app with Nest.js and Bun
---

{% callout %}
Requires Bun `v0.7.0` or later.
{% /callout %}

---

Initialize your app with the Nest.js CLI.

```sh
$ bunx @nestjs/cli new my-app
⚡ We will scaffold your app in a few seconds..

? Which package manager would you ❤️ to use? bun
CREATE my-app/.eslintrc.js (663 bytes)
CREATE my-app/.prettierrc (51 bytes)
CREATE my-app/README.md (3347 bytes)
CREATE my-app/nest-cli.json (171 bytes)
CREATE my-app/package.json (1947 bytes)
CREATE my-app/tsconfig.build.json (97 bytes)
CREATE my-app/tsconfig.json (546 bytes)
CREATE my-app/src/app.controller.spec.ts (617 bytes)
CREATE my-app/src/app.controller.ts (274 bytes)
CREATE my-app/src/app.module.ts (249 bytes)
CREATE my-app/src/app.service.ts (142 bytes)
CREATE my-app/src/main.ts (208 bytes)
CREATE my-app/test/app.e2e-spec.ts (630 bytes)
CREATE my-app/test/jest-e2e.json (183 bytes)

✔ Installation in progress... ☕

🚀 Successfully created project my-app
👉 Get started with the following commands:

$ cd my-app
$ bun run start
```

---

As the Nest.js templater intructed, let's `cd` into our app directory and start the development server.

```sh
$ cd my-app
$ bun run start
$ nest start
[Nest] 35114 - 08/09/2023, 1:51:29 PM LOG [NestFactory] Starting Nest application...
[Nest] 35114 - 08/09/2023, 1:51:29 PM LOG [InstanceLoader] AppModule dependencies initialized +5ms
[Nest] 35114 - 08/09/2023, 1:51:29 PM LOG [RoutesResolver] AppController {/}: +7ms
[Nest] 35114 - 08/09/2023, 1:51:29 PM LOG [RouterExplorer] Mapped {/, GET} route +0ms
[Nest] 35114 - 08/09/2023, 1:51:29 PM LOG [NestApplication] Nest application successfully started +1ms
```

---

To run the server in watch mode. Nest.js does not support hot reloading [out of the box](https://docs.nestjs.com/recipes/hot-reload), but you can run the server in watch mode. This will restart the server when changes are made.

```sh
$ bun run start:dev
```

---

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.