pwi-plata-type 0.4.165 → 0.4.166

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.
Files changed (101) hide show
  1. package/README.md +2 -2
  2. package/__BUILD__/libs/sql.js +11 -4
  3. package/__BUILD__/libs/sql.js.map +1 -1
  4. package/package.json +53 -53
  5. package/src/@types/build.d.ts +26 -26
  6. package/src/@types/cluster.actions.d.ts +27 -27
  7. package/src/@types/cluster.d.ts +55 -55
  8. package/src/@types/create-cli.d.ts +8 -8
  9. package/src/@types/exported.d.ts +31 -31
  10. package/src/@types/fs.d.ts +6 -6
  11. package/src/@types/global.d.ts +113 -113
  12. package/src/@types/knex.d.ts +13 -13
  13. package/src/@types/model.d.ts +143 -143
  14. package/src/@types/router.d.ts +107 -107
  15. package/src/@types/sql.d.ts +75 -75
  16. package/src/@types/swagger.d.ts +22 -22
  17. package/src/bin/extras/create-api-cli.ts +218 -218
  18. package/src/bin/extras/create-cluster-cli.ts +160 -160
  19. package/src/bin/extras/create-lib-cli.ts +84 -84
  20. package/src/bin/extras/plata-create-tools.ts +97 -97
  21. package/src/bin/plata-api.ts +189 -189
  22. package/src/bin/plata-build.ts +17 -17
  23. package/src/bin/plata-cluster.ts +42 -42
  24. package/src/bin/plata-cmd.ts +18 -18
  25. package/src/bin/plata-create.ts +49 -49
  26. package/src/bin/plata-runtime.ts +131 -131
  27. package/src/bin/plata-swagger.ts +99 -99
  28. package/src/bin/runtime/_setupRuntime.ts +48 -48
  29. package/src/bin/runtime/_types.d.ts +7 -7
  30. package/src/bin/runtime/class.ts +20 -20
  31. package/src/bin/runtime/dirs.ts +25 -25
  32. package/src/bin/runtime/effect.ts +60 -60
  33. package/src/bin/runtime/fs.ts +10 -10
  34. package/src/bin/runtime/promises.ts +18 -18
  35. package/src/bin/runtime/require.ts +113 -113
  36. package/src/bin/runtime/sql.ts +12 -12
  37. package/src/bin/runtime/switch.ts +60 -60
  38. package/src/index.ts +19 -19
  39. package/src/libs/axios.ts +51 -51
  40. package/src/libs/build.ts +162 -162
  41. package/src/libs/cluster/cluster-controller.ts +93 -93
  42. package/src/libs/cluster.ts +330 -330
  43. package/src/libs/custom.ts +15 -15
  44. package/src/libs/env.ts +10 -10
  45. package/src/libs/fs.ts +399 -399
  46. package/src/libs/hot-reload.ts +63 -63
  47. package/src/libs/models/index.ts +4 -4
  48. package/src/libs/models/model-template-combine.ts +93 -93
  49. package/src/libs/models/model-template-env.ts +58 -58
  50. package/src/libs/models/model-template-union.ts +83 -83
  51. package/src/libs/models/model-template.ts +107 -107
  52. package/src/libs/models/model-validations.ts +443 -443
  53. package/src/libs/models/tools.ts +194 -194
  54. package/src/libs/router.ts +185 -185
  55. package/src/libs/sql.ts +788 -778
  56. package/src/libs/swagger.ts +81 -81
  57. package/src/libs/tools.ts +240 -240
  58. package/src/scripts/post-install/api.ts +32 -32
  59. package/src/scripts/post-install/cluster.ts +28 -28
  60. package/src/scripts/post-install/lib.ts +25 -25
  61. package/src/scripts/post-install.ts +64 -64
  62. package/src/scripts/pre-test.ts +33 -33
  63. package/src/tests/assets/sql/example.sql +76 -76
  64. package/src/tests/config.test.ts +12 -12
  65. package/src/tests/effect.test.ts +62 -62
  66. package/src/tests/model.env.test.ts +66 -66
  67. package/src/tests/model.test.ts +141 -141
  68. package/src/tests/model.union.test.ts +160 -160
  69. package/src/tests/router.test.ts +44 -44
  70. package/src/tests/sql.test.ts +502 -502
  71. package/src/tests/switch.test.ts +76 -76
  72. package/templates/create-cli/class.ts +13 -13
  73. package/templates/create-cli/cluster.ts +14 -14
  74. package/templates/create-cli/cmd.ts +3 -3
  75. package/templates/create-cli/config.ts +2 -2
  76. package/templates/create-cli/lib.ts +3 -3
  77. package/templates/create-cli/model.ts +14 -14
  78. package/templates/create-cli/route.ts +8 -8
  79. package/templates/create-cli/task.ts +13 -13
  80. package/templates/postinstall/api/.vscode/launch.json +20 -20
  81. package/templates/postinstall/api/Dockerfile +24 -24
  82. package/templates/postinstall/api/configs/env.ts +2 -2
  83. package/templates/postinstall/api/envs/debug.env +15 -15
  84. package/templates/postinstall/api/envs/homolog.env +15 -15
  85. package/templates/postinstall/api/envs/prod.env +15 -15
  86. package/templates/postinstall/api/tsconfig.json +24 -24
  87. package/templates/postinstall/cluster/.vscode/launch.json +20 -20
  88. package/templates/postinstall/cluster/Dockerfile +24 -24
  89. package/templates/postinstall/cluster/configs/env.ts +2 -2
  90. package/templates/postinstall/cluster/envs/debug.env +10 -10
  91. package/templates/postinstall/cluster/envs/homolog.env +10 -10
  92. package/templates/postinstall/cluster/envs/prod.env +10 -10
  93. package/templates/postinstall/cluster/tsconfig.json +24 -24
  94. package/templates/postinstall/lib/postinstall-tools.mjs +111 -111
  95. package/templates/postinstall/lib/postinstall.js +33 -33
  96. package/templates/postinstall/lib/tsconfig.json +22 -22
  97. package/templates/swagger-cli/header.json +21 -21
  98. package/templates/swagger-cli/route/body.json +14 -14
  99. package/templates/swagger-cli/route/header.json +18 -18
  100. package/templates/swagger-cli/route/response.json +53 -53
  101. package/tsconfig.json +28 -28
