@anthonylzq/simba.js 4.3.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/lib/src/functions/api.js +100 -48
- package/package.json +11 -3
package/lib/src/functions/api.js
CHANGED
|
@@ -771,7 +771,7 @@ export * from './user'
|
|
|
771
771
|
file: `${projectName}/src/network/routes/index.ts`
|
|
772
772
|
},
|
|
773
773
|
user: {
|
|
774
|
-
content: `import { Router } from 'express'
|
|
774
|
+
content: `import { NextFunction, Router } from 'express'
|
|
775
775
|
|
|
776
776
|
import { response } from 'network/response'
|
|
777
777
|
import { UserService } from 'services'
|
|
@@ -783,70 +783,122 @@ const User = Router()
|
|
|
783
783
|
User.route('/users')
|
|
784
784
|
.post(
|
|
785
785
|
validatorCompiler(storeUserSchema, 'body'),
|
|
786
|
-
async (
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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
|
+
}
|
|
794
802
|
}
|
|
795
803
|
)
|
|
796
|
-
.get(
|
|
797
|
-
|
|
798
|
-
|
|
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' })
|
|
799
813
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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' })
|
|
805
829
|
|
|
806
|
-
|
|
807
|
-
|
|
830
|
+
response({ error: false, message: result, res, status: 200 })
|
|
831
|
+
} catch (error) {
|
|
832
|
+
next(error)
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
)
|
|
808
836
|
|
|
809
837
|
User.route('/user/:id')
|
|
810
838
|
.get(
|
|
811
839
|
validatorCompiler(idSchema, 'params'),
|
|
812
|
-
async (
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
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
|
+
}
|
|
820
856
|
}
|
|
821
857
|
)
|
|
822
858
|
.patch(
|
|
823
859
|
validatorCompiler(idSchema, 'params'),
|
|
824
860
|
validatorCompiler(storeUserSchema, 'body'),
|
|
825
|
-
async (
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
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
|
+
}
|
|
838
882
|
}
|
|
839
883
|
)
|
|
840
884
|
.delete(
|
|
841
885
|
validatorCompiler(idSchema, 'params'),
|
|
842
|
-
async (
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
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
|
+
}
|
|
850
902
|
}
|
|
851
903
|
)
|
|
852
904
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anthonylzq/simba.js",
|
|
3
|
-
"version": "4.3.
|
|
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"
|
|
@@ -66,5 +67,12 @@
|
|
|
66
67
|
"files": [
|
|
67
68
|
"lib",
|
|
68
69
|
"bin"
|
|
69
|
-
]
|
|
70
|
+
],
|
|
71
|
+
"standard-version": {
|
|
72
|
+
"skip": {
|
|
73
|
+
"tag": true,
|
|
74
|
+
"commit": true,
|
|
75
|
+
"bump": true
|
|
76
|
+
}
|
|
77
|
+
}
|
|
70
78
|
}
|