5
5
</a >
6
6
</p >
7
7
8
- Starter for Node.js Express API in Typescript with jsonwebtoken, joi, Knex, Objection.js and many other popular tools.
8
+ Starter for Node.js, Express API in Typescript and PostgreSQL with jsonwebtoken, joi, Knex, Objection.js and many other popular tools.
9
9
10
10
## Requirements
11
11
@@ -16,8 +16,6 @@ Starter for Node.js Express API in Typescript with jsonwebtoken, joi, Knex, Obje
16
16
17
17
## Getting Started
18
18
19
- Clone the repository, install the dependencies.
20
-
21
19
``` bash
22
20
# Clone repository
23
21
$ git clone
[email protected] :cham11ng/typescript-api-starter.git
< application-name
>
@@ -27,6 +25,9 @@ $ cd <application-name>
27
25
# Update database credentials
28
26
$ cp .env.example .env
29
27
28
+ # Install dependencies
29
+ $ yarn install
30
+
30
31
$ yarn migrate
31
32
```
32
33
@@ -53,60 +54,54 @@ $ yarn dev
53
54
<a href =" https://imgur.com/gallery/4rhTo " ><img src =" https://i.imgur.com/GpcDbLB.gif " /></a >
54
55
</p >
55
56
56
- ** Using Docker**
57
-
58
- Make a copy of ` .env.docker ` and save as ` .env ` .
57
+ ### Using Docker
59
58
60
59
``` bash
60
+ # Make a copy of `.env.docker` and save as `.env`.
61
61
$ cp .env.docker .env
62
62
```
63
63
64
64
Install dependencies and run the application locally.
65
65
66
66
``` bash
67
- $ docker compose up -d postgres
68
-
69
67
$ docker compose up -d api
70
68
71
- $ docker compose exec api sh yarn migrate # Make sure server is started checking logs before running this command
69
+ # Make sure server is started checking logs before running this command
70
+ $ docker compose exec api sh yarn migrate
72
71
```
73
72
74
- View logs of the container.
75
-
76
73
``` bash
77
- $ docker compose logs -f
78
- ```
74
+ # View logs of the container.
75
+ $ docker compose logs -f api
79
76
80
- To stop the services.
81
-
82
- ``` bash
77
+ # To stop the services.
83
78
$ docker compose stop api postgres
84
79
```
85
80
86
81
## Generating Migrations and Seeds
87
82
88
- To create migration use ` make:migration ` and seed use ` make:seeder ` :
89
-
90
83
``` bash
84
+ # To create migration use `make:migration`
91
85
$ yarn make:migration create_{table_name}_table
92
86
87
+ # To create seed use `make:seeder`
93
88
$ yarn make:seeder {table_name}_table_seeder
94
89
```
95
90
96
- Example,
97
-
98
91
``` bash
92
+ # Example
99
93
$ yarn make:migration create_posts_table
100
-
101
94
$ yarn make:seeder post_table_seeder
102
95
```
103
96
104
97
Modify migration and seeder file as per the requirement. Then finally:
105
98
106
99
``` bash
107
- $ yarn migrate # to migrate
100
+ # to migrate
101
+ $ yarn migrate
108
102
109
- $ yarn seed # to seed
103
+ # to seed
104
+ $ yarn seed
110
105
```
111
106
112
107
## Setting up REST Client
@@ -120,7 +115,7 @@ Create a file or add following lines in `.vscode` > `settings.json` and switch a
120
115
"refreshToken" : " foo" ,
121
116
"accessToken" : " bar" ,
122
117
123
- "password" : " secret"
118
+ "password" : " secret"
124
119
},
125
120
"local" : {
126
121
"host" : " localhost" ,
0 commit comments