@thzero/library_server 0.18.20 → 0.18.22
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 +112 -112
- package/boot/index.js +529 -529
- package/boot/plugins/admin/index.js +6 -6
- package/boot/plugins/admin/news.js +33 -33
- package/boot/plugins/admin/users.js +33 -33
- package/boot/plugins/api.js +64 -64
- package/boot/plugins/apiFront.js +31 -31
- package/boot/plugins/index.js +70 -70
- package/boot/plugins/news.js +44 -44
- package/boot/plugins/users.js +46 -46
- package/boot/plugins/usersExtended.js +32 -32
- package/constants.js +45 -45
- package/data/baseNews.js +42 -42
- package/data/baseSettingsUser.js +9 -9
- package/data/baseUser.js +28 -28
- package/data/index.js +24 -24
- package/data/named.js +20 -20
- package/errors/tokenExpired.js +7 -7
- package/license.md +8 -8
- package/openSource.js +66 -66
- package/package.json +38 -38
- package/repository/index.js +182 -182
- package/repository/usageMetrics/devnull.js +16 -16
- package/routes/index.js +76 -76
- package/service/admin/baseNews.js +45 -45
- package/service/admin/index.js +130 -130
- package/service/admin/news.js +6 -6
- package/service/admin/users.js +107 -107
- package/service/baseSecurity.js +183 -183
- package/service/baseUser.js +122 -122
- package/service/communication.js +6 -6
- package/service/config.js +37 -37
- package/service/crypto.js +16 -16
- package/service/discovery/index.js +6 -6
- package/service/discovery/resources/index.js +101 -101
- package/service/external.js +19 -19
- package/service/externalRest.js +19 -19
- package/service/index.js +20 -20
- package/service/monitoring.js +12 -12
- package/service/news/base.js +59 -59
- package/service/news/index.js +6 -6
- package/service/news/validation/index.js +6 -6
- package/service/plans.js +31 -31
- package/service/restCommunication.js +21 -21
- package/service/usageMetrics.js +84 -84
- package/service/utility.js +190 -190
- package/service/version.js +37 -37
- package/utility/injector.js +59 -59
- package/utility/internalIp/index.js +48 -48
- package/utility/list/doubleLinked.js +88 -88
- package/utility/list/priorityQueue.js +109 -109
- package/utility/list/queue.js +72 -72
- package/utility/os.js +20 -20
package/README.md
CHANGED
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-

|
|
2
|
-

