본문 바로가기

개발관련/NestJS

Nestjs 프로젝트 생성

728x90

$nest new nest-app nest-app으로 nestjs 프로젝트를 생성하고, PS C:\dev\nest-app> npm run test:cov >> # test coverage >> npm run test:e2e >> # e2e tests >> npm run test >> # unit tests > nest-app@0.0.1 test:cov C:\dev\nest-app > jest --coverage PASS src/app.controller.spec.ts AppController root √ should return "Hello World!" (18 ms) -------------------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s -------------------|---------|----------|---------|---------|------------------- All files | 54.16 | 100 | 75 | 50 | app.controller.ts | 100 | 100 | 100 | 100 | app.module.ts | 0 | 100 | 100 | 0 | 1-10 app.service.ts | 100 | 100 | 100 | 100 | main.ts | 0 | 100 | 0 | 0 | 1-8 -------------------|---------|----------|---------|---------|------------------- Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 8.578 s Ran all test suites. > nest-app@0.0.1 test:e2e C:\dev\nest-app > jest --config ./test/jest-e2e.json 파일들이 생성되고 테스트 실행도 제공해준다. PS C:\dev\nest-app> nest Usage: nest [options] Options: -v, --version Output the current version. -h, --help Output usage information. Commands: new|n [options] [name] Generate Nest application. build [options] [app] Build Nest application. start [options] [app] Run Nest application. info|i Display Nest project details. update|u [options] Update Nest dependencies. add [options] Adds support for an external library to your project. generate|g [options] [name] [path] Generate a Nest element. Schematics available on @nestjs/schematics collection: ┌───────────────┬─────────────┬──────────────────────────────────────────────┐ │ name │ alias │ description │ │ application │ application │ Generate a new application workspace │ │ class │ cl │ Generate a new class │ │ configuration │ config │ Generate a CLI configuration file │ │ controller │ co │ Generate a controller declaration │ │ decorator │ d │ Generate a custom decorator │ │ filter │ f │ Generate a filter declaration │ │ gateway │ ga │ Generate a gateway declaration │ │ guard │ gu │ Generate a guard declaration │ │ interceptor │ in │ Generate an interceptor declaration │ │ interface │ interface │ Generate an interface │ │ middleware │ mi │ Generate a middleware declaration │ │ module │ mo │ Generate a module declaration │ │ pipe │ pi │ Generate a pipe declaration │ │ provider │ pr │ Generate a provider declaration │ │ resolver │ r │ Generate a GraphQL resolver declaration │ │ service │ s │ Generate a service declaration │ │ library │ lib │ Generate a new library within a monorepo │ │ sub-app │ app │ Generate a new application within a monorepo │ │ resource │ res │ Generate a new CRUD resource │ └───────────────┴─────────────┴──────────────────────────────────────────────┘ nest라고 치면 쓸 수 있는 cli명령어와 alias가 나온다 예를들어 새로운 컨트롤러를 만들때는, nest g co 라고 친다. 컨트롤러 이름을 묻는 질문에 원하는 이름을 치면 디렉토리와 컨트롤러가 이름에 맞게 생성된다. PS C:\dev\nest-app> nest g co ? What name would you like to use for the controller? greeting CREATE src/greeting/greeting.controller.spec.ts (492 bytes) CREATE src/greeting/greeting.controller.ts (101 bytes) UPDATE src/app.module.ts (211 bytes)

728x90

'개발관련 > NestJS' 카테고리의 다른 글

NestJS 설치 (+에러 해결법)  (0) 2023.08.08