@@ -1,98 +1,98 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
-
4
- import { PlataDirs, PlataFiles } from '../../libs/tools'
5
-
6
- export namespace tools {
7
- export namespace files {
8
- export async function mkdirIfNotExists(dir: string) {
9
- try {
10
- const p = path.resolve(dir)
11
-
12
- if (!fs.existsSync(p)) {
13
- fs.mkdirSync(p, { recursive: true })
14
- }
15
- } catch (err) {
16
- console.error(err)
17
- process.exit(1)
18
- }
19
- }
20
-
21
- export async function copyFileIfNotExists(source: string, destination: string) {
22
- try {
23
- const s = path.resolve(source)
24
- const d = path.resolve(destination)
25
-
26
- if (!fs.existsSync(d)) {
27
- fs.copyFileSync(s, d)
28
- }
29
- } catch (err) {
30
- console.error(err)
31
- process.exit(1)
32
- }
33
- }
34
-
35
- export async function copyFileToProject(projectFolder: string, templateFile: string, fileName: string): Promise<string> {
36
- const s = path.resolve(PlataDirs.getPlataTempleteDir('create-cli', `${templateFile}.ts`))
37
- let d = path.resolve(Plata.ProjectDir, projectFolder)
38
-
39
- await mkdirIfNotExists(d)
40
- d = path.join(d, fileName)
41
- await copyFileIfNotExists(s, d)
42
-
43
- return d
44
- }
45
-
46
- export async function deployFileToProject(projectFolder: string, templateFile: string, fileName: string, args: any) {
47
- const fileInProject = await copyFileToProject(projectFolder, templateFile, fileName)
48
-
49
- const content: any = await PlataFiles.readFileSync(fileInProject, (line) => {
50
- if (line === '//@ts-nocheck') {
51
- return ''
52
- }
53
-
54
- if (line === '') {
55
- return ''
56
- }
57
-
58
- // Procura por texto para subistituir esse texto que esta no formato ç__PARAMETRO__ç
59
- let lastIndex = 0
60
- while(lastIndex !== -1) {
61
- lastIndex = line.indexOf('$__', lastIndex)
62
-
63
- if (lastIndex !== -1) {
64
- const pIndex = line.indexOf('__$', lastIndex)
65
- const param = line.slice(lastIndex + 3, pIndex)
66
-
67
- line = line.replace(new RegExp(`\\$__${param}__\\$`, 'g'), args[param])
68
- }
69
- }
70
-
71
- return line
72
- })
73
-
74
- if (content.err !== undefined) {
75
- console.log(content.err)
76
- process.exit(1)
77
- } else {
78
- fs.writeFileSync(fileInProject, content)
79
- }
80
- }
81
- }
82
-
83
- export namespace args {
84
- export type argsCallBack = (command: string, args: string[]) => Promise<string[]>
85
-
86
- export async function forEachArg(callback: argsCallBack) {
87
- let args = process.argv.slice(process.argv.indexOf('--') + 1)
88
-
89
- while(args.length !== 0) {
90
- const command = args.shift()
91
-
92
- if (command !== undefined) {
93
- args = await callback(command, args)
94
- }
95
- }
96
- }
97
- }
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+
4
+ import { PlataDirs, PlataFiles } from '../../libs/tools'
5
+
6
+ export namespace tools {
7
+ export namespace files {
8
+ export async function mkdirIfNotExists(dir: string) {
9
+ try {
10
+ const p = path.resolve(dir)
11
+
12
+ if (!fs.existsSync(p)) {
13
+ fs.mkdirSync(p, { recursive: true })
14
+ }
15
+ } catch (err) {
16
+ console.error(err)
17
+ process.exit(1)
18
+ }
19
+ }
20
+
21
+ export async function copyFileIfNotExists(source: string, destination: string) {
22
+ try {
23
+ const s = path.resolve(source)
24
+ const d = path.resolve(destination)
25
+
26
+ if (!fs.existsSync(d)) {
27
+ fs.copyFileSync(s, d)
28
+ }
29
+ } catch (err) {
30
+ console.error(err)
31
+ process.exit(1)
32
+ }
33
+ }
34
+
35
+ export async function copyFileToProject(projectFolder: string, templateFile: string, fileName: string): Promise<string> {
36
+ const s = path.resolve(PlataDirs.getPlataTempleteDir('create-cli', `${templateFile}.ts`))
37
+ let d = path.resolve(Plata.ProjectDir, projectFolder)
38
+
39
+ await mkdirIfNotExists(d)
40
+ d = path.join(d, fileName)
41
+ await copyFileIfNotExists(s, d)
42
+
43
+ return d
44
+ }
45
+
46
+ export async function deployFileToProject(projectFolder: string, templateFile: string, fileName: string, args: any) {
47
+ const fileInProject = await copyFileToProject(projectFolder, templateFile, fileName)
48
+
49
+ const content: any = await PlataFiles.readFileSync(fileInProject, (line) => {
50
+ if (line === '//@ts-nocheck') {
51
+ return ''
52
+ }
53
+
54
+ if (line === '') {
55
+ return ''
56
+ }
57
+
58
+ // Procura por texto para subistituir esse texto que esta no formato ç__PARAMETRO__ç
59
+ let lastIndex = 0
60
+ while(lastIndex !== -1) {
61
+ lastIndex = line.indexOf('$__', lastIndex)
62
+
63
+ if (lastIndex !== -1) {
64
+ const pIndex = line.indexOf('__$', lastIndex)
65
+ const param = line.slice(lastIndex + 3, pIndex)
66
+
67
+ line = line.replace(new RegExp(`\\$__${param}__\\$`, 'g'), args[param])
68
+ }
69
+ }
70
+
71
+ return line
72
+ })
73
+
74
+ if (content.err !== undefined) {
75
+ console.log(content.err)
76
+ process.exit(1)
77
+ } else {
78
+ fs.writeFileSync(fileInProject, content)
79
+ }
80
+ }
81
+ }
82
+
83
+ export namespace args {
84
+ export type argsCallBack = (command: string, args: string[]) => Promise<string[]>
85
+
86
+ export async function forEachArg(callback: argsCallBack) {
87
+ let args = process.argv.slice(process.argv.indexOf('--') + 1)
88
+
89
+ while(args.length !== 0) {
90
+ const command = args.shift()
91
+
92
+ if (command !== undefined) {
93
+ args = await callback(command, args)
94
+ }
95
+ }
96
+ }
97
+ }
98
98
  }
@@ -1,190 +1,190 @@
1
- import express from 'express'
2
- import { PlataClusterManager } from '++/libs/cluster'
3
- import { createServer } from 'node:https'
4
- import fs from 'node:fs/promises'
5
- import path from 'node:path'
6
- import { buildExpressRouter, loadRoutesFromProject } from '++/libs/router'
7
- import { getCustomExpress } from '++/libs/custom'
8
- import { HotReload } from '++/libs/hot-reload'
9
-
10
- export const main = async () => {
11
- const cluster = new PlataClusterManager()
12
-
13
- if (cluster.isPrimary()) {
14
-
15
- let workers: number | undefined = undefined
16
-
17
- if (Plata.config._PLATA_API_WORKERS !== undefined) {
18
- workers = +Plata.config._PLATA_API_WORKERS || undefined
19
- }
20
-
21
- const clustersPromise: RequireFolderReturn<{ default: Cluster.WorkerConfig }> = require("@@/clusters/*.*")
22
-
23
- if (process.argv.includes('--hot'))
24
- Plata.FastPromise(() => HotReload.setupHotReloadPrimary())
25
- ;
26
-
27
- const clusters = await clustersPromise
28
-
29
- if (clusters.errorID !== undefined) {
30
- console.log(clusters)
31
- process.exit(0)
32
- }
33
- // start Clusters
34
- {
35
- const promises: any = []
36
-
37
- clusters.forEach(c => {
38
- const config = c.exports.default
39
- promises.push(cluster._startCluster(config).then(r => {
40
- if (r !== null) {
41
- console.log(r)
42
- process.exit(0)
43
- }
44
- }))
45
- })
46
-
47
- await Promise.all(promises)
48
- }
49
-
50
- // Inicia a API
51
- await cluster._startCluster({
52
- name: '__PLATA_EXPRESS__',
53
- env: Plata.config.ENV ?? 'prod',
54
- onStart: async () => {},
55
- workers: workers,
56
- })
57
- } else {
58
- if (Plata.config._PLATA_WORKER_NAME === '__PLATA_EXPRESS__') {
59
- if (process.argv.includes('--hot'))
60
- Plata.FastPromise(() => HotReload.setupHotReloadWorker())
61
- ;
62
-
63
- const projectRoutesPromise = Plata.FastPromise(() => loadRoutesFromProject())
64
- const app = await getCustomExpress()
65
-
66
- app.disable('x-powered-by')
67
-
68
- const apiRoots = Plata.config._PLATA_API_ROOT ?? '/api'
69
-
70
- app.use(express.json({ limit: Plata.config._PLATA_API_JSON_SIZE ?? '100kb' }))
71
-
72
-
73
- const requiredRoutes = await projectRoutesPromise
74
-
75
- if (requiredRoutes.errorID !== undefined) {
76
- console.log(requiredRoutes)
77
-
78
- await cluster.send({
79
- action: 'KILL',
80
- msg: 'Erro enquanto carregava as rotas'
81
- })
82
-
83
- return
84
- }
85
-
86
- {
87
- const result = await buildExpressRouter(requiredRoutes)
88
-
89
- if (result.errorID !== undefined) {
90
- console.log(result)
91
-
92
- await cluster.send({
93
- action: 'KILL',
94
- msg: 'Erro enquanto carregava as rotas'
95
- })
96
-
97
- return
98
- }
99
-
100
- app.use(apiRoots.split(','), result as any)
101
- }
102
-
103
- app.use((err, _req, res, _next) => {
104
- return res.status(500).json({
105
- errorID: 'PRAPI0001',
106
- error: 'Erro interno inesperado',
107
- msg: {
108
- message: err.message,
109
- stack: err.stack ?? new Error().stack
110
- }
111
- })
112
- })
113
-
114
- app.all('*', (req, res) => {
115
- return res.status(404).json({
116
- errorID: 'PRAPI0002',
117
- msg: 'Rota não encontrada',
118
- error: req.path
119
- })
120
- })
121
-
122
- const port = process.env.PORT ?? 3050
123
-
124
- if (!Plata.config._PLATA_API_SSL_KEY || !Plata.config._PLATA_API_SSL_CERT) {
125
-
126
- console.log(`Nenhum certificado configurado na env ${process.env.ENV}:`)
127
- console.log(`_PLATA_API_SSL_KEY: ${process.env._PLATA_API_SSL_KEY}`)
128
- console.log(`_PLATA_API_SSL_CERT: ${process.env._PLATA_API_SSL_CERT}`)
129
-
130
- app.listen(port, () => {
131
- console.log(`Iniciando Worker Express na porta ${port}`)
132
- setTimeout(() => process.removeAllListeners('exit'), 500)
133
- })
134
-
135
- } else {
136
-
137
- console.log('Iniciando a Plata com ssl usando os arquivos:')
138
- console.log(`key: ${process.env._PLATA_API_SSL_KEY}`)
139
- console.log(`cert: ${process.env._PLATA_API_SSL_CERT}`)
140
-
141
- const [ cert, key ] = await Promise.all([
142
- fs.readFile(path.normalize(path.join(
143
- Plata.ProjectDir,
144
- Plata.config._PLATA_API_SSL_CERT
145
- ))),
146
- fs.readFile(path.normalize(path.join(
147
- Plata.ProjectDir,
148
- Plata.config._PLATA_API_SSL_KEY
149
- )))
150
- ]).catch(err => {
151
- console.log({
152
- errorID: 'PRAPI0003',
153
- msg: 'Erro ao ler o certifica e chave ssl',
154
- error: {
155
- message: err?.toString(),
156
- stack: err?.stack
157
- }
158
- } satisfies PlataError)
159
-
160
- process.exit(1)
161
- })
162
-
163
- const https = createServer({
164
- cert,
165
- key,
166
- passphrase: process.env._PLATA_API_SSL_PASS
167
- }, app)
168
-
169
- https.listen(port, () => {
170
- console.log(`Iniciando Worker Express na porta ${port} com SSL`)
171
- setTimeout(() => process.removeAllListeners('exit'), 500)
172
- })
173
- }
174
- } else {
175
- if (Plata.config._PLATA_WORKER_NAME === undefined) {
176
- await cluster.send({
177
- action: 'KILL',
178
- msg: 'tried to start a Worker without _PLATA_WORKER_NAME'
179
- })
180
-
181
- return
182
- }
183
-
184
- await cluster._onStartCluster(
185
- Plata.config._PLATA_WORKER_NAME,
186
- Plata.config._PLATA_WORKER_TYPE,
187
- )
188
- }
189
- }
1
+ import express from 'express'
2
+ import { PlataClusterManager } from '++/libs/cluster'
3
+ import { createServer } from 'node:https'
4
+ import fs from 'node:fs/promises'
5
+ import path from 'node:path'
6
+ import { buildExpressRouter, loadRoutesFromProject } from '++/libs/router'
7
+ import { getCustomExpress } from '++/libs/custom'
8
+ import { HotReload } from '++/libs/hot-reload'
9
+
10
+ export const main = async () => {
11
+ const cluster = new PlataClusterManager()
12
+
13
+ if (cluster.isPrimary()) {
14
+
15
+ let workers: number | undefined = undefined
16
+
17
+ if (Plata.config._PLATA_API_WORKERS !== undefined) {
18
+ workers = +Plata.config._PLATA_API_WORKERS || undefined
19
+ }
20
+
21
+ const clustersPromise: RequireFolderReturn<{ default: Cluster.WorkerConfig }> = require("@@/clusters/*.*")
22
+
23
+ if (process.argv.includes('--hot'))
24
+ Plata.FastPromise(() => HotReload.setupHotReloadPrimary())
25
+ ;
26
+
27
+ const clusters = await clustersPromise
28
+
29
+ if (clusters.errorID !== undefined) {
30
+ console.log(clusters)
31
+ process.exit(0)
32
+ }
33
+ // start Clusters
34
+ {
35
+ const promises: any = []
36
+
37
+ clusters.forEach(c => {
38
+ const config = c.exports.default
39
+ promises.push(cluster._startCluster(config).then(r => {
40
+ if (r !== null) {
41
+ console.log(r)
42
+ process.exit(0)
43
+ }
44
+ }))
45
+ })
46
+
47
+ await Promise.all(promises)
48
+ }
49
+
50
+ // Inicia a API
51
+ await cluster._startCluster({
52
+ name: '__PLATA_EXPRESS__',
53
+ env: Plata.config.ENV ?? 'prod',
54
+ onStart: async () => {},
55
+ workers: workers,
56
+ })
57
+ } else {
58
+ if (Plata.config._PLATA_WORKER_NAME === '__PLATA_EXPRESS__') {
59
+ if (process.argv.includes('--hot'))
60
+ Plata.FastPromise(() => HotReload.setupHotReloadWorker())
61
+ ;
62
+
63
+ const projectRoutesPromise = Plata.FastPromise(() => loadRoutesFromProject())
64
+ const app = await getCustomExpress()
65
+
66
+ app.disable('x-powered-by')
67
+
68
+ const apiRoots = Plata.config._PLATA_API_ROOT ?? '/api'
69
+
70
+ app.use(express.json({ limit: Plata.config._PLATA_API_JSON_SIZE ?? '100kb' }))
71
+
72
+
73
+ const requiredRoutes = await projectRoutesPromise
74
+
75
+ if (requiredRoutes.errorID !== undefined) {
76
+ console.log(requiredRoutes)
77
+
78
+ await cluster.send({
79
+ action: 'KILL',
80
+ msg: 'Erro enquanto carregava as rotas'
81
+ })
82
+
83
+ return
84
+ }
85
+
86
+ {
87
+ const result = await buildExpressRouter(requiredRoutes)
88
+
89
+ if (result.errorID !== undefined) {
90
+ console.log(result)
91
+
92
+ await cluster.send({
93
+ action: 'KILL',
94
+ msg: 'Erro enquanto carregava as rotas'
95
+ })
96
+
97
+ return
98
+ }
99
+
100
+ app.use(apiRoots.split(','), result as any)
101
+ }
102
+
103
+ app.use((err, _req, res, _next) => {
104
+ return res.status(500).json({
105
+ errorID: 'PRAPI0001',
106
+ error: 'Erro interno inesperado',
107
+ msg: {
108
+ message: err.message,
109
+ stack: err.stack ?? new Error().stack
110
+ }
111
+ })
112
+ })
113
+
114
+ app.all('*', (req, res) => {
115
+ return res.status(404).json({
116
+ errorID: 'PRAPI0002',
117
+ msg: 'Rota não encontrada',
118
+ error: req.path
119
+ })
120
+ })
121
+
122
+ const port = process.env.PORT ?? 3050
123
+
124
+ if (!Plata.config._PLATA_API_SSL_KEY || !Plata.config._PLATA_API_SSL_CERT) {
125
+
126
+ console.log(`Nenhum certificado configurado na env ${process.env.ENV}:`)
127
+ console.log(`_PLATA_API_SSL_KEY: ${process.env._PLATA_API_SSL_KEY}`)
128
+ console.log(`_PLATA_API_SSL_CERT: ${process.env._PLATA_API_SSL_CERT}`)
129
+
130
+ app.listen(port, () => {
131
+ console.log(`Iniciando Worker Express na porta ${port}`)
132
+ setTimeout(() => process.removeAllListeners('exit'), 500)
133
+ })
134
+
135
+ } else {
136
+
137
+ console.log('Iniciando a Plata com ssl usando os arquivos:')
138
+ console.log(`key: ${process.env._PLATA_API_SSL_KEY}`)
139
+ console.log(`cert: ${process.env._PLATA_API_SSL_CERT}`)
140
+
141
+ const [ cert, key ] = await Promise.all([
142
+ fs.readFile(path.normalize(path.join(
143
+ Plata.ProjectDir,
144
+ Plata.config._PLATA_API_SSL_CERT
145
+ ))),
146
+ fs.readFile(path.normalize(path.join(
147
+ Plata.ProjectDir,
148
+ Plata.config._PLATA_API_SSL_KEY
149
+ )))
150
+ ]).catch(err => {
151
+ console.log({
152
+ errorID: 'PRAPI0003',
153
+ msg: 'Erro ao ler o certifica e chave ssl',
154
+ error: {
155
+ message: err?.toString(),
156
+ stack: err?.stack
157
+ }
158
+ } satisfies PlataError)
159
+
160
+ process.exit(1)
161
+ })
162
+
163
+ const https = createServer({
164
+ cert,
165
+ key,
166
+ passphrase: process.env._PLATA_API_SSL_PASS
167
+ }, app)
168
+
169
+ https.listen(port, () => {
170
+ console.log(`Iniciando Worker Express na porta ${port} com SSL`)
171
+ setTimeout(() => process.removeAllListeners('exit'), 500)
172
+ })
173
+ }
174
+ } else {
175
+ if (Plata.config._PLATA_WORKER_NAME === undefined) {
176
+ await cluster.send({
177
+ action: 'KILL',
178
+ msg: 'tried to start a Worker without _PLATA_WORKER_NAME'
179
+ })
180
+
181
+ return
182
+ }
183
+
184
+ await cluster._onStartCluster(
185
+ Plata.config._PLATA_WORKER_NAME,
186
+ Plata.config._PLATA_WORKER_TYPE,
187
+ )
188
+ }
189
+ }
190
190
  }
@@ -1,18 +1,18 @@
1
- import { PlataBuild } from "++/libs/build"
2
- import path from 'path'
3
-
4
- export const main = async () => {
5
- const config = await PlataBuild.getBuildConfig()
6
-
7
- if (config.errorID !== undefined) {
8
- console.error(config)
9
- process.exit(1)
10
- }
11
-
12
- await PlataBuild.compile({
13
- ...config,
14
- basePath: path.join(Plata.ProjectDir, '__RELEASE__'),
15
- mapFiles: true,
16
- packageJsonSetup: true,
17
- })
1
+ import { PlataBuild } from "++/libs/build"
2
+ import path from 'path'
3
+
4
+ export const main = async () => {
5
+ const config = await PlataBuild.getBuildConfig()
6
+
7
+ if (config.errorID !== undefined) {
8
+ console.error(config)
9
+ process.exit(1)
10
+ }
11
+
12
+ await PlataBuild.compile({
13
+ ...config,
14
+ basePath: path.join(Plata.ProjectDir, '__RELEASE__'),
15
+ mapFiles: true,
16
+ packageJsonSetup: true,
17
+ })
18
18
  }