|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
|
|
5
|
-
# library_server
|
|
6
|
-
|
|
7
|
-
An opinionated library of common functionality to bootstrap an API application using MongoDb and Firebase. Currently either Fastify or Koa can be used as the web server; Fastify will be the focus going forward due to lack of support and updates with the Koa stack.
|
|
8
|
-
|
|
9
|
-
### Requirements
|
|
10
|
-
|
|
11
|
-
#### NodeJs
|
|
12
|
-
|
|
13
|
-
Requires [NodeJs ](https://nodejs.org) version 18+.
|
|
14
|
-
|
|
15
|
-
### Installation
|
|
16
|
-
|
|
17
|
-
[](https://npmjs.org/package/@thzero/library_server)
|
|
18
|
-
|
|
19
|
-
#### Mongo
|
|
20
|
-
|
|
21
|
-
Mongo is the only currently supposed option as the server side data source.
|
|
22
|
-
|
|
23
|
-
* Install the MongoDb (either locally or in the cloud) server
|
|
24
|
-
* Recommendation is MongoDb Atlas (https://www.mongodb.com/cloud/atlas) for development/sandbox
|
|
25
|
-
* Create a new MongoDb database in the Mongo server
|
|
26
|
-
* Restore the default SocietySidekick MongoDb
|
|
27
|
-
* Use the following MongoDb CLI tool to restore the default database located at (https://github.com/thzero/societySidekick-database)
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
.\bin\mongorestore --host <mongodb host name> --ssl --username <mongo user name> --password <mongo user password> --authenticationDatabase admin -d production <location of default database>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Recommended tools for managing Mongo database
|
|
34
|
-
* MongoDb Compass (https://www.mongodb.com/products/compass)
|
|
35
|
-
* Robo3T (https://robomongo.org)
|
|
36
|
-
|
|
37
|
-
#### Firebase
|
|
38
|
-
|
|
39
|
-
Google Firebase (https://firebase.google.com) provides the social based authentication; currently only Google social accounts are supported.
|
|
40
|
-
|
|
41
|
-
* Add a new project
|
|
42
|
-
* Setup **Authentication**, enabled Google in the **Sign-in method**.
|
|
43
|
-
* Get the Firebase SDK configuration
|
|
44
|
-
* Go to Project Overview->Settings->Service accounts
|
|
45
|
-
* Select **Node.js** option
|
|
46
|
-
* Click **Generate new private key**
|
|
47
|
-
|
|
48
|
-
#### Configuration
|
|
49
|
-
|
|
50
|
-
The following setup for configuration is required for an application using this library_server dependency
|
|
51
|
-
|
|
52
|
-
* Setup the configuration found in the config\development.json
|
|
53
|
-
* Note that this is ignored in the .gitignore
|
|
54
|
-
* Configuration looks like the following
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
{
|
|
58
|
-
"app": {
|
|
59
|
-
"auth": {
|
|
60
|
-
"apiKey": "<generate a GUID as key in standard nomeclature '#######-####-####-####-############'>",
|
|
61
|
-
"claims": {
|
|
62
|
-
"check": <true of false, false by default>,
|
|
63
|
-
"useDefault": <true of false, false by default>
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"cors": {
|
|
67
|
-
"origin": "*"
|
|
68
|
-
},
|
|
69
|
-
"db": {
|
|
70
|
-
"default": "mongo"
|
|
71
|
-
"mongo": {
|
|
72
|
-
"connection": "<mongo connection string>",
|
|
73
|
-
"name": "<environment name>"
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
"logging": {
|
|
77
|
-
"level": <see https://github.com/pinojs/pino/issues/123 for logging levels>,
|
|
78
|
-
"prettify": <true of false if you want prettify, if true requres 'pino-prettify' as a dependency>
|
|
79
|
-
},
|
|
80
|
-
"port": <port to run the server on>
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
##### Environment Variable overrides
|
|
86
|
-
|
|
87
|
-
The following environmnent variables override the above configuration settings found in the config file.
|
|
88
|
-
|
|
89
|
-
* AUTH_API_KEY
|
|
90
|
-
* AUTH_CLAIMS_CHECK
|
|
91
|
-
* AUTH_CLAIMS_USE_DEFAULT
|
|
92
|
-
* CORS_ORIGIN
|
|
93
|
-
* DB_DEFAULT
|
|
94
|
-
* DB_CONNECTION_ATLAS
|
|
95
|
-
* DB_NAME_ATLAS
|
|
96
|
-
* DB_CONNECTION_MONGO
|
|
97
|
-
* DB_NAME_MONGO
|
|
98
|
-
* IP_ADDRESS
|
|
99
|
-
* LOGGING_LEVEL
|
|
100
|
-
* LOGGING_PRETTIFY
|
|
101
|
-
* PORT
|
|
102
|
-
|
|
103
|
-
##### Development Tool Configuration
|
|
104
|
-
|
|
105
|
-
* Include the following in the package.json for the application.
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
"version_major": #,
|
|
109
|
-
"version_minor": #,
|
|
110
|
-
"version_patch": #,
|
|
111
|
-
"version_date": "MM/DD/YYYY",
|
|
112
|
-
```
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
# library_server
|
|
6
|
+
|
|
7
|
+
An opinionated library of common functionality to bootstrap an API application using MongoDb and Firebase. Currently either Fastify or Koa can be used as the web server; Fastify will be the focus going forward due to lack of support and updates with the Koa stack.
|
|
8
|
+
|
|
9
|
+
### Requirements
|
|
10
|
+
|
|
11
|
+
#### NodeJs
|
|
12
|
+
|
|
13
|
+
Requires [NodeJs ](https://nodejs.org) version 18+.
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
[](https://npmjs.org/package/@thzero/library_server)
|
|
18
|
+
|
|
19
|
+
#### Mongo
|
|
20
|
+
|
|
21
|
+
Mongo is the only currently supposed option as the server side data source.
|
|
22
|
+
|
|
23
|
+
* Install the MongoDb (either locally or in the cloud) server
|
|
24
|
+
* Recommendation is MongoDb Atlas (https://www.mongodb.com/cloud/atlas) for development/sandbox
|
|
25
|
+
* Create a new MongoDb database in the Mongo server
|
|
26
|
+
* Restore the default SocietySidekick MongoDb
|
|
27
|
+
* Use the following MongoDb CLI tool to restore the default database located at (https://github.com/thzero/societySidekick-database)
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
.\bin\mongorestore --host <mongodb host name> --ssl --username <mongo user name> --password <mongo user password> --authenticationDatabase admin -d production <location of default database>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Recommended tools for managing Mongo database
|
|
34
|
+
* MongoDb Compass (https://www.mongodb.com/products/compass)
|
|
35
|
+
* Robo3T (https://robomongo.org)
|
|
36
|
+
|
|
37
|
+
#### Firebase
|
|
38
|
+
|
|
39
|
+
Google Firebase (https://firebase.google.com) provides the social based authentication; currently only Google social accounts are supported.
|
|
40
|
+
|
|
41
|
+
* Add a new project
|
|
42
|
+
* Setup **Authentication**, enabled Google in the **Sign-in method**.
|
|
43
|
+
* Get the Firebase SDK configuration
|
|
44
|
+
* Go to Project Overview->Settings->Service accounts
|
|
45
|
+
* Select **Node.js** option
|
|
46
|
+
* Click **Generate new private key**
|
|
47
|
+
|
|
48
|
+
#### Configuration
|
|
49
|
+
|
|
50
|
+
The following setup for configuration is required for an application using this library_server dependency
|
|
51
|
+
|
|
52
|
+
* Setup the configuration found in the config\development.json
|
|
53
|
+
* Note that this is ignored in the .gitignore
|
|
54
|
+
* Configuration looks like the following
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
{
|
|
58
|
+
"app": {
|
|
59
|
+
"auth": {
|
|
60
|
+
"apiKey": "<generate a GUID as key in standard nomeclature '#######-####-####-####-############'>",
|
|
61
|
+
"claims": {
|
|
62
|
+
"check": <true of false, false by default>,
|
|
63
|
+
"useDefault": <true of false, false by default>
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"cors": {
|
|
67
|
+
"origin": "*"
|
|
68
|
+
},
|
|
69
|
+
"db": {
|
|
70
|
+
"default": "mongo"
|
|
71
|
+
"mongo": {
|
|
72
|
+
"connection": "<mongo connection string>",
|
|
73
|
+
"name": "<environment name>"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"logging": {
|
|
77
|
+
"level": <see https://github.com/pinojs/pino/issues/123 for logging levels>,
|
|
78
|
+
"prettify": <true of false if you want prettify, if true requres 'pino-prettify' as a dependency>
|
|
79
|
+
},
|
|
80
|
+
"port": <port to run the server on>
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
##### Environment Variable overrides
|
|
86
|
+
|
|
87
|
+
The following environmnent variables override the above configuration settings found in the config file.
|
|
88
|
+
|
|
89
|
+
* AUTH_API_KEY
|
|
90
|
+
* AUTH_CLAIMS_CHECK
|
|
91
|
+
* AUTH_CLAIMS_USE_DEFAULT
|
|
92
|
+
* CORS_ORIGIN
|
|
93
|
+
* DB_DEFAULT
|
|
94
|
+
* DB_CONNECTION_ATLAS
|
|
95
|
+
* DB_NAME_ATLAS
|
|
96
|
+
* DB_CONNECTION_MONGO
|
|
97
|
+
* DB_NAME_MONGO
|
|
98
|
+
* IP_ADDRESS
|
|
99
|
+
* LOGGING_LEVEL
|
|
100
|
+
* LOGGING_PRETTIFY
|
|
101
|
+
* PORT
|
|
102
|
+
|
|
103
|
+
##### Development Tool Configuration
|
|
104
|
+
|
|
105
|
+
* Include the following in the package.json for the application.
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
"version_major": #,
|
|
109
|
+
"version_minor": #,
|
|
110
|
+
"version_patch": #,
|
|
111
|
+
"version_date": "MM/DD/YYYY",
|
|
112
|
+
```
|