@anthonylzq/simba.js 1.9.0 → 2.0.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/README.md +53 -25
- package/lib/src/functions/docker.js +2 -2
- package/lib/src/functions/eslint.js +2 -1
- package/lib/src/functions/express.js +458 -350
- package/lib/src/functions/tsconfig.js +38 -8
- package/lib/src/installation.js +1 -3
- package/package.json +8 -4
- package/CHANGELOG.md +0 -117
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Set up a modern backend app by running one command. This project has the goal to
|
|
|
6
6
|
|
|
7
7
|
- `.env`
|
|
8
8
|
- `.eslintignore`
|
|
9
|
-
- `.eslintrc
|
|
9
|
+
- `.eslintrc`
|
|
10
10
|
- `.gitignore`
|
|
11
11
|
- `CHANGELOG.md`
|
|
12
12
|
- `Dockerfile`
|
|
@@ -15,15 +15,17 @@ Set up a modern backend app by running one command. This project has the goal to
|
|
|
15
15
|
- `nodemon.json`
|
|
16
16
|
- `package.json`
|
|
17
17
|
- `README.md`
|
|
18
|
+
- `tsconfig.base.json`
|
|
18
19
|
- `tsconfig.json`
|
|
19
20
|
- `webpack.config.js`
|
|
21
|
+
- `yarn.lock` (or `package-lock.json`)
|
|
20
22
|
|
|
21
23
|
## Installation
|
|
22
24
|
|
|
23
25
|
This package is meant to be installed globally in your computer by using:
|
|
24
26
|
|
|
25
27
|
```bash
|
|
26
|
-
npm i -g simba.js
|
|
28
|
+
npm i -g @anthonylzq/simba.js
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
## Usage
|
|
@@ -95,34 +97,56 @@ Developed by AnthonyLzq
|
|
|
95
97
|
Regardless of the option chosen, a new folder will be generated with the name of the project, it will contain the following structure:
|
|
96
98
|
|
|
97
99
|
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
📂node_modules
|
|
101
|
+
📂src
|
|
100
102
|
┣ 📂@types
|
|
101
|
-
┃ ┣
|
|
102
|
-
┣
|
|
103
|
-
┃
|
|
104
|
-
┃
|
|
105
|
-
|
|
106
|
-
┃ ┣
|
|
107
|
-
┃ ┗ 📜user.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
┃
|
|
103
|
+
┃ ┣ 📂custom
|
|
104
|
+
┃ ┃ ┣ 📜request.d.ts
|
|
105
|
+
┃ ┃ ┗ 📜response.d.ts
|
|
106
|
+
┃ ┣ 📂dto
|
|
107
|
+
┃ ┃ ┗ 📜user.d.ts
|
|
108
|
+
┃ ┣ 📂models
|
|
109
|
+
┃ ┃ ┗ 📜user.d.ts
|
|
110
|
+
┃ ┗ 📜index.d.ts
|
|
111
|
+
┣ 📂database
|
|
112
|
+
┃ ┣ 📂mongo
|
|
113
|
+
┃ ┃ ┣ 📂models
|
|
114
|
+
┃ ┃ ┃ ┣ 📜index.ts
|
|
115
|
+
┃ ┃ ┃ ┗ 📜user.ts
|
|
116
|
+
┃ ┃ ┣ 📂queries
|
|
117
|
+
┃ ┃ ┃ ┣ 📜index.ts
|
|
118
|
+
┃ ┃ ┃ ┗ 📜user.ts
|
|
119
|
+
┃ ┃ ┗ 📜index.ts
|
|
120
|
+
┃ ┗ 📜index.ts
|
|
111
121
|
┣ 📂network
|
|
122
|
+
┃ ┣ 📂routes
|
|
123
|
+
┃ ┃ ┣ 📂schemas
|
|
124
|
+
┃ ┃ ┃ ┣ 📜index.ts
|
|
125
|
+
┃ ┃ ┃ ┗ 📜user.ts
|
|
126
|
+
┃ ┃ ┣ 📜home.ts
|
|
127
|
+
┃ ┃ ┣ 📜index.ts
|
|
128
|
+
┃ ┃ ┗ 📜user.ts
|
|
112
129
|
┃ ┣ 📜index.ts
|
|
130
|
+
┃ ┣ 📜response.ts
|
|
113
131
|
┃ ┣ 📜routes.ts
|
|
114
132
|
┃ ┗ 📜server.ts
|
|
115
|
-
┣ 📂
|
|
116
|
-
┃ ┣
|
|
133
|
+
┣ 📂services
|
|
134
|
+
┃ ┣ 📂utils
|
|
135
|
+
┃ ┃ ┣ 📂messages
|
|
136
|
+
┃ ┃ ┃ ┣ 📜index.ts
|
|
137
|
+
┃ ┃ ┃ ┗ 📜user.ts
|
|
138
|
+
┃ ┃ ┗ 📜index.ts
|
|
117
139
|
┃ ┣ 📜index.ts
|
|
118
140
|
┃ ┗ 📜user.ts
|
|
141
|
+
┣ 📂test
|
|
142
|
+
┃ ┗ 📜test.http
|
|
119
143
|
┣ 📂utils
|
|
120
|
-
┃ ┣ 📜
|
|
121
|
-
┃ ┗ 📜
|
|
144
|
+
┃ ┣ 📜docs.json
|
|
145
|
+
┃ ┗ 📜index.ts
|
|
122
146
|
┗ 📜index.ts
|
|
123
147
|
📜.env
|
|
124
148
|
📜.eslintignore
|
|
125
|
-
📜.eslintrc
|
|
149
|
+
📜.eslintrc
|
|
126
150
|
📜.gitignore
|
|
127
151
|
📜CHANGELOG.md
|
|
128
152
|
📜Dockerfile
|
|
@@ -131,6 +155,7 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
131
155
|
📜nodemon.json
|
|
132
156
|
📜package.json
|
|
133
157
|
📜README.md
|
|
158
|
+
📜tsconfig.base.json
|
|
134
159
|
📜tsconfig.json
|
|
135
160
|
📜webpack.config.js
|
|
136
161
|
📜yarn.lock (or package-lock.json)
|
|
@@ -160,8 +185,8 @@ simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
|
|
|
160
185
|
|
|
161
186
|
### Some considerations
|
|
162
187
|
|
|
163
|
-
- This project
|
|
164
|
-
- You are able to run a server that has one main route, `home` (`/`), `user` (`api/user` or `api/user/:
|
|
188
|
+
- This project was based in other project from my own, [`typescript-project-generator`](https://www.npmjs.com/package/typescript-project-generator), but only considering the `express-mongoose` part.
|
|
189
|
+
- You are able to run a server that has one main route, `home` (`/`), `user` (`api/user` or `api/user/:id`) and `docs` (`api/docs`).
|
|
165
190
|
- To connect your server with your `MongoDB` database, you need to provide your `uri` in the `.env`. By default, Simba will try to connect to a local database. The content of the `.env` file is:
|
|
166
191
|
|
|
167
192
|
```bash
|
|
@@ -182,11 +207,16 @@ simba -N myProject -D 'This is a test' -a myName -e myEmail@email.com -H
|
|
|
182
207
|
// Some more code...
|
|
183
208
|
|
|
184
209
|
// another file
|
|
185
|
-
globalStringVariable = 'Hi mom, I am global'
|
|
210
|
+
global.globalStringVariable = 'Hi mom, I am global'
|
|
186
211
|
console.log({ globalStringVariable })
|
|
187
212
|
```
|
|
188
213
|
|
|
189
|
-
- The provided project structure is inspired in my personal experience as [`Node.js`](https://nodejs.org/en/) developer and the [`Nest`](https://nestjs.com/) framework.
|
|
214
|
+
- The provided project structure is inspired in my personal experience as [`Node.js`](https://nodejs.org/en/) developer and the [`Nest`](https://nestjs.com/) framework. It follows a layered architecture:
|
|
215
|
+
|
|
216
|
+
1. Presentation layer (network layer): it is represented by the network folder, which contains the routes and the necessary schemas for each route.
|
|
217
|
+
2. Business layer (services layer): it is represented by the services folder, which contains all the code related to the business logic of your application.
|
|
218
|
+
3. Persistance layer (database layer): it is represented by the database folder, which contains the database connection, models and queries (that will be used by the services). Multiple database connection are possible and should be implemented here.
|
|
219
|
+
|
|
190
220
|
- The server is fully tested and has no errors (at least for now), feel free to report one [here](https://github.com/AnthonyLzq/simba.js/issues).
|
|
191
221
|
- Support for windows and linux platforms is available.
|
|
192
222
|
- To check the content of the files generated, please check the `example` folder.
|
|
@@ -215,8 +245,6 @@ Here is the list of the packages that are being installed, as `devDependencies`:
|
|
|
215
245
|
- [`eslint-config-standard`](https://www.npmjs.com/package/eslint-config-standard)
|
|
216
246
|
- [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import)
|
|
217
247
|
- [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier)
|
|
218
|
-
- [`eslint-plugin-sort-keys-fix`](https://www.npmjs.com/package/eslint-plugin-sort-keys-fix)
|
|
219
|
-
- [`eslint-plugin-typescript-sort-keys`](https://www.npmjs.com/package/eslint-plugin-typescript-sort-keys)
|
|
220
248
|
- [`nodemon`](https://www.npmjs.com/package/nodemon)
|
|
221
249
|
- [`prettier`](https://www.npmjs.com/package/prettier)
|
|
222
250
|
- [`standard-version`](https://www.npmjs.com/package/standard-version)
|
|
@@ -14,11 +14,11 @@ COPY package.json ./
|
|
|
14
14
|
|
|
15
15
|
RUN yarn install --prod
|
|
16
16
|
|
|
17
|
-
RUN yarn add webpack webpack-node-externals -D
|
|
17
|
+
RUN yarn add webpack webpack-node-externals tsconfig-paths-webpack-plugin -D
|
|
18
18
|
|
|
19
19
|
RUN yarn build
|
|
20
20
|
|
|
21
|
-
RUN yarn remove webpack webpack-node-externals
|
|
21
|
+
RUN yarn remove webpack webpack-node-externals tsconfig-paths-webpack-plugin
|
|
22
22
|
|
|
23
23
|
COPY dist /app/dist
|
|
24
24
|
|
|
@@ -54,6 +54,7 @@ module.exports = async projectName => {
|
|
|
54
54
|
],
|
|
55
55
|
'newline-before-return': 'error',
|
|
56
56
|
'object-curly-spacing': ['error', 'always'],
|
|
57
|
+
"object-shorthand": ["error", "always"],
|
|
57
58
|
'prefer-const': 'error',
|
|
58
59
|
'prettier/prettier': [
|
|
59
60
|
'error',
|
|
@@ -73,7 +74,7 @@ module.exports = async projectName => {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
`,
|
|
76
|
-
eslintFile: '.eslintrc
|
|
77
|
+
eslintFile: '.eslintrc',
|
|
77
78
|
eslintIgnoreContent: '/dist',
|
|
78
79
|
eslintIgnoreFile: '.eslintignore'
|
|
79
80
|
}
|