├── .gitignore ├── bun.lockb ├── tsconfig.build.json ├── nest-cli.json ├── src ├── main.ts ├── entities │ └── user.entity.ts ├── app.controller.ts ├── app.service.ts └── app.module.ts ├── tsconfig.json ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/letstri/bun-nestjs/HEAD/bun.lockb -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/nest-cli", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src", 5 | "compilerOptions": { 6 | "deleteOutDir": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /src/entities/user.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; 2 | 3 | @Entity() 4 | export class User { 5 | @PrimaryGeneratedColumn() 6 | id: number; 7 | 8 | @Column() 9 | firstName: string; 10 | 11 | @Column() 12 | lastName: string; 13 | 14 | @Column() 15 | age: number; 16 | } 17 | -------------------------------------------------------------------------------- /src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | createUser() { 10 | return this.appService.createUser(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "ES2021", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true, 15 | "strictNullChecks": false, 16 | "noImplicitAny": false, 17 | "strictBindCallApply": false, 18 | "forceConsistentCasingInFileNames": false, 19 | "noFallthroughCasesInSwitch": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { InjectRepository } from '@nestjs/typeorm'; 3 | import type { Repository } from 'typeorm'; 4 | import { User } from './entities/user.entity'; 5 | 6 | @Injectable() 7 | export class AppService { 8 | constructor( 9 | @InjectRepository(User) 10 | private readonly userRepository: Repository, 11 | ) {} 12 | 13 | async createUser() { 14 | const user = this.userRepository.create({ 15 | firstName: 'Valerii', 16 | lastName: 'Strilets', 17 | age: 27, 18 | }); 19 | 20 | const entity = await this.userRepository.save(user); 21 | return entity; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { TypeOrmModule } from '@nestjs/typeorm'; 3 | import { AppController } from './app.controller'; 4 | import { AppService } from './app.service'; 5 | import { User } from './entities/user.entity'; 6 | 7 | const userForFeature = TypeOrmModule.forFeature([User]); 8 | 9 | @Module({ 10 | imports: [ 11 | TypeOrmModule.forRoot({ 12 | type: 'postgres', 13 | host: 'localhost', 14 | port: 5432, 15 | username: 'postgres', 16 | password: 'root', 17 | database: 'test', 18 | synchronize: true, 19 | logging: false, 20 | entities: [User], 21 | }), 22 | userForFeature, 23 | ], 24 | controllers: [AppController], 25 | providers: [AppService], 26 | }) 27 | export class AppModule {} 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bun", 3 | "version": "0.0.1", 4 | "author": "Valerii Strilets", 5 | "license": "UNLICENSED", 6 | "scripts": { 7 | "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", 8 | "start:dev": "bun --watch ./src/main.ts", 9 | "start:debug": "nest start --debug --watch", 10 | "start:prod": "bun ./src/main.ts", 11 | "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix" 12 | }, 13 | "dependencies": { 14 | "@nestjs/common": "^10.0.0", 15 | "@nestjs/core": "^10.0.0", 16 | "@nestjs/platform-express": "^10.0.0", 17 | "@nestjs/typeorm": "^10.0.1", 18 | "pg": "^8.11.3", 19 | "typeorm": "^0.3.17" 20 | }, 21 | "devDependencies": { 22 | "@nestjs/cli": "^10.0.0", 23 | "@nestjs/schematics": "^10.0.0", 24 | "@types/express": "^4.17.17", 25 | "@types/node": "^20.9.4", 26 | "@typescript-eslint/eslint-plugin": "^6.0.0", 27 | "@typescript-eslint/parser": "^6.0.0", 28 | "eslint": "^8.42.0", 29 | "eslint-config-prettier": "^9.0.0", 30 | "eslint-plugin-prettier": "^5.0.0", 31 | "prettier": "^3.0.0", 32 | "typescript": "^5.1.3" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Nest Logo 3 |

4 | 5 | [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 6 | [circleci-url]: https://circleci.com/gh/nestjs/nest 7 | 8 |

A progressive Bun framework for building efficient and scalable server-side applications.

9 |

10 | NPM Version 11 | Package License 12 | NPM Downloads 13 | CircleCI 14 | Coverage 15 | Discord 16 | Backers on Open Collective 17 | Sponsors on Open Collective 18 | 19 | Support us 20 | 21 |

22 | 24 | 25 | ## Description 26 | 27 | [Nest](https://github.com/nestjs/nest) framework TypeScript repository with Bun. 28 | 29 | ## Installation 30 | 31 | ```bash 32 | $ bun install 33 | ``` 34 | 35 | ## Running the app 36 | 37 | ```bash 38 | # watch mode 39 | $ bun run start:dev 40 | 41 | # production mode 42 | $ bun run start:prod 43 | ``` 44 | 45 | ## Support 46 | 47 | Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). 48 | 49 | ## Stay in touch 50 | 51 | - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) 52 | - Website - [https://nestjs.com](https://nestjs.com/) 53 | - Twitter - [@nestframework](https://twitter.com/nestframework) 54 | - Bun adaption - [@letstri](https://github.com/letstri) 55 | 56 | ## License 57 | 58 | Nest is [MIT licensed](LICENSE). 59 | --------------------------------------------------------------------------------