pwi-plata-type 0.4.166 → 0.4.167
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 +2 -2
- package/__BUILD__/libs/sql.js +4 -1
- package/__BUILD__/libs/sql.js.map +1 -1
- package/package.json +53 -53
- package/src/@types/build.d.ts +26 -26
- package/src/@types/cluster.actions.d.ts +27 -27
- package/src/@types/cluster.d.ts +55 -55
- package/src/@types/create-cli.d.ts +8 -8
- package/src/@types/exported.d.ts +31 -31
- package/src/@types/fs.d.ts +6 -6
- package/src/@types/global.d.ts +113 -113
- package/src/@types/knex.d.ts +13 -13
- package/src/@types/model.d.ts +143 -143
- package/src/@types/router.d.ts +107 -107
- package/src/@types/sql.d.ts +75 -75
- package/src/@types/swagger.d.ts +22 -22
- package/src/bin/extras/create-api-cli.ts +218 -218
- package/src/bin/extras/create-cluster-cli.ts +160 -160
- package/src/bin/extras/create-lib-cli.ts +84 -84
- package/src/bin/extras/plata-create-tools.ts +97 -97
- package/src/bin/plata-api.ts +189 -189
- package/src/bin/plata-build.ts +17 -17
- package/src/bin/plata-cluster.ts +42 -42
- package/src/bin/plata-cmd.ts +18 -18
- package/src/bin/plata-create.ts +49 -49
- package/src/bin/plata-runtime.ts +131 -131
- package/src/bin/plata-swagger.ts +99 -99
- package/src/bin/runtime/_setupRuntime.ts +48 -48
- package/src/bin/runtime/_types.d.ts +7 -7
- package/src/bin/runtime/class.ts +20 -20
- package/src/bin/runtime/dirs.ts +25 -25
- package/src/bin/runtime/effect.ts +60 -60
- package/src/bin/runtime/fs.ts +10 -10
- package/src/bin/runtime/promises.ts +18 -18
- package/src/bin/runtime/require.ts +113 -113
- package/src/bin/runtime/sql.ts +12 -12
- package/src/bin/runtime/switch.ts +60 -60
- package/src/index.ts +19 -19
- package/src/libs/axios.ts +51 -51
- package/src/libs/build.ts +162 -162
- package/src/libs/cluster/cluster-controller.ts +93 -93
- package/src/libs/cluster.ts +330 -330
- package/src/libs/custom.ts +15 -15
- package/src/libs/env.ts +10 -10
- package/src/libs/fs.ts +399 -399
- package/src/libs/hot-reload.ts +63 -63
- package/src/libs/models/index.ts +4 -4
- package/src/libs/models/model-template-combine.ts +93 -93
- package/src/libs/models/model-template-env.ts +58 -58
- package/src/libs/models/model-template-union.ts +83 -83
- package/src/libs/models/model-template.ts +107 -107
- package/src/libs/models/model-validations.ts +443 -443
- package/src/libs/models/tools.ts +194 -194
- package/src/libs/router.ts +185 -185
- package/src/libs/sql.ts +792 -788
- package/src/libs/swagger.ts +81 -81
- package/src/libs/tools.ts +240 -240
- package/src/scripts/post-install/api.ts +32 -32
- package/src/scripts/post-install/cluster.ts +28 -28
- package/src/scripts/post-install/lib.ts +25 -25
- package/src/scripts/post-install.ts +64 -64
- package/src/scripts/pre-test.ts +33 -33
- package/src/tests/assets/sql/example.sql +76 -76
- package/src/tests/config.test.ts +12 -12
- package/src/tests/effect.test.ts +62 -62
- package/src/tests/model.env.test.ts +66 -66
- package/src/tests/model.test.ts +141 -141
- package/src/tests/model.union.test.ts +160 -160
- package/src/tests/router.test.ts +44 -44
- package/src/tests/sql.test.ts +502 -502
- package/src/tests/switch.test.ts +76 -76
- package/templates/create-cli/class.ts +13 -13
- package/templates/create-cli/cluster.ts +14 -14
- package/templates/create-cli/cmd.ts +3 -3
- package/templates/create-cli/config.ts +2 -2
- package/templates/create-cli/lib.ts +3 -3
- package/templates/create-cli/model.ts +14 -14
- package/templates/create-cli/route.ts +8 -8
- package/templates/create-cli/task.ts +13 -13
- package/templates/postinstall/api/.vscode/launch.json +20 -20
- package/templates/postinstall/api/Dockerfile +24 -24
- package/templates/postinstall/api/configs/env.ts +2 -2
- package/templates/postinstall/api/envs/debug.env +15 -15
- package/templates/postinstall/api/envs/homolog.env +15 -15
- package/templates/postinstall/api/envs/prod.env +15 -15
- package/templates/postinstall/api/tsconfig.json +24 -24
- package/templates/postinstall/cluster/.vscode/launch.json +20 -20
- package/templates/postinstall/cluster/Dockerfile +24 -24
- package/templates/postinstall/cluster/configs/env.ts +2 -2
- package/templates/postinstall/cluster/envs/debug.env +10 -10
- package/templates/postinstall/cluster/envs/homolog.env +10 -10
- package/templates/postinstall/cluster/envs/prod.env +10 -10
- package/templates/postinstall/cluster/tsconfig.json +24 -24
- package/templates/postinstall/lib/postinstall-tools.mjs +111 -111
- package/templates/postinstall/lib/postinstall.js +33 -33
- package/templates/postinstall/lib/tsconfig.json +22 -22
- package/templates/swagger-cli/header.json +21 -21
- package/templates/swagger-cli/route/body.json +14 -14
- package/templates/swagger-cli/route/header.json +18 -18
- package/templates/swagger-cli/route/response.json +53 -53
- package/tsconfig.json +28 -28
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import { describe, it, before } from "node:test"
|
|
2
|
-
import assert from "node:assert"
|
|
3
|
-
import { loadRuntimeLibs } from "../bin/runtime/_setupRuntime"
|
|
4
|
-
import { PlataModels } from ".."
|
|
5
|
-
|
|
6
|
-
describe('PlataModels.union', () => {
|
|
7
|
-
const plataPromise = (async () => {
|
|
8
|
-
const g = global as any
|
|
9
|
-
|
|
10
|
-
g.Plata = await loadRuntimeLibs()
|
|
11
|
-
})()
|
|
12
|
-
|
|
13
|
-
before(async () => {
|
|
14
|
-
await plataPromise
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const modelTemplateEnv = new PlataModels.ModelTemplateEnv({
|
|
18
|
-
test_union: [ PlataModels.Required(), PlataModels.VarChar(Infinity) ],
|
|
19
|
-
ENV_enum: [ PlataModels.Enum([ 0, 1 ]) ],
|
|
20
|
-
ENV_decimal: [ PlataModels.Decimal(2,2) ],
|
|
21
|
-
ENV_intMin: [ PlataModels.Int(5) ],
|
|
22
|
-
ENV_intMax: [ PlataModels.Int(undefined, 5) ],
|
|
23
|
-
ENV_intRequired: [ PlataModels.Required(), PlataModels.Int() ],
|
|
24
|
-
ENV_smallDateTime: [ PlataModels.SmallDateTime() ],
|
|
25
|
-
ENV_varChar: [ PlataModels.VarChar(1) ],
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
const modelTemplate = new PlataModels.ModelTemplate({
|
|
29
|
-
test_union: [ PlataModels.Required(), PlataModels.VarChar(Infinity) ],
|
|
30
|
-
enum: [ PlataModels.Enum([ 0,1 ]) ],
|
|
31
|
-
stringDateTime: [ PlataModels.StringDateTime() ],
|
|
32
|
-
dateTime: [ PlataModels.DateTime() ],
|
|
33
|
-
decimal: [ PlataModels.Decimal(2,2) ],
|
|
34
|
-
intMin: [ PlataModels.Int(5) ],
|
|
35
|
-
intMax: [ PlataModels.Int(undefined, 5) ],
|
|
36
|
-
intRequired: [ PlataModels.Required(), PlataModels.Int() ],
|
|
37
|
-
smallDateTime: [ PlataModels.SmallDateTime() ],
|
|
38
|
-
telefone: [ PlataModels.Telefone() ],
|
|
39
|
-
telefoneDDI: [ PlataModels.TelefoneDDI() ],
|
|
40
|
-
varCharMin: [ PlataModels.VarChar(1, 1) ],
|
|
41
|
-
varChar: [ PlataModels.VarChar(1) ],
|
|
42
|
-
} as const, {})
|
|
43
|
-
|
|
44
|
-
const modelUnion = new PlataModels.ModelTemplateUnion({ key: 'key' }, {
|
|
45
|
-
modelTemplate,
|
|
46
|
-
modelTemplateEnv,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
modelUnion.addFilter(x => {
|
|
50
|
-
x.test_union = x.test_union === true ? '1' : null
|
|
51
|
-
|
|
52
|
-
return x
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const getTemplateOkay = () => ({
|
|
56
|
-
test_union: true,
|
|
57
|
-
key: 'modelTemplate',
|
|
58
|
-
enum: 0,
|
|
59
|
-
stringDateTime: '2022-12-04T02:06:22',
|
|
60
|
-
dateTime: new Date(),
|
|
61
|
-
decimal: 99.99,
|
|
62
|
-
intMin: 5,
|
|
63
|
-
intMax: 5,
|
|
64
|
-
intRequired: 1,
|
|
65
|
-
smallDateTime: '2022-12-04',
|
|
66
|
-
telefone: '99-999999999',
|
|
67
|
-
telefoneDDI: '+055 99-999999999',
|
|
68
|
-
varCharMin: '1',
|
|
69
|
-
varChar: '1',
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const getTemplateNotOkay = () => ({
|
|
73
|
-
key: 'modelTemplate',
|
|
74
|
-
test_union: false,
|
|
75
|
-
enum: 2,
|
|
76
|
-
stringDateTime: '',
|
|
77
|
-
dateTime: '',
|
|
78
|
-
decimal: 5.666666666666,
|
|
79
|
-
intMin: 1,
|
|
80
|
-
intMax: 6,
|
|
81
|
-
intRequired: null,
|
|
82
|
-
smallDateTime: '',
|
|
83
|
-
telefone: '',
|
|
84
|
-
telefoneDDI: '',
|
|
85
|
-
varCharMin: '',
|
|
86
|
-
varChar: '11',
|
|
87
|
-
}) as any // Forced just for test
|
|
88
|
-
|
|
89
|
-
const getEnvOkay = () => ({
|
|
90
|
-
key: 'modelTemplateEnv',
|
|
91
|
-
test_union: true,
|
|
92
|
-
ENV_enum: `${0}`,
|
|
93
|
-
ENV_decimal: `${22.22}`,
|
|
94
|
-
ENV_intMin: `${5}`,
|
|
95
|
-
ENV_intMax: `${5}`,
|
|
96
|
-
ENV_intRequired: `${6}`,
|
|
97
|
-
ENV_smallDateTime: '2022-12-04',
|
|
98
|
-
ENV_varChar: '1',
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const getEnvNotOkay = () => ({
|
|
102
|
-
key: 'modelTemplateEnv',
|
|
103
|
-
test_union: false,
|
|
104
|
-
ENV_enum: `${2}`,
|
|
105
|
-
ENV_decimal: `${222.222}`,
|
|
106
|
-
ENV_intMin: `${4}`,
|
|
107
|
-
ENV_intMax: `${6}`,
|
|
108
|
-
ENV_smallDateTime: '2022-12--04',
|
|
109
|
-
ENV_varChar: '12',
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('Validations Env (Okay)', async () => {
|
|
113
|
-
const okayObj = getEnvOkay()
|
|
114
|
-
|
|
115
|
-
const value = await modelUnion.validate(okayObj)
|
|
116
|
-
|
|
117
|
-
assert.strictEqual(value.errors, undefined)
|
|
118
|
-
|
|
119
|
-
const type: { key: 'modelTemplateEnv' | 'modelTemplate'} = value.value
|
|
120
|
-
|
|
121
|
-
assert.deepEqual(value.value, okayObj)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it('Validations Template (Okay)', async () => {
|
|
125
|
-
const okayObj = getTemplateOkay()
|
|
126
|
-
|
|
127
|
-
const value = await modelUnion.validate(okayObj)
|
|
128
|
-
|
|
129
|
-
assert.strictEqual(value.errors, undefined)
|
|
130
|
-
|
|
131
|
-
const type: { key: 'modelTemplateEnv' | 'modelTemplate'} = value.value
|
|
132
|
-
|
|
133
|
-
assert.deepEqual(value.value, okayObj)
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
it('Validations Env (Not Okay)', async () => {
|
|
137
|
-
const notOkayObj = getEnvNotOkay()
|
|
138
|
-
|
|
139
|
-
const value = await modelUnion.validate(notOkayObj)
|
|
140
|
-
|
|
141
|
-
assert.notStrictEqual(value.errors, undefined)
|
|
142
|
-
assert.strictEqual(
|
|
143
|
-
value.errors?.length,
|
|
144
|
-
Object.keys(modelTemplateEnv.template).length,
|
|
145
|
-
value.errors?.map(e => `${e.errorID} - ${e.msg}`).join('\n')
|
|
146
|
-
)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('Validations Template (Not Okay)', async () => {
|
|
150
|
-
const notOkayObj = getTemplateNotOkay()
|
|
151
|
-
|
|
152
|
-
const value = await modelUnion.validate(notOkayObj)
|
|
153
|
-
|
|
154
|
-
assert.notStrictEqual(value.errors, undefined)
|
|
155
|
-
assert.strictEqual(
|
|
156
|
-
value.errors?.length,
|
|
157
|
-
Object.keys(modelTemplate.template).length,
|
|
158
|
-
value.errors?.map(e => `${e.errorID} - ${e.msg}`).join('\n')
|
|
159
|
-
)
|
|
160
|
-
})
|
|
1
|
+
import { describe, it, before } from "node:test"
|
|
2
|
+
import assert from "node:assert"
|
|
3
|
+
import { loadRuntimeLibs } from "../bin/runtime/_setupRuntime"
|
|
4
|
+
import { PlataModels } from ".."
|
|
5
|
+
|
|
6
|
+
describe('PlataModels.union', () => {
|
|
7
|
+
const plataPromise = (async () => {
|
|
8
|
+
const g = global as any
|
|
9
|
+
|
|
10
|
+
g.Plata = await loadRuntimeLibs()
|
|
11
|
+
})()
|
|
12
|
+
|
|
13
|
+
before(async () => {
|
|
14
|
+
await plataPromise
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const modelTemplateEnv = new PlataModels.ModelTemplateEnv({
|
|
18
|
+
test_union: [ PlataModels.Required(), PlataModels.VarChar(Infinity) ],
|
|
19
|
+
ENV_enum: [ PlataModels.Enum([ 0, 1 ]) ],
|
|
20
|
+
ENV_decimal: [ PlataModels.Decimal(2,2) ],
|
|
21
|
+
ENV_intMin: [ PlataModels.Int(5) ],
|
|
22
|
+
ENV_intMax: [ PlataModels.Int(undefined, 5) ],
|
|
23
|
+
ENV_intRequired: [ PlataModels.Required(), PlataModels.Int() ],
|
|
24
|
+
ENV_smallDateTime: [ PlataModels.SmallDateTime() ],
|
|
25
|
+
ENV_varChar: [ PlataModels.VarChar(1) ],
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const modelTemplate = new PlataModels.ModelTemplate({
|
|
29
|
+
test_union: [ PlataModels.Required(), PlataModels.VarChar(Infinity) ],
|
|
30
|
+
enum: [ PlataModels.Enum([ 0,1 ]) ],
|
|
31
|
+
stringDateTime: [ PlataModels.StringDateTime() ],
|
|
32
|
+
dateTime: [ PlataModels.DateTime() ],
|
|
33
|
+
decimal: [ PlataModels.Decimal(2,2) ],
|
|
34
|
+
intMin: [ PlataModels.Int(5) ],
|
|
35
|
+
intMax: [ PlataModels.Int(undefined, 5) ],
|
|
36
|
+
intRequired: [ PlataModels.Required(), PlataModels.Int() ],
|
|
37
|
+
smallDateTime: [ PlataModels.SmallDateTime() ],
|
|
38
|
+
telefone: [ PlataModels.Telefone() ],
|
|
39
|
+
telefoneDDI: [ PlataModels.TelefoneDDI() ],
|
|
40
|
+
varCharMin: [ PlataModels.VarChar(1, 1) ],
|
|
41
|
+
varChar: [ PlataModels.VarChar(1) ],
|
|
42
|
+
} as const, {})
|
|
43
|
+
|
|
44
|
+
const modelUnion = new PlataModels.ModelTemplateUnion({ key: 'key' }, {
|
|
45
|
+
modelTemplate,
|
|
46
|
+
modelTemplateEnv,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
modelUnion.addFilter(x => {
|
|
50
|
+
x.test_union = x.test_union === true ? '1' : null
|
|
51
|
+
|
|
52
|
+
return x
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const getTemplateOkay = () => ({
|
|
56
|
+
test_union: true,
|
|
57
|
+
key: 'modelTemplate',
|
|
58
|
+
enum: 0,
|
|
59
|
+
stringDateTime: '2022-12-04T02:06:22',
|
|
60
|
+
dateTime: new Date(),
|
|
61
|
+
decimal: 99.99,
|
|
62
|
+
intMin: 5,
|
|
63
|
+
intMax: 5,
|
|
64
|
+
intRequired: 1,
|
|
65
|
+
smallDateTime: '2022-12-04',
|
|
66
|
+
telefone: '99-999999999',
|
|
67
|
+
telefoneDDI: '+055 99-999999999',
|
|
68
|
+
varCharMin: '1',
|
|
69
|
+
varChar: '1',
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const getTemplateNotOkay = () => ({
|
|
73
|
+
key: 'modelTemplate',
|
|
74
|
+
test_union: false,
|
|
75
|
+
enum: 2,
|
|
76
|
+
stringDateTime: '',
|
|
77
|
+
dateTime: '',
|
|
78
|
+
decimal: 5.666666666666,
|
|
79
|
+
intMin: 1,
|
|
80
|
+
intMax: 6,
|
|
81
|
+
intRequired: null,
|
|
82
|
+
smallDateTime: '',
|
|
83
|
+
telefone: '',
|
|
84
|
+
telefoneDDI: '',
|
|
85
|
+
varCharMin: '',
|
|
86
|
+
varChar: '11',
|
|
87
|
+
}) as any // Forced just for test
|
|
88
|
+
|
|
89
|
+
const getEnvOkay = () => ({
|
|
90
|
+
key: 'modelTemplateEnv',
|
|
91
|
+
test_union: true,
|
|
92
|
+
ENV_enum: `${0}`,
|
|
93
|
+
ENV_decimal: `${22.22}`,
|
|
94
|
+
ENV_intMin: `${5}`,
|
|
95
|
+
ENV_intMax: `${5}`,
|
|
96
|
+
ENV_intRequired: `${6}`,
|
|
97
|
+
ENV_smallDateTime: '2022-12-04',
|
|
98
|
+
ENV_varChar: '1',
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const getEnvNotOkay = () => ({
|
|
102
|
+
key: 'modelTemplateEnv',
|
|
103
|
+
test_union: false,
|
|
104
|
+
ENV_enum: `${2}`,
|
|
105
|
+
ENV_decimal: `${222.222}`,
|
|
106
|
+
ENV_intMin: `${4}`,
|
|
107
|
+
ENV_intMax: `${6}`,
|
|
108
|
+
ENV_smallDateTime: '2022-12--04',
|
|
109
|
+
ENV_varChar: '12',
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('Validations Env (Okay)', async () => {
|
|
113
|
+
const okayObj = getEnvOkay()
|
|
114
|
+
|
|
115
|
+
const value = await modelUnion.validate(okayObj)
|
|
116
|
+
|
|
117
|
+
assert.strictEqual(value.errors, undefined)
|
|
118
|
+
|
|
119
|
+
const type: { key: 'modelTemplateEnv' | 'modelTemplate'} = value.value
|
|
120
|
+
|
|
121
|
+
assert.deepEqual(value.value, okayObj)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('Validations Template (Okay)', async () => {
|
|
125
|
+
const okayObj = getTemplateOkay()
|
|
126
|
+
|
|
127
|
+
const value = await modelUnion.validate(okayObj)
|
|
128
|
+
|
|
129
|
+
assert.strictEqual(value.errors, undefined)
|
|
130
|
+
|
|
131
|
+
const type: { key: 'modelTemplateEnv' | 'modelTemplate'} = value.value
|
|
132
|
+
|
|
133
|
+
assert.deepEqual(value.value, okayObj)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('Validations Env (Not Okay)', async () => {
|
|
137
|
+
const notOkayObj = getEnvNotOkay()
|
|
138
|
+
|
|
139
|
+
const value = await modelUnion.validate(notOkayObj)
|
|
140
|
+
|
|
141
|
+
assert.notStrictEqual(value.errors, undefined)
|
|
142
|
+
assert.strictEqual(
|
|
143
|
+
value.errors?.length,
|
|
144
|
+
Object.keys(modelTemplateEnv.template).length,
|
|
145
|
+
value.errors?.map(e => `${e.errorID} - ${e.msg}`).join('\n')
|
|
146
|
+
)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('Validations Template (Not Okay)', async () => {
|
|
150
|
+
const notOkayObj = getTemplateNotOkay()
|
|
151
|
+
|
|
152
|
+
const value = await modelUnion.validate(notOkayObj)
|
|
153
|
+
|
|
154
|
+
assert.notStrictEqual(value.errors, undefined)
|
|
155
|
+
assert.strictEqual(
|
|
156
|
+
value.errors?.length,
|
|
157
|
+
Object.keys(modelTemplate.template).length,
|
|
158
|
+
value.errors?.map(e => `${e.errorID} - ${e.msg}`).join('\n')
|
|
159
|
+
)
|
|
160
|
+
})
|
|
161
161
|
})
|
package/src/tests/router.test.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { describe, it, before } from "node:test"
|
|
2
|
-
import assert from "node:assert"
|
|
3
|
-
import { PlataRoutes } from ".."
|
|
4
|
-
import { loadRuntimeLibs } from "../bin/runtime/_setupRuntime"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
describe('Plata Switch', () => {
|
|
8
|
-
const plataPromise = (async () => {
|
|
9
|
-
const g = global as any
|
|
10
|
-
|
|
11
|
-
g.Plata = await loadRuntimeLibs()
|
|
12
|
-
})()
|
|
13
|
-
|
|
14
|
-
const exports = { default: async (r) => r }
|
|
15
|
-
|
|
16
|
-
before(async () => {
|
|
17
|
-
await plataPromise
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it('Ordem dos index', async () => {
|
|
21
|
-
const routes = PlataRoutes.processRoutes([
|
|
22
|
-
{
|
|
23
|
-
exports,
|
|
24
|
-
filePath: '/v1/controle/index.js',
|
|
25
|
-
name: 'index'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
exports,
|
|
29
|
-
filePath: '/v1/controle/update.js',
|
|
30
|
-
name: 'update'
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
exports,
|
|
34
|
-
filePath: '/v1/index.js',
|
|
35
|
-
name: 'index'
|
|
36
|
-
},
|
|
37
|
-
])
|
|
38
|
-
|
|
39
|
-
assert.deepStrictEqual(routes.map(r => r.httpRoute), [
|
|
40
|
-
'/v1/',
|
|
41
|
-
'/v1/controle/',
|
|
42
|
-
'/v1/controle/update',
|
|
43
|
-
])
|
|
44
|
-
})
|
|
1
|
+
import { describe, it, before } from "node:test"
|
|
2
|
+
import assert from "node:assert"
|
|
3
|
+
import { PlataRoutes } from ".."
|
|
4
|
+
import { loadRuntimeLibs } from "../bin/runtime/_setupRuntime"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
describe('Plata Switch', () => {
|
|
8
|
+
const plataPromise = (async () => {
|
|
9
|
+
const g = global as any
|
|
10
|
+
|
|
11
|
+
g.Plata = await loadRuntimeLibs()
|
|
12
|
+
})()
|
|
13
|
+
|
|
14
|
+
const exports = { default: async (r) => r }
|
|
15
|
+
|
|
16
|
+
before(async () => {
|
|
17
|
+
await plataPromise
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('Ordem dos index', async () => {
|
|
21
|
+
const routes = PlataRoutes.processRoutes([
|
|
22
|
+
{
|
|
23
|
+
exports,
|
|
24
|
+
filePath: '/v1/controle/index.js',
|
|
25
|
+
name: 'index'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
exports,
|
|
29
|
+
filePath: '/v1/controle/update.js',
|
|
30
|
+
name: 'update'
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
exports,
|
|
34
|
+
filePath: '/v1/index.js',
|
|
35
|
+
name: 'index'
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
|
|
39
|
+
assert.deepStrictEqual(routes.map(r => r.httpRoute), [
|
|
40
|
+
'/v1/',
|
|
41
|
+
'/v1/controle/',
|
|
42
|
+
'/v1/controle/update',
|
|
43
|
+
])
|
|
44
|
+
})
|
|
45
45
|
})
|