create-sip 1.3.6 → 1.3.8

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.
@@ -2,178 +2,11 @@
2
2
 
3
3
  Express based REST API template
4
4
 
5
- ## Install
5
+ ## Install dependencies
6
6
 
7
7
  ```cmd
8
8
  npm install
9
- ```
10
-
11
- ## Copy config file
12
-
13
- Copy **config/default.json.example** to **config/default.json** file.
14
-
15
- ## APP KEY generation
16
-
17
- Run the genkey:
18
-
19
- ```cmd
20
- node op key:generate
21
- ```
22
-
23
- ## Database settings
24
-
25
- The database settings can be found at the following location:
26
-
27
- * config/default.json
28
-
29
- ### Database dialect
30
-
31
- The default database is an in-memory database. Its contents are cleared after the server is restarted.
32
-
33
- One of:
34
-
35
- * sqlite
36
- * mariadb
37
-
38
- After installing the appropriate dependencies, it can be used:
39
-
40
- * mysql
41
- * postgres
42
- * mssql
43
- * db2
44
- * snowflake
45
- * oracle
46
-
47
- With the `sqlite` option, the usual path setting is `database.sqlite`. The default storage is :memory:, where data is stored in memory only.
48
-
49
- ## Starting
50
-
51
- For development:
52
-
53
- ```cmd
54
9
  npm run dev
55
10
  ```
56
11
 
57
- Run productum:
58
-
59
- ```cmd
60
- npm start
61
- ```
62
-
63
- ## Model and controller creation
64
-
65
- You can generate a model and controller with the following commands:
66
-
67
- ```bash
68
- node op make:model something
69
- node op make:controller something
70
- ```
71
-
72
- The name after the model and controller statements must be given in the singular. Controller generation automatically appends the "Controller" suffix.
73
-
74
- ## Admin user
75
-
76
- The admin user can be created with the following command:
77
-
78
- ```bash
79
- node op admin:generate
80
- ```
81
-
82
- The command will prompt for the password.
83
-
84
- ## Config generation
85
-
86
- The next command generates the default config file:
87
-
88
- ```bash
89
- node op conf:generate
90
- ```
91
-
92
- ## Database import
93
-
94
- The database can be seeded with the following command:
95
-
96
- ```bash
97
- node op db:import <model_name> <file_path>
98
- ```
99
-
100
- The model name must be given in the singular and lowercase. The file extension must be:
101
-
102
- * .json
103
- * .csv
104
-
105
- The keys in the JSON file and the field names in the CSV file must match the model fields.
106
-
107
- If the CSV file contains quotation marks, they are automatically removed.
108
-
109
- ## Database synchronization
110
-
111
- Models and database tables can be synchronized, but this can be dangerous.
112
-
113
- Database synchronization can be set up in the app/models/modrels.js file. Default values are:
114
-
115
- ```js
116
- { alter: true }
117
- ```
118
-
119
- This preserves the data and existing structure.
120
-
121
- Possible values:
122
-
123
- ```js
124
- { force: true }
125
- ```
126
-
127
- The latter deletes the contents of the database table!
128
-
129
- If the value is false, there is no synchronization in either case.
130
-
131
- ## Migration
132
-
133
- Generate a migration:
134
-
135
- ```bash
136
- node op make/migration thing
137
- ```
138
-
139
- Run all migration:
140
-
141
- ```bash
142
- node op migration:run
143
- ```
144
-
145
- Run a migration:
146
-
147
- ```bash
148
- node op migration:run <migration_name>
149
- ```
150
-
151
- Rollback a migration:
152
-
153
- ```bash
154
- node op migration:rollback
155
- ```
156
-
157
- Rollback two migrations:
158
-
159
- ```bash
160
- node op migration:rollback 2
161
- ```
162
-
163
- Reset the database:
164
-
165
- ```bash
166
- node op migration:reset
167
- ```
168
-
169
- Reset the database and run all migrations:
170
-
171
- ```bash
172
- node op migration:fresh
173
- ```
174
-
175
- ## Licence
176
-
177
- May be freely distributed under the MIT license.
178
-
179
- Copyright (c) 2023 Sallai András
12
+ See the docs directory for details.
@@ -1,10 +1,10 @@
1
1
  import Sequelize from 'sequelize'
2
- import dotenv from '@dotenvx/dotenvx'
2
+ import dotenvFlow from 'dotenv-flow'
3
3
 
