minimonolith 0.13.7 → 0.14.1
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/.env.example +2 -5
- package/README.md +14 -1
- package/package.json +1 -1
- package/src/database/databaseService.js +6 -4
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -134,7 +134,9 @@ export default (MODELS, ROUTE_CODE) => ({
|
|
|
134
134
|
|
|
135
135
|
## Database Authentication
|
|
136
136
|
|
|
137
|
-
To set up authentication for the database, you need to provide the necessary environment variables in a `.env` file.
|
|
137
|
+
To set up authentication for the database, you need to provide the necessary environment variables in a `.env` file. Depending on the database dialect the required variables will differ.
|
|
138
|
+
|
|
139
|
+
For MySQL:
|
|
138
140
|
|
|
139
141
|
```makefile
|
|
140
142
|
MM_API_DB_USERNAME=<your_database_username>
|
|
@@ -147,4 +149,15 @@ MM_API_LOCAL_ENV=true
|
|
|
147
149
|
MM_API_PROD_ENV=false
|
|
148
150
|
```
|
|
149
151
|
|
|
152
|
+
For SQLite:
|
|
153
|
+
|
|
154
|
+
```makefile
|
|
155
|
+
MM_API_DB_DATABASE=<your_database_name>
|
|
156
|
+
MM_API_DB_DIALECT=sqlite
|
|
157
|
+
DB_STORAGE=:memory: # For in-memory SQLite database
|
|
158
|
+
# Or
|
|
159
|
+
DB_STORAGE=path/to/your/sqlite/file.db # For file-based SQLite database
|
|
160
|
+
```
|
|
161
|
+
|
|
150
162
|
Make sure to replace the placeholders with your actual database credentials. The `MM_API_LOCAL_ENV` variable is used to allow Sequelize to alter table structure automatically when working locally, while the `MM_API_PROD_ENV` variable controls logging of secret credentials for debugging purposes in non-production environments.
|
|
163
|
+
|
package/package.json
CHANGED
|
@@ -27,11 +27,13 @@ const establishConnection = async ORM => {
|
|
|
27
27
|
|
|
28
28
|
const registerDatabaseService = async API => {
|
|
29
29
|
try {
|
|
30
|
-
const { MM_API_DB_DIALECT, MM_API_DB_DB, MM_API_DB_USER,
|
|
31
|
-
|
|
30
|
+
const { MM_API_DB_DIALECT, MM_API_DB_DB, MM_API_DB_USER,
|
|
31
|
+
MM_API_DB_PASS, MM_API_DB_HOST, MM_API_DB_PORT, MM_API_DB_STORAGE } = process.env;
|
|
32
|
+
const SEQUELIZE_OPTIONS = { dialect: MM_API_DB_DIALECT, host: MM_API_DB_HOST,
|
|
33
|
+
port: MM_API_DB_PORT, storage: MM_API_DB_STORAGE, logging: false };
|
|
32
34
|
|
|
33
|
-
if (!process.env.PROD_ENV) console.log({ ROUTE_CODE,
|
|
34
|
-
|
|
35
|
+
if (!process.env.PROD_ENV) console.log({ ROUTE_CODE, MM_API_DB_VARS: { MM_API_DB_DIALECT,
|
|
36
|
+
MM_API_DB_USER, MM_API_DB_PASS, MM_API_DB_HOST, MM_API_DB_PORT, MM_API_DB_DB, MM_API_DB_STORAGE }});
|
|
35
37
|
API.ORM = new Sequelize(MM_API_DB_DB, MM_API_DB_USER, MM_API_DB_PASS, SEQUELIZE_OPTIONS);
|
|
36
38
|
establishConnection(API.ORM);
|
|
37
39
|
|