@thzero/library_server 0.18.21 → 0.18.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +178 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,12 +10,26 @@ An opinionated library of common functionality to bootstrap an API application u
|
|
|
10
10
|
|
|
11
11
|
#### NodeJs
|
|
12
12
|
|
|
13
|
-
Requires [NodeJs ](https://nodejs.org) version
|
|
13
|
+
Requires [NodeJs ](https://nodejs.org) version 22+.
|
|
14
|
+
|
|
15
|
+
### NodeMon
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
npm -g i nodemon
|
|
19
|
+
```
|
|
14
20
|
|
|
15
21
|
### Installation
|
|
16
22
|
|
|
17
23
|
[](https://npmjs.org/package/@thzero/library_server)
|
|
18
24
|
|
|
25
|
+
#### NPM Dependencies
|
|
26
|
+
|
|
27
|
+
Install the NPM dependencies for the server.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
19
33
|
#### Mongo
|
|
20
34
|
|
|
21
35
|
Mongo is the only currently supposed option as the server side data source.
|
|
@@ -45,6 +59,10 @@ Google Firebase (https://firebase.google.com) provides the social based authenti
|
|
|
45
59
|
* Select **Node.js** option
|
|
46
60
|
* Click **Generate new private key**
|
|
47
61
|
|
|
62
|
+
#### ServiceAccountKey.json
|
|
63
|
+
|
|
64
|
+
* Copy the contents of the file that was downloaded when generating a new private key into the 'config\ServiceAccountKey.json' file.
|
|
65
|
+
|
|
48
66
|
#### Configuration
|
|
49
67
|
|
|
50
68
|
The following setup for configuration is required for an application using this library_server dependency
|
|
@@ -110,3 +128,162 @@ The following environmnent variables override the above configuration settings f
|
|
|
110
128
|
"version_patch": #,
|
|
111
129
|
"version_date": "MM/DD/YYYY",
|
|
112
130
|
```
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
### Compile and hot-reloads for development
|
|
135
|
+
|
|
136
|
+
#### NPM CLI
|
|
137
|
+
|
|
138
|
+
Run the application server locally in debug mode with hot reloading via Nodemon.
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
npm run debug
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Visual Code
|
|
145
|
+
|
|
146
|
+
Install VisualCode, open the 'server' folder via 'Open Folder'.
|
|
147
|
+
|
|
148
|
+
Using the Menu->Run->Start Debugging will launch the application in debug mode with hot reloading via Nodemon
|
|
149
|
+
|
|
150
|
+
## Hosting
|
|
151
|
+
|
|
152
|
+
See Google Cloud Hosting.
|
|
153
|
+
|
|
154
|
+
## Google Cloud Hosting
|
|
155
|
+
|
|
156
|
+
Login to Google Cloud hosting, select the same account that was setup for Firebase.
|
|
157
|
+
|
|
158
|
+
Enable the following APIs in the Enable APIs & Services section for the project.
|
|
159
|
+
|
|
160
|
+
* Cloud Source Repositories API
|
|
161
|
+
* Cloud Build API
|
|
162
|
+
|
|
163
|
+
### Project's cloudbuild.yaml
|
|
164
|
+
|
|
165
|
+
Update the cloudbuild.yaml file in the source project and change the following based on your account name
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
https://source.developers.google.com/p/<account name>/r/github_thzero_rocket_sidekick-common
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Setup Google Cloud Source Repositories
|
|
172
|
+
|
|
173
|
+
This is a mirror of the GitHub repo for the following repos:
|
|
174
|
+
* https://img.shields.io/github/package-json/v/thzero/rocket_sidekick-common
|
|
175
|
+
* https://img.shields.io/github/package-json/v/thzero/rocket_sidekick-server
|
|
176
|
+
|
|
177
|
+
* Add Repository
|
|
178
|
+
* Connect external repository
|
|
179
|
+
* Select the project setup by Firebase, then GitHub
|
|
180
|
+
* Select the web-common repo
|
|
181
|
+
* Connect selected repositories
|
|
182
|
+
|
|
183
|
+
Select repository, then permissions. Verify that the Cloud Build Service Account is listed.
|
|
184
|
+
|
|
185
|
+
### Deploy to CloudRun
|
|
186
|
+
|
|
187
|
+
https://cloud.google.com/run/docs/continuous-deployment-with-cloud-build
|
|
188
|
+
https://cloud.google.com/run/docs/deploying#service
|
|
189
|
+
|
|
190
|
+
#### Settings for Cloud Run configuration
|
|
191
|
+
|
|
192
|
+
##### Cloud Run
|
|
193
|
+
* Continuously deploy new revisions from a source repository
|
|
194
|
+
* Use Set Up With Cloud Build
|
|
195
|
+
* Select the Repository Provide and Repository
|
|
196
|
+
* Click Next
|
|
197
|
+
* Branch: ^master$
|
|
198
|
+
* Build Type: Dockerfile
|
|
199
|
+
* Source location: /Dockerfile
|
|
200
|
+
* Click Save
|
|
201
|
+
|
|
202
|
+
##### CPU Allocation
|
|
203
|
+
* CPU is only allocated during request processing
|
|
204
|
+
|
|
205
|
+
##### Revision Autoscaling
|
|
206
|
+
* Minimum 0
|
|
207
|
+
* Maximum 1000
|
|
208
|
+
|
|
209
|
+
##### Ingress Control
|
|
210
|
+
* All
|
|
211
|
+
|
|
212
|
+
##### Authentication
|
|
213
|
+
* Allow unauthenticated invocations
|
|
214
|
+
|
|
215
|
+
##### Capacity
|
|
216
|
+
* 512mb 1 cpu
|
|
217
|
+
* Requested Timeout 300
|
|
218
|
+
* Max Request per Container 80
|
|
219
|
+
|
|
220
|
+
##### Variables & Secrets
|
|
221
|
+
|
|
222
|
+
Add these variables:
|
|
223
|
+
|
|
224
|
+
* SERVICE_ACCOUNT_KEY - <Firebase servicecAccountKey.json file in local config folder>
|
|
225
|
+
* AUTH_API_KEY - <guid>
|
|
226
|
+
* DB_DEFAULT - atla
|
|
227
|
+
* DB_CONNECTION_ALTAS - <connection string>
|
|
228
|
+
* DB_NAME_ALTAS - production
|
|
229
|
+
* DB_CONNECTION_MONGO - <connection string>
|
|
230
|
+
* optional
|
|
231
|
+
* DB_NAME_MONGO - production
|
|
232
|
+
* optional
|
|
233
|
+
* LOG_LEVEL - debug
|
|
234
|
+
* IP_ADDRESS - 0.0.0.0
|
|
235
|
+
|
|
236
|
+
#### Cloud Source Repository
|
|
237
|
+
|
|
238
|
+
In Cloud Build, go to the Repositories section.
|
|
239
|
+
|
|
240
|
+
* Select an appropriate region, should be for the same region as your Cloud Run is running on
|
|
241
|
+
* Select 2nd Gen
|
|
242
|
+
* Link Repository to create a link to your repository
|
|
243
|
+
|
|
244
|
+
##### Link Repository
|
|
245
|
+
|
|
246
|
+
###### Connection
|
|
247
|
+
* Create a new Host Connection
|
|
248
|
+
|
|
249
|
+
###### Region
|
|
250
|
+
* Select the same region as your Cloud Run is running on
|
|
251
|
+
|
|
252
|
+
###### Name
|
|
253
|
+
* Set name for the connection
|
|
254
|
+
|
|
255
|
+
* Click Connect to create the connection
|
|
256
|
+
* You may require the Security Manager API to be enabled
|
|
257
|
+
* Click Continue in the confirmation dialog
|
|
258
|
+
|
|
259
|
+
###### Github Installation
|
|
260
|
+
* Select an installation user or Install a new account
|
|
261
|
+
|
|
262
|
+
#### Cloud Build Trigger
|
|
263
|
+
|
|
264
|
+
##### Event
|
|
265
|
+
* Push to branch
|
|
266
|
+
|
|
267
|
+
###### Region
|
|
268
|
+
* Select the same region as used with the Cloud Source Repository
|
|
269
|
+
|
|
270
|
+
###### Repository Generation
|
|
271
|
+
* Select 2nd
|
|
272
|
+
|
|
273
|
+
##### Source
|
|
274
|
+
* Select the repository
|
|
275
|
+
* Select "^master$" branch
|
|
276
|
+
|
|
277
|
+
##### Configuration
|
|
278
|
+
|
|
279
|
+
###### Type
|
|
280
|
+
* Cloud Build configuration file (yaml or json)
|
|
281
|
+
|
|
282
|
+
###### Location
|
|
283
|
+
* Repository
|
|
284
|
+
* Cloud Build configuration file location
|
|
285
|
+
* / cloudbuild.yaml
|
|
286
|
+
|
|
287
|
+
##### Deploy
|
|
288
|
+
|
|
289
|
+
Run the trigger to kick of a deploy.
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.18.
|
|
4
|
+
"version": "0.18.23",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 18,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
7
|
+
"version_patch": 23,
|
|
8
|
+
"version_date": "09/03/2025",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap an API using either Fastify or Koa as the web server.",
|
|
10
10
|
"author": "thZero",
|
|
11
11
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@godaddy/terminus": "^4.12.1",
|
|
29
29
|
"async-mutex": "^0.5.0",
|
|
30
|
-
"config": "^4.1.
|
|
30
|
+
"config": "^4.1.1",
|
|
31
31
|
"default-gateway": "^7.2.2",
|
|
32
32
|
"easy-rbac": "^4.0.0",
|
|
33
33
|
"ipaddr.js": "^2.2.0"
|