@anthonylzq/simba.js 7.0.2 → 7.1.0
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.
|
@@ -124,7 +124,7 @@ import { HttpLogger } from 'express-pino-logger'
|
|
|
124
124
|
|
|
125
125
|
const ENVIRONMENTS_WITHOUT_RECONNECTION = ['ci', 'local']
|
|
126
126
|
const dbConnection = async (
|
|
127
|
-
logger
|
|
127
|
+
logger?: HttpLogger['logger']
|
|
128
128
|
): Promise<{
|
|
129
129
|
connect: () => Promise<typeof import('mongoose')>
|
|
130
130
|
disconnect: () => Promise<void>
|
|
@@ -136,10 +136,10 @@ const dbConnection = async (
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
connection.on('connected', () => {
|
|
139
|
-
logger
|
|
139
|
+
logger?.info('Mongo connection established.')
|
|
140
140
|
})
|
|
141
141
|
connection.on('reconnected', () => {
|
|
142
|
-
logger
|
|
142
|
+
logger?.info('Mongo connection reestablished')
|
|
143
143
|
})
|
|
144
144
|
connection.on('disconnected', () => {
|
|
145
145
|
if (
|
|
@@ -147,7 +147,7 @@ const dbConnection = async (
|
|
|
147
147
|
process.env.NODE_ENV as string
|
|
148
148
|
)
|
|
149
149
|
) {
|
|
150
|
-
logger
|
|
150
|
+
logger?.info(
|
|
151
151
|
'Mongo connection disconnected. Trying to reconnected to Mongo...'
|
|
152
152
|
)
|
|
153
153
|
setTimeout(() => {
|
|
@@ -160,11 +160,11 @@ const dbConnection = async (
|
|
|
160
160
|
}
|
|
161
161
|
})
|
|
162
162
|
connection.on('close', () => {
|
|
163
|
-
logger
|
|
163
|
+
logger?.info('Mongo connection closed')
|
|
164
164
|
})
|
|
165
165
|
connection.on('error', (e: Error) => {
|
|
166
|
-
logger
|
|
167
|
-
logger
|
|
166
|
+
logger?.info('Mongo connection error:')
|
|
167
|
+
logger?.error(e)
|
|
168
168
|
})
|
|
169
169
|
|
|
170
170
|
return {
|
|
@@ -91,7 +91,7 @@ import { FastifyLoggerInstance } from 'fastify'
|
|
|
91
91
|
|
|
92
92
|
const ENVIRONMENTS_WITHOUT_RECONNECTION = ['ci', 'local']
|
|
93
93
|
const dbConnection = async (
|
|
94
|
-
logger
|
|
94
|
+
logger?: FastifyLoggerInstance
|
|
95
95
|
): Promise<{
|
|
96
96
|
connect: () => Promise<typeof import('mongoose')>
|
|
97
97
|
disconnect: () => Promise<void>
|
|
@@ -103,10 +103,10 @@ const dbConnection = async (
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
connection.on('connected', () => {
|
|
106
|
-
logger
|
|
106
|
+
logger?.info('Mongo connection established.')
|
|
107
107
|
})
|
|
108
108
|
connection.on('reconnected', () => {
|
|
109
|
-
logger
|
|
109
|
+
logger?.info('Mongo connection reestablished')
|
|
110
110
|
})
|
|
111
111
|
connection.on('disconnected', () => {
|
|
112
112
|
if (
|
|
@@ -114,7 +114,7 @@ const dbConnection = async (
|
|
|
114
114
|
process.env.NODE_ENV as string
|
|
115
115
|
)
|
|
116
116
|
) {
|
|
117
|
-
logger
|
|
117
|
+
logger?.info(
|
|
118
118
|
'Mongo connection disconnected. Trying to reconnected to Mongo...'
|
|
119
119
|
)
|
|
120
120
|
setTimeout(() => {
|
|
@@ -127,11 +127,11 @@ const dbConnection = async (
|
|
|
127
127
|
}
|
|
128
128
|
})
|
|
129
129
|
connection.on('close', () => {
|
|
130
|
-
logger
|
|
130
|
+
logger?.info('Mongo connection closed')
|
|
131
131
|
})
|
|
132
132
|
connection.on('error', (e: Error) => {
|
|
133
|
-
logger
|
|
134
|
-
logger
|
|
133
|
+
logger?.info('Mongo connection error:')
|
|
134
|
+
logger?.error(e)
|
|
135
135
|
})
|
|
136
136
|
|
|
137
137
|
return {
|
|
@@ -336,7 +336,7 @@ import * as models from './models'
|
|
|
336
336
|
let sequelize: Sequelize
|
|
337
337
|
|
|
338
338
|
const dbConnection = async (
|
|
339
|
-
logger
|
|
339
|
+
logger?: FastifyLoggerInstance
|
|
340
340
|
): Promise<{
|
|
341
341
|
connect: () => Promise<Sequelize>
|
|
342
342
|
disconnect: () => Promise<void>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
api: require('./api'),
|
|
3
|
+
changelog: require('./changelog'),
|
|
4
|
+
docker: require('./docker'),
|
|
5
|
+
eslint: require('./eslint'),
|
|
6
|
+
ghat: require('./ghat'),
|
|
7
|
+
gitignore: require('./gitignore'),
|
|
8
|
+
herokuF: require('./heroku'),
|
|
9
|
+
licenseF: require('./license'),
|
|
10
|
+
packageJson: require('./packageJson'),
|
|
11
|
+
readme: require('./readme'),
|
|
12
|
+
testsF: require('./tests'),
|
|
13
|
+
tsconfig: require('./tsconfig'),
|
|
14
|
+
ghatF: require('./ghat'),
|
|
15
|
+
webpack: require('./webpack')
|
|
16
|
+
}
|
|
@@ -47,7 +47,18 @@ module.exports = async ({
|
|
|
47
47
|
: ''
|
|
48
48
|
}
|
|
49
49
|
"dependencies": {},
|
|
50
|
-
"devDependencies": {}
|
|
50
|
+
"devDependencies": {},
|
|
51
|
+
"nodemonConfig": {
|
|
52
|
+
"watch": [
|
|
53
|
+
".env",
|
|
54
|
+
"src"
|
|
55
|
+
],
|
|
56
|
+
"ext": "ts",
|
|
57
|
+
"ignore": [
|
|
58
|
+
"src/**/*.test.ts"
|
|
59
|
+
],
|
|
60
|
+
"exec": "npx ts-node -r dotenv/config ./src/index"
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
63
|
`
|
|
53
64
|
await writeFile(`${projectName}/${data.file}`, data.content)
|
package/lib/src/index.js
CHANGED
|
@@ -3,20 +3,21 @@ const colors = require('colors')
|
|
|
3
3
|
const util = require('util')
|
|
4
4
|
const exec = util.promisify(require('child_process').exec)
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
const {
|
|
7
|
+
packageJson,
|
|
8
|
+
readme,
|
|
9
|
+
changelog,
|
|
10
|
+
licenseF,
|
|
11
|
+
gitignore,
|
|
12
|
+
tsconfig,
|
|
13
|
+
eslint,
|
|
14
|
+
webpack,
|
|
15
|
+
docker,
|
|
16
|
+
herokuF,
|
|
17
|
+
api,
|
|
18
|
+
testsF,
|
|
19
|
+
ghatF
|
|
20
|
+
} = require('./functions')
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @param {Number} process number of process
|
|
@@ -159,7 +160,6 @@ webpack-node-externals`
|
|
|
159
160
|
changelog(projectName),
|
|
160
161
|
gitignore(projectName),
|
|
161
162
|
tsconfig(projectName, dbIsSQL),
|
|
162
|
-
nodemon(projectName),
|
|
163
163
|
eslint({ projectName, tests, dbIsSQL }),
|
|
164
164
|
webpack(projectName),
|
|
165
165
|
docker(projectName),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "set up a modern backend app by running one command",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -101,18 +101,18 @@
|
|
|
101
101
|
"cli-progress": "^3.11.2",
|
|
102
102
|
"colors": "^1.4.0",
|
|
103
103
|
"readline-sync": "^1.4.10",
|
|
104
|
-
"underscore": "^1.13.
|
|
105
|
-
"yargs": "^17.
|
|
104
|
+
"underscore": "^1.13.6",
|
|
105
|
+
"yargs": "^17.6.0"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"dotenv": "^16.0.
|
|
109
|
-
"eslint": "^8.
|
|
108
|
+
"dotenv": "^16.0.3",
|
|
109
|
+
"eslint": "^8.26.0",
|
|
110
110
|
"eslint-config-prettier": "^8.5.0",
|
|
111
111
|
"eslint-config-standard": "^17.0.0",
|
|
112
112
|
"eslint-plugin-import": "^2.26.0",
|
|
113
113
|
"eslint-plugin-node": "^11.1.0",
|
|
114
114
|
"eslint-plugin-prettier": "^4.2.1",
|
|
115
|
-
"eslint-plugin-promise": "^6.
|
|
115
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
116
116
|
"prettier": "^2.7.1",
|
|
117
117
|
"standard-version": "^9.5.0"
|
|
118
118
|
},
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const writeFile = require('../utils/writeFile')
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @param {String} projectName
|
|
5
|
-
* @returns {Promise<void>}
|
|
6
|
-
*/
|
|
7
|
-
module.exports = async projectName => {
|
|
8
|
-
const data = {
|
|
9
|
-
nodemonContent: `{
|
|
10
|
-
"watch": [
|
|
11
|
-
".env",
|
|
12
|
-
"src"
|
|
13
|
-
],
|
|
14
|
-
"ext": "ts",
|
|
15
|
-
"ignore": [
|
|
16
|
-
"src/**/*.test.ts"
|
|
17
|
-
],
|
|
18
|
-
"exec": "npx ts-node -r dotenv/config ./src/index"
|
|
19
|
-
}
|
|
20
|
-
`,
|
|
21
|
-
nodemonFile: 'nodemon.json'
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
await writeFile(`${projectName}/${data.nodemonFile}`, data.nodemonContent)
|
|
25
|
-
}
|