4
4
  if (process.env.NODE_ENV === 'test') {
5
- dotenv.config({ path: '.env.test', quiet: true })
5
+ dotenv.config({ path: '.env.test' })
6
6
  }else {
7
- dotenv.config({ quiet: true })
7
+ dotenv.config()
8
8
  }
9
9
 
10
10
  const sequelize = new Sequelize(
@@ -1,7 +1,7 @@
1
1
  import app from './app.js'
2
- import dotenv from '@dotenvx/dotenvx'
2
+ import dotenvFlow from 'dotenv-flow'
3
3
 
4
- dotenv.config({ quiet: true })
4
+ dotenv.config()
5
5
 
6
6
  const PORT = process.env.APP_PORT || 8000
7
7
 
@@ -1,6 +1,6 @@
1
1
  import jwt from 'jsonwebtoken';
2
- import dotenv from '@dotenvx/dotenvx'
3
- dotenv.config({ quiet: true })
2
+ import dotenvFlow from 'dotenv-flow';
3
+ dotenv.config()
4
4
 
5
5
  const verifyToken = (req, res, next) => {
6
6
  let authData = req.headers.authorization;
package/expressapi/op CHANGED
@@ -324,13 +324,6 @@ async function startGenerateAdmin() {
324
324
  const { default: User } = await import('./app/models/user.js')
325
325
  await User.sync()
326
326
 
327
- await import('dotenv').then((dotenv) => dotenv.config())
328
- const isMemoryDb = process.env.DB_PATH === ':memory:';
329
- if(isMemoryDb) {
330
- console.log('Admin cannot be created in memory db!')
331
- return;
332
- }
333
-
334
327
  const isUserExist = await User.findOne({ where: { name: 'admin' } })
335
328
  if (isUserExist) {
336
329
  console.log('Admin already exists!')
@@ -12,6 +12,7 @@
12
12
  "@dotenvx/dotenvx": "^1.51.0",
13
13
  "bcryptjs": "^2.4.3",
14
14
  "cors": "^2.8.5",
15
+ "dotenv-flow": "^4.1.0",
15
16
  "express": "^4.18.2",
16
17
  "generate-api-key": "^1.0.2",
17
18
  "jsonwebtoken": "^9.0.0",
@@ -1394,6 +1395,30 @@
1394
1395
  "url": "https://dotenvx.com"
1395
1396
  }
1396
1397
  },
1398
+ "node_modules/dotenv-flow": {
1399
+ "version": "4.1.0",
1400
+ "resolved": "https://registry.npmjs.org/dotenv-flow/-/dotenv-flow-4.1.0.tgz",
1401
+ "integrity": "sha512-0cwP9jpQBQfyHwvE0cRhraZMkdV45TQedA8AAUZMsFzvmLcQyc1HPv+oX0OOYwLFjIlvgVepQ+WuQHbqDaHJZg==",
1402
+ "license": "MIT",
1403
+ "dependencies": {
1404
+ "dotenv": "^16.0.0"
1405
+ },
1406
+ "engines": {
1407
+ "node": ">= 12.0.0"
1408
+ }
1409
+ },
1410
+ "node_modules/dotenv-flow/node_modules/dotenv": {
1411
+ "version": "16.6.1",
1412
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
1413
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
1414
+ "license": "BSD-2-Clause",
1415
+ "engines": {
1416
+ "node": ">=12"
1417
+ },
1418
+ "funding": {
1419
+ "url": "https://dotenvx.com"
1420
+ }
1421
+ },
1397
1422
  "node_modules/dottie": {
1398
1423
  "version": "2.0.6",
1399
1424
  "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.6.tgz",
@@ -5,7 +5,7 @@
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "NODE_ENV=test mocha",
8
- "dev": "nodemon app --watch app --watch config",
8
+ "dev": "nodemon app",
9
9
  "start": "node app"
10
10
  },
11
11
  "keywords": [
@@ -18,6 +18,7 @@
18
18
  "@dotenvx/dotenvx": "^1.51.0",
19
19
  "bcryptjs": "^2.4.3",
20
20
  "cors": "^2.8.5",
21
+ "dotenv-flow": "^4.1.0",
21
22
  "express": "^4.18.2",
22
23
  "generate-api-key": "^1.0.2",
23
24
  "jsonwebtoken": "^9.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sip",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "main": "index.js",
5
5
  "bin": {
6
6
  "create-sip": "create-sip.js"