@anthonylzq/simba.js 4.0.0 → 4.3.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 +14 -9
- package/lib/src/functions/api.js +159 -119
- package/lib/src/index.js +3 -3
- package/lib/src/utils/titleCase.js +1 -1
- package/package.json +16 -6
package/README.md
CHANGED
|
@@ -136,9 +136,8 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
136
136
|
┃ ┗ 📜index.ts
|
|
137
137
|
┣ 📂network
|
|
138
138
|
┃ ┣ 📂routes
|
|
139
|
-
┃ ┃ ┣ 📂
|
|
140
|
-
┃ ┃ ┃
|
|
141
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
139
|
+
┃ ┃ ┣ 📂utils
|
|
140
|
+
┃ ┃ ┃ ┗ 📜docs.ts
|
|
142
141
|
┃ ┃ ┣ 📜home.ts
|
|
143
142
|
┃ ┃ ┣ 📜index.ts
|
|
144
143
|
┃ ┃ ┗ 📜user.ts
|
|
@@ -146,6 +145,9 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
146
145
|
┃ ┣ 📜response.ts
|
|
147
146
|
┃ ┣ 📜routes.ts
|
|
148
147
|
┃ ┗ 📜server.ts
|
|
148
|
+
┣ 📂schemas
|
|
149
|
+
┃ ┣ 📜index.ts
|
|
150
|
+
┃ ┗ 📜user.ts
|
|
149
151
|
┣ 📂services
|
|
150
152
|
┃ ┣ 📂utils
|
|
151
153
|
┃ ┃ ┣ 📂messages
|
|
@@ -183,8 +185,6 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
183
185
|
📂node_modules
|
|
184
186
|
📂src
|
|
185
187
|
┣ 📂@types
|
|
186
|
-
┃ ┣ 📂dto
|
|
187
|
-
┃ ┃ ┗ 📜user.d.ts
|
|
188
188
|
┃ ┣ 📂models
|
|
189
189
|
┃ ┃ ┗ 📜user.d.ts
|
|
190
190
|
┃ ┗ 📜index.d.ts
|
|
@@ -200,9 +200,8 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
200
200
|
┃ ┗ 📜index.ts
|
|
201
201
|
┣ 📂network
|
|
202
202
|
┃ ┣ 📂routes
|
|
203
|
-
┃ ┃ ┣ 📂
|
|
204
|
-
┃ ┃ ┃
|
|
205
|
-
┃ ┃ ┃ ┗ 📜user.ts
|
|
203
|
+
┃ ┃ ┣ 📂utils
|
|
204
|
+
┃ ┃ ┃ ┗ 📜docs.ts
|
|
206
205
|
┃ ┃ ┣ 📜docs.ts
|
|
207
206
|
┃ ┃ ┣ 📜home.ts
|
|
208
207
|
┃ ┃ ┣ 📜index.ts
|
|
@@ -211,6 +210,9 @@ Regardless of the option chosen, a new folder will be generated with the name of
|
|
|
211
210
|
┃ ┣ 📜response.ts
|
|
212
211
|
┃ ┣ 📜routes.ts
|
|
213
212
|
┃ ┗ 📜server.ts
|
|
213
|
+
┣ 📂schemas
|
|
214
|
+
┃ ┣ 📜index.ts
|
|
215
|
+
┃ ┗ 📜user.ts
|
|
214
216
|
┣ 📂services
|
|
215
217
|
┃ ┣ 📂utils
|
|
216
218
|
┃ ┃ ┣ 📂messages
|
|
@@ -331,12 +333,14 @@ As `dependencies`:
|
|
|
331
333
|
As `devDependencies`:
|
|
332
334
|
|
|
333
335
|
- [`@types/express`](https://www.npmjs.com/package/@types/express)
|
|
336
|
+
- [`@types/cors`](https://www.npmjs.com/package/@types/cors)
|
|
334
337
|
- [`@types/morgan`](https://www.npmjs.com/package/@types/morgan)
|
|
335
338
|
- [`@types/swagger-ui-express`](https://www.npmjs.com/package/@types/swagger-ui-express)
|
|
336
339
|
|
|
337
340
|
As `dependencies`:
|
|
338
341
|
|
|
339
|
-
- [`
|
|
342
|
+
- [`cors`](https://www.npmjs.com/package/cors)
|
|
343
|
+
- [`express`](https://www.npmjs.com/package/express)
|
|
340
344
|
- [`morgan`](https://www.npmjs.com/package/morgan)
|
|
341
345
|
- [`swagger-ui-express`](https://www.npmjs.com/package/swagger-ui-express)
|
|
342
346
|
|
|
@@ -345,6 +349,7 @@ As `dependencies`:
|
|
|
345
349
|
As `dependencies`:
|
|
346
350
|
|
|
347
351
|
- [`fastify`](https://www.npmjs.com/package/fastify)
|
|
352
|
+
- [`fastify-cors`](https://www.npmjs.com/package/fastify-cors)
|
|
348
353
|
- [`fastify-swagger`](https://www.npmjs.com/package/fastify-swagger)
|
|
349
354
|
|
|
350
355
|
Feel free to contribute to this project. Every contribution will be appreciated.
|
package/lib/src/functions/api.js
CHANGED
|
@@ -121,17 +121,6 @@ export {}
|
|
|
121
121
|
file: `${projectName}/src/@types/index.d.ts`
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
|
-
'@types/dto': {
|
|
125
|
-
user: {
|
|
126
|
-
content: `interface UserDTO {
|
|
127
|
-
id: string
|
|
128
|
-
lastName: string
|
|
129
|
-
name: string
|
|
130
|
-
}
|
|
131
|
-
`,
|
|
132
|
-
file: `${projectName}/src/@types/dto/user.d.ts`
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
124
|
'@types/models': {
|
|
136
125
|
user: {
|
|
137
126
|
content: `interface UserDBO {
|
|
@@ -661,26 +650,27 @@ export { applyRoutes }
|
|
|
661
650
|
content: `import express from 'express'
|
|
662
651
|
import mongoose from 'mongoose'
|
|
663
652
|
import morgan from 'morgan'
|
|
653
|
+
import cors from 'cors'
|
|
664
654
|
|
|
665
655
|
import { applyRoutes } from './router'
|
|
666
656
|
|
|
667
657
|
const PORT = (process.env.PORT as string) || '1996'
|
|
668
658
|
|
|
669
659
|
class Server {
|
|
670
|
-
|
|
671
|
-
|
|
660
|
+
#app: express.Application
|
|
661
|
+
#connection: mongoose.Connection | undefined
|
|
672
662
|
|
|
673
663
|
constructor() {
|
|
674
|
-
this
|
|
675
|
-
this
|
|
664
|
+
this.#app = express()
|
|
665
|
+
this.#config()
|
|
676
666
|
}
|
|
677
667
|
|
|
678
|
-
|
|
679
|
-
this.
|
|
680
|
-
this.
|
|
681
|
-
this.
|
|
682
|
-
this.
|
|
683
|
-
this.
|
|
668
|
+
#config() {
|
|
669
|
+
this.#app.use(cors())
|
|
670
|
+
this.#app.use(morgan('dev'))
|
|
671
|
+
this.#app.use(express.json())
|
|
672
|
+
this.#app.use(express.urlencoded({ extended: false }))
|
|
673
|
+
this.#app.use(
|
|
684
674
|
(
|
|
685
675
|
req: express.Request,
|
|
686
676
|
res: express.Response,
|
|
@@ -696,23 +686,23 @@ class Server {
|
|
|
696
686
|
}
|
|
697
687
|
)
|
|
698
688
|
|
|
699
|
-
applyRoutes(this
|
|
689
|
+
applyRoutes(this.#app)
|
|
700
690
|
}
|
|
701
691
|
|
|
702
|
-
|
|
703
|
-
this
|
|
692
|
+
async #mongo(): Promise<void> {
|
|
693
|
+
this.#connection = mongoose.connection
|
|
704
694
|
const connection = {
|
|
705
695
|
keepAlive: true,
|
|
706
696
|
useNewUrlParser: true,
|
|
707
697
|
useUnifiedTopology: true
|
|
708
698
|
}
|
|
709
|
-
this.
|
|
699
|
+
this.#connection.on('connected', () => {
|
|
710
700
|
console.log('Mongo connection established.')
|
|
711
701
|
})
|
|
712
|
-
this.
|
|
702
|
+
this.#connection.on('reconnected', () => {
|
|
713
703
|
console.log('Mongo connection reestablished')
|
|
714
704
|
})
|
|
715
|
-
this.
|
|
705
|
+
this.#connection.on('disconnected', () => {
|
|
716
706
|
console.log('Mongo connection disconnected')
|
|
717
707
|
console.log('Trying to reconnected to Mongo...')
|
|
718
708
|
setTimeout(() => {
|
|
@@ -723,10 +713,10 @@ class Server {
|
|
|
723
713
|
})
|
|
724
714
|
}, 3000)
|
|
725
715
|
})
|
|
726
|
-
this.
|
|
716
|
+
this.#connection.on('close', () => {
|
|
727
717
|
console.log('Mongo connection closed')
|
|
728
718
|
})
|
|
729
|
-
this.
|
|
719
|
+
this.#connection.on('error', (e: Error) => {
|
|
730
720
|
console.log('Mongo connection error:')
|
|
731
721
|
console.error(e)
|
|
732
722
|
})
|
|
@@ -734,12 +724,12 @@ class Server {
|
|
|
734
724
|
}
|
|
735
725
|
|
|
736
726
|
public start(): void {
|
|
737
|
-
this.
|
|
727
|
+
this.#app.listen(PORT, () => {
|
|
738
728
|
console.log(\`Server running at port \${PORT}\`)
|
|
739
729
|
})
|
|
740
730
|
|
|
741
731
|
try {
|
|
742
|
-
this
|
|
732
|
+
this.#mongo()
|
|
743
733
|
} catch (e) {
|
|
744
734
|
console.error(e)
|
|
745
735
|
}
|
|
@@ -781,7 +771,7 @@ export * from './user'
|
|
|
781
771
|
file: `${projectName}/src/network/routes/index.ts`
|
|
782
772
|
},
|
|
783
773
|
user: {
|
|
784
|
-
content: `import { Router } from 'express'
|
|
774
|
+
content: `import { NextFunction, Router } from 'express'
|
|
785
775
|
|
|
786
776
|
import { response } from 'network/response'
|
|
787
777
|
import { UserService } from 'services'
|
|
@@ -793,70 +783,122 @@ const User = Router()
|
|
|
793
783
|
User.route('/users')
|
|
794
784
|
.post(
|
|
795
785
|
validatorCompiler(storeUserSchema, 'body'),
|
|
796
|
-
async (
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
786
|
+
async (
|
|
787
|
+
req: CustomRequest,
|
|
788
|
+
res: CustomResponse,
|
|
789
|
+
next: NextFunction
|
|
790
|
+
): Promise<void> => {
|
|
791
|
+
try {
|
|
792
|
+
const {
|
|
793
|
+
body: { args }
|
|
794
|
+
} = req
|
|
795
|
+
const us = new UserService({ userDtoWithoutId: args })
|
|
796
|
+
const result = await us.process({ type: 'store' })
|
|
797
|
+
|
|
798
|
+
response({ error: false, message: result, res, status: 201 })
|
|
799
|
+
} catch (error) {
|
|
800
|
+
next(error)
|
|
801
|
+
}
|
|
804
802
|
}
|
|
805
803
|
)
|
|
806
|
-
.get(
|
|
807
|
-
|
|
808
|
-
|
|
804
|
+
.get(
|
|
805
|
+
async (
|
|
806
|
+
req: CustomRequest,
|
|
807
|
+
res: CustomResponse,
|
|
808
|
+
next: NextFunction
|
|
809
|
+
): Promise<void> => {
|
|
810
|
+
try {
|
|
811
|
+
const us = new UserService()
|
|
812
|
+
const result = await us.process({ type: 'getAll' })
|
|
809
813
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
814
|
+
response({ error: false, message: result, res, status: 200 })
|
|
815
|
+
} catch (error) {
|
|
816
|
+
next(error)
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
)
|
|
820
|
+
.delete(
|
|
821
|
+
async (
|
|
822
|
+
req: CustomRequest,
|
|
823
|
+
res: CustomResponse,
|
|
824
|
+
next: NextFunction
|
|
825
|
+
): Promise<void> => {
|
|
826
|
+
try {
|
|
827
|
+
const us = new UserService()
|
|
828
|
+
const result = await us.process({ type: 'deleteAll' })
|
|
815
829
|
|
|
816
|
-
|
|
817
|
-
|
|
830
|
+
response({ error: false, message: result, res, status: 200 })
|
|
831
|
+
} catch (error) {
|
|
832
|
+
next(error)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
)
|
|
818
836
|
|
|
819
837
|
User.route('/user/:id')
|
|
820
838
|
.get(
|
|
821
839
|
validatorCompiler(idSchema, 'params'),
|
|
822
|
-
async (
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
840
|
+
async (
|
|
841
|
+
req: CustomRequest,
|
|
842
|
+
res: CustomResponse,
|
|
843
|
+
next: NextFunction
|
|
844
|
+
): Promise<void> => {
|
|
845
|
+
try {
|
|
846
|
+
const {
|
|
847
|
+
params: { id }
|
|
848
|
+
} = req
|
|
849
|
+
const us = new UserService({ id })
|
|
850
|
+
const result = await us.process({ type: 'getOne' })
|
|
851
|
+
|
|
852
|
+
response({ error: false, message: result, res, status: 200 })
|
|
853
|
+
} catch (error) {
|
|
854
|
+
next(error)
|
|
855
|
+
}
|
|
830
856
|
}
|
|
831
857
|
)
|
|
832
858
|
.patch(
|
|
833
859
|
validatorCompiler(idSchema, 'params'),
|
|
834
860
|
validatorCompiler(storeUserSchema, 'body'),
|
|
835
|
-
async (
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
861
|
+
async (
|
|
862
|
+
req: CustomRequest,
|
|
863
|
+
res: CustomResponse,
|
|
864
|
+
next: NextFunction
|
|
865
|
+
): Promise<void> => {
|
|
866
|
+
try {
|
|
867
|
+
const {
|
|
868
|
+
body: { args },
|
|
869
|
+
params: { id }
|
|
870
|
+
} = req
|
|
871
|
+
const userDto = {
|
|
872
|
+
id,
|
|
873
|
+
...args
|
|
874
|
+
} as UserDTO
|
|
875
|
+
const us = new UserService({ userDto })
|
|
876
|
+
const result = await us.process({ type: 'update' })
|
|
877
|
+
|
|
878
|
+
response({ error: false, message: result, res, status: 200 })
|
|
879
|
+
} catch (error) {
|
|
880
|
+
next(error)
|
|
881
|
+
}
|
|
848
882
|
}
|
|
849
883
|
)
|
|
850
884
|
.delete(
|
|
851
885
|
validatorCompiler(idSchema, 'params'),
|
|
852
|
-
async (
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
886
|
+
async (
|
|
887
|
+
req: CustomRequest,
|
|
888
|
+
res: CustomResponse,
|
|
889
|
+
next: NextFunction
|
|
890
|
+
): Promise<void> => {
|
|
891
|
+
try {
|
|
892
|
+
const {
|
|
893
|
+
params: { id }
|
|
894
|
+
} = req
|
|
895
|
+
const us = new UserService({ id })
|
|
896
|
+
const result = await us.process({ type: 'delete' })
|
|
897
|
+
|
|
898
|
+
response({ error: false, message: result, res, status: 200 })
|
|
899
|
+
} catch (error) {
|
|
900
|
+
next(error)
|
|
901
|
+
}
|
|
860
902
|
}
|
|
861
903
|
)
|
|
862
904
|
|
|
@@ -1397,24 +1439,26 @@ export { applyRoutes }
|
|
|
1397
1439
|
file: `${projectName}/src/network/router.ts`
|
|
1398
1440
|
},
|
|
1399
1441
|
server: {
|
|
1400
|
-
content: `import
|
|
1442
|
+
content: `import fastify, { FastifyInstance } from 'fastify'
|
|
1401
1443
|
import mongoose from 'mongoose'
|
|
1402
1444
|
|
|
1403
1445
|
import { applyRoutes } from './router'
|
|
1446
|
+
import { validatorCompiler } from './utils'
|
|
1404
1447
|
|
|
1405
1448
|
const PORT = process.env.PORT ?? '1996'
|
|
1406
1449
|
|
|
1407
1450
|
class Server {
|
|
1408
|
-
|
|
1409
|
-
|
|
1451
|
+
#app: FastifyInstance
|
|
1452
|
+
#connection: mongoose.Connection | undefined
|
|
1410
1453
|
|
|
1411
1454
|
constructor() {
|
|
1412
|
-
this
|
|
1413
|
-
this
|
|
1455
|
+
this.#app = fastify({ logger: { prettyPrint: true } })
|
|
1456
|
+
this.#config()
|
|
1414
1457
|
}
|
|
1415
1458
|
|
|
1416
|
-
|
|
1417
|
-
this.
|
|
1459
|
+
#config() {
|
|
1460
|
+
this.#app.register(require('fastify-cors'), {})
|
|
1461
|
+
this.#app.addHook('preHandler', (req, reply, done) => {
|
|
1418
1462
|
reply.header('Access-Control-Allow-Methods', 'GET, POST, PATCH, DELETE')
|
|
1419
1463
|
reply.header('Access-Control-Allow-Origin', '*')
|
|
1420
1464
|
reply.header(
|
|
@@ -1423,25 +1467,26 @@ class Server {
|
|
|
1423
1467
|
)
|
|
1424
1468
|
done()
|
|
1425
1469
|
})
|
|
1426
|
-
|
|
1470
|
+
this.#app.setValidatorCompiler(validatorCompiler)
|
|
1471
|
+
applyRoutes(this.#app)
|
|
1427
1472
|
}
|
|
1428
1473
|
|
|
1429
|
-
|
|
1430
|
-
this
|
|
1474
|
+
async #mongo(): Promise<void> {
|
|
1475
|
+
this.#connection = mongoose.connection
|
|
1431
1476
|
const connection = {
|
|
1432
1477
|
keepAlive: true,
|
|
1433
1478
|
useNewUrlParser: true,
|
|
1434
1479
|
useUnifiedTopology: true
|
|
1435
1480
|
}
|
|
1436
|
-
this.
|
|
1437
|
-
this.
|
|
1481
|
+
this.#connection.on('connected', () => {
|
|
1482
|
+
this.#app.log.info('Mongo connection established.')
|
|
1438
1483
|
})
|
|
1439
|
-
this.
|
|
1440
|
-
this.
|
|
1484
|
+
this.#connection.on('reconnected', () => {
|
|
1485
|
+
this.#app.log.info('Mongo connection reestablished')
|
|
1441
1486
|
})
|
|
1442
|
-
this.
|
|
1443
|
-
this.
|
|
1444
|
-
this.
|
|
1487
|
+
this.#connection.on('disconnected', () => {
|
|
1488
|
+
this.#app.log.info('Mongo connection disconnected')
|
|
1489
|
+
this.#app.log.info('Trying to reconnected to Mongo...')
|
|
1445
1490
|
setTimeout(() => {
|
|
1446
1491
|
mongoose.connect(process.env.MONGO_URI as string, {
|
|
1447
1492
|
...connection,
|
|
@@ -1450,20 +1495,20 @@ class Server {
|
|
|
1450
1495
|
})
|
|
1451
1496
|
}, 3000)
|
|
1452
1497
|
})
|
|
1453
|
-
this.
|
|
1454
|
-
this.
|
|
1498
|
+
this.#connection.on('close', () => {
|
|
1499
|
+
this.#app.log.info('Mongo connection closed')
|
|
1455
1500
|
})
|
|
1456
|
-
this.
|
|
1457
|
-
this.
|
|
1458
|
-
this.
|
|
1501
|
+
this.#connection.on('error', (e: Error) => {
|
|
1502
|
+
this.#app.log.info('Mongo connection error:')
|
|
1503
|
+
this.#app.log.error(e)
|
|
1459
1504
|
})
|
|
1460
1505
|
await mongoose.connect(process.env.MONGO_URI as string, connection)
|
|
1461
1506
|
}
|
|
1462
1507
|
|
|
1463
1508
|
public async start(): Promise<void> {
|
|
1464
1509
|
try {
|
|
1465
|
-
await this.
|
|
1466
|
-
this
|
|
1510
|
+
await this.#app.listen(PORT)
|
|
1511
|
+
this.#mongo()
|
|
1467
1512
|
} catch (e) {
|
|
1468
1513
|
console.error(e)
|
|
1469
1514
|
}
|
|
@@ -1558,7 +1603,6 @@ import {
|
|
|
1558
1603
|
StoreUser
|
|
1559
1604
|
} from 'schemas'
|
|
1560
1605
|
import { UserService } from 'services'
|
|
1561
|
-
import { validatorCompiler } from './utils'
|
|
1562
1606
|
|
|
1563
1607
|
const User = (app: FastifyInstance, prefix = '/api'): void => {
|
|
1564
1608
|
app
|
|
@@ -1576,8 +1620,7 @@ const User = (app: FastifyInstance, prefix = '/api'): void => {
|
|
|
1576
1620
|
}
|
|
1577
1621
|
},
|
|
1578
1622
|
tags: ['user']
|
|
1579
|
-
}
|
|
1580
|
-
validatorCompiler
|
|
1623
|
+
}
|
|
1581
1624
|
},
|
|
1582
1625
|
async (request, reply) => {
|
|
1583
1626
|
const {
|
|
@@ -1668,8 +1711,7 @@ const User = (app: FastifyInstance, prefix = '/api'): void => {
|
|
|
1668
1711
|
}
|
|
1669
1712
|
},
|
|
1670
1713
|
tags: ['user']
|
|
1671
|
-
}
|
|
1672
|
-
validatorCompiler
|
|
1714
|
+
}
|
|
1673
1715
|
},
|
|
1674
1716
|
async (request, reply) => {
|
|
1675
1717
|
const {
|
|
@@ -1763,7 +1805,7 @@ export { User }
|
|
|
1763
1805
|
file: `${projectName}/src/network/routes/user.ts`
|
|
1764
1806
|
}
|
|
1765
1807
|
},
|
|
1766
|
-
'network/
|
|
1808
|
+
'network/utils': {
|
|
1767
1809
|
index: {
|
|
1768
1810
|
content: `/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1769
1811
|
import {
|
|
@@ -1801,17 +1843,19 @@ const validatorCompiler = ({
|
|
|
1801
1843
|
|
|
1802
1844
|
export { validatorCompiler }
|
|
1803
1845
|
`,
|
|
1804
|
-
file: `${projectName}/src/network/
|
|
1846
|
+
file: `${projectName}/src/network/utils/index.ts`
|
|
1805
1847
|
}
|
|
1806
1848
|
}
|
|
1807
1849
|
}
|
|
1808
1850
|
|
|
1809
1851
|
const expressFolders = `${projectName}/src/utils \
|
|
1810
|
-
${projectName}/src/@types/custom
|
|
1852
|
+
${projectName}/src/@types/custom \
|
|
1853
|
+
${projectName}/src/network/routes/utils`
|
|
1854
|
+
|
|
1855
|
+
const fastifyFolders = `${projectName}/src/network/utils`
|
|
1811
1856
|
|
|
1812
1857
|
const createFoldersCommands = `mkdir ${projectName}/src \
|
|
1813
1858
|
${projectName}/src/@types \
|
|
1814
|
-
${projectName}/src/@types/dto \
|
|
1815
1859
|
${projectName}/src/@types/models \
|
|
1816
1860
|
${projectName}/src/database \
|
|
1817
1861
|
${projectName}/src/database/mongo \
|
|
@@ -1819,12 +1863,11 @@ ${projectName}/src/database/mongo/models \
|
|
|
1819
1863
|
${projectName}/src/database/mongo/queries \
|
|
1820
1864
|
${projectName}/src/network \
|
|
1821
1865
|
${projectName}/src/network/routes \
|
|
1822
|
-
${projectName}/src/network/routes/utils \
|
|
1823
1866
|
${projectName}/src/schemas \
|
|
1824
1867
|
${projectName}/src/services \
|
|
1825
1868
|
${projectName}/src/services/utils \
|
|
1826
1869
|
${projectName}/src/services/utils/messages \
|
|
1827
|
-
${fastify ?
|
|
1870
|
+
${fastify ? `${fastifyFolders}` : `${expressFolders}`}
|
|
1828
1871
|
`
|
|
1829
1872
|
|
|
1830
1873
|
if (os.platform() === 'win32')
|
|
@@ -1834,9 +1877,6 @@ ${fastify ? '' : `${expressFolders}`}
|
|
|
1834
1877
|
// /@types
|
|
1835
1878
|
await writeFile(data['@types'].index.file, data['@types'].index.content)
|
|
1836
1879
|
|
|
1837
|
-
// /@types/dto
|
|
1838
|
-
await writeFile(data['@types/dto'].user.file, data['@types/dto'].user.content)
|
|
1839
|
-
|
|
1840
1880
|
// /@types/models
|
|
1841
1881
|
await writeFile(
|
|
1842
1882
|
data['@types/models'].user.file,
|
|
@@ -1937,8 +1977,8 @@ ${fastify ? '' : `${expressFolders}`}
|
|
|
1937
1977
|
|
|
1938
1978
|
// /network/routes/utils
|
|
1939
1979
|
await writeFile(
|
|
1940
|
-
fastifyData['network/
|
|
1941
|
-
fastifyData['network/
|
|
1980
|
+
fastifyData['network/utils'].index.file,
|
|
1981
|
+
fastifyData['network/utils'].index.content
|
|
1942
1982
|
)
|
|
1943
1983
|
} else {
|
|
1944
1984
|
// /@types/custom
|
package/lib/src/index.js
CHANGED
|
@@ -57,13 +57,13 @@ module.exports = async ({
|
|
|
57
57
|
cliProgress.Presets.shades_classic
|
|
58
58
|
)
|
|
59
59
|
|
|
60
|
-
const expressProdPackages = 'express morgan swagger-ui-express'
|
|
61
|
-
const fastifyProdPackages = 'fastify fastify-swagger'
|
|
60
|
+
const expressProdPackages = 'express morgan swagger-ui-express cors'
|
|
61
|
+
const fastifyProdPackages = 'fastify fastify-swagger fastify-cors pino-pretty'
|
|
62
62
|
const prodPackages = `${manager} http-errors mongoose @sinclair/typebox ajv@^6 ${
|
|
63
63
|
fastify ? fastifyProdPackages : expressProdPackages
|
|
64
64
|
}`
|
|
65
65
|
|
|
66
|
-
const expressDevPackages = `@types/express @types/morgan @types/swagger-ui-express`
|
|
66
|
+
const expressDevPackages = `@types/express @types/morgan @types/swagger-ui-express @types/cors`
|
|
67
67
|
const fastifyDevPackages = ''
|
|
68
68
|
const devPackages = `${manager} -D \
|
|
69
69
|
@types/http-errors \
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"description": "set up a modern backend app by running one command",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"directories": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"rm-fastify": "if [ -d \"example/fastify\" ]; then rm -rf example/fastify; fi",
|
|
20
20
|
"rm-git-express": "if [ -d \"example/express/.git\" ]; then rm -rf example/express/.git; fi",
|
|
21
21
|
"rm-git-fastify": "if [ -d \"example/fastify/.git\" ]; then rm -rf example/fastify/.git; fi",
|
|
22
|
-
"cd-mv-example": "if [ ! -d \"example\" ]; then mkdir example && cd example; fi"
|
|
22
|
+
"cd-mv-example": "if [ ! -d \"example\" ]; then mkdir example && cd example; fi",
|
|
23
|
+
"version": "npm run release && git add CHANGELOG.md"
|
|
23
24
|
},
|
|
24
25
|
"bin": {
|
|
25
26
|
"simba": "./bin/index.js"
|
|
@@ -41,16 +42,18 @@
|
|
|
41
42
|
"colors": "^1.4.0",
|
|
42
43
|
"readline-sync": "^1.4.10",
|
|
43
44
|
"underscore": "^1.13.2",
|
|
44
|
-
"yargs": "^17.
|
|
45
|
+
"yargs": "^17.4.1"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"dotenv": "^16.0.0",
|
|
48
|
-
"eslint": "^8.
|
|
49
|
+
"eslint": "^8.13.0",
|
|
49
50
|
"eslint-config-prettier": "^8.5.0",
|
|
50
51
|
"eslint-config-standard": "^16.0.3",
|
|
51
|
-
"eslint-plugin-import": "^2.
|
|
52
|
+
"eslint-plugin-import": "^2.26.0",
|
|
52
53
|
"eslint-plugin-node": "^11.1.0",
|
|
53
54
|
"eslint-plugin-prettier": "^4.0.0",
|
|
55
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
56
|
+
"prettier": "^2.6.2",
|
|
54
57
|
"standard-version": "^9.3.2"
|
|
55
58
|
},
|
|
56
59
|
"repository": {
|
|
@@ -64,5 +67,12 @@
|
|
|
64
67
|
"files": [
|
|
65
68
|
"lib",
|
|
66
69
|
"bin"
|
|
67
|
-
]
|
|
70
|
+
],
|
|
71
|
+
"standard-version": {
|
|
72
|
+
"skip": {
|
|
73
|
+
"tag": true,
|
|
74
|
+
"commit": true,
|
|
75
|
+
"bump": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
68
78
|
}
|