-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocument.txt
63 lines (49 loc) · 2.38 KB
/
Document.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
1. To create a nest.js project with specific version you have to use the specific verison cli:
-> npx @nestjs/cli@8.0.0 new my-nest-project
2. Using cli
a. to generate modules
i. if nestcli is globally installed then simply use:
- nest generate module modules/quiz or - nest g mo module/quiz
ii. if you want to use npx then(use this when nestjs/cli is not globally installed and only internally installed using point number 1 method):
- npx @nestjs/cli generate module modules/quiz
b. to generate controller
i. without test files:
=> nest g co quiz --no-spec or npx @nestjs/cli generate controller quiz --no-spec
ii. with test files:
=> nest g co quiz or npx @nestjs/cli generate controller quiz
c. to generate service
i. without test files:
- nest g service modules/auth --no-spec
ii. with test files:
- nest g service modules/auth
2. For migration:
- make sure to delete all tables first to start fresh then
a. to check all migrations:
=> yarn typeorm:cli migration:show
b. then create base migration file(the generated file will be inside database/migrations). This will have commands to create tables with out defined entitites:
=> yarn migration:generate BaseMigrations
or => npm run migration:generate BaseMigrations
c. To run the migrations:
=> yarn migration:run
d. to revert or run migration down:
=> yarn migration:revert
e. if you have to make changes to table columns then first make the necessary changes and run:
=> yarn migration:generate added_user_role_column
this will automatically apply the changes via migration. added_user_role_column is our customn migration file name. This command creates a new migration file inside migrations folder in database folder
then run the migration for the changes to take effect
=> yarn migration:run
f. if you want to frequently drop your tables and re run migration and seeds then utilze our scripts defined in package.json file:
=> yarn db:refresh
3. For seeders:
i. first run seed configuration:
=> yarn seed:config or npm run seed:config
ii. after creating the seed files generate the seed datas by:
=> yarn seed:run
4. for local strategy passport authentication:
- you must send username and password in payload with email and passport as value. like:
{
"username":"r@g.com",
"password":"Password@123"
}
5. for swagger api documentation:
- got to http://localhost:5000/api/ to see the documentation