@diia-inhouse/scaffold 2.17.0
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/LICENCE.md +287 -0
- package/README.md +93 -0
- package/dist/_sharedTemplates/actionTest.t +36 -0
- package/dist/_templates/add/action/01-action.ts.t +34 -0
- package/dist/_templates/add/action/01-test.ts.t +37 -0
- package/dist/_templates/add/action/01.interface.ts.t +15 -0
- package/dist/_templates/add/action/02-scriptRunner.t +3 -0
- package/dist/_templates/add/action/dict.js +18 -0
- package/dist/_templates/add/action/dict.js.map +1 -0
- package/dist/_templates/add/action/prompt.js +88 -0
- package/dist/_templates/add/action/prompt.js.map +1 -0
- package/dist/_templates/add/eventListener/01-event.ts.t +18 -0
- package/dist/_templates/add/eventListener/01-interface.ts.t +5 -0
- package/dist/_templates/add/eventListener/02-scriptRunner.ts.t +3 -0
- package/dist/_templates/add/eventListener/prompt.js +22 -0
- package/dist/_templates/add/eventListener/prompt.js.map +1 -0
- package/dist/_templates/add/externalEventListener/01-event.ts.t +16 -0
- package/dist/_templates/add/externalEventListener/01-interface.ts.t +5 -0
- package/dist/_templates/add/externalEventListener/02-scriptRunner.t +3 -0
- package/dist/_templates/add/externalEventListener/prompt.js +22 -0
- package/dist/_templates/add/externalEventListener/prompt.js.map +1 -0
- package/dist/_templates/add/generator/01-interface.ts.t +7 -0
- package/dist/_templates/add/generator/01-prompt.ts.t +19 -0
- package/dist/_templates/add/generator/02-scriptRunner.ts.t +7 -0
- package/dist/_templates/add/generator/03-scriptRunner.ts.t +3 -0
- package/dist/_templates/add/generator/prompt.js +45 -0
- package/dist/_templates/add/generator/prompt.js.map +1 -0
- package/dist/_templates/add/model/01-interfaces.model.ts.t +8 -0
- package/dist/_templates/add/model/01-model.ts.t +16 -0
- package/dist/_templates/add/model/02-scriptRunner.ts.t +3 -0
- package/dist/_templates/add/model/prompt.js +20 -0
- package/dist/_templates/add/model/prompt.js.map +1 -0
- package/dist/_templates/add/scheduledTask/01-task.ts.t +12 -0
- package/dist/_templates/add/scheduledTask/02-scriptRunner.t +3 -0
- package/dist/_templates/add/scheduledTask/prompt.js +20 -0
- package/dist/_templates/add/scheduledTask/prompt.js.map +1 -0
- package/dist/_templates/add/task/01-interface.ts.t +5 -0
- package/dist/_templates/add/task/01-task.ts.t +29 -0
- package/dist/_templates/add/task/02-scriptRunner.t +5 -0
- package/dist/_templates/add/task/prompt.js +32 -0
- package/dist/_templates/add/task/prompt.js.map +1 -0
- package/dist/_templates/add/test/01-test.ts.t +5 -0
- package/dist/_templates/add/test/02-scriptRunner.ts.t +3 -0
- package/dist/_templates/add/test/prompt.js +48 -0
- package/dist/_templates/add/test/prompt.js.map +1 -0
- package/dist/_templates/init/matchers/01-index.ts.t +5 -0
- package/dist/_templates/init/matchers/01-inject-setup.ts.t +8 -0
- package/dist/_templates/init/matchers/01-jest.d.ts.t +16 -0
- package/dist/_templates/init/matchers/01-matcher.ts.t +5 -0
- package/dist/_templates/init/matchers/01-new-setup.ts.t +8 -0
- package/dist/_templates/init/matchers/01-tsconfig.json.t +6 -0
- package/dist/_templates/init/matchers/02-scriptRunner.ts.t +3 -0
- package/dist/_templates/init/matchers/prompt.js +77 -0
- package/dist/_templates/init/matchers/prompt.js.map +1 -0
- package/dist/_templates/init/package/01-.eslintignore.t +7 -0
- package/dist/_templates/init/package/01-.gitignore.t +8 -0
- package/dist/_templates/init/package/01-.gitlab-ci.yml.t +13 -0
- package/dist/_templates/init/package/01-.prettierignore.t +5 -0
- package/dist/_templates/init/package/01-package.json.t +48 -0
- package/dist/_templates/init/package/01-readme.md.t +7 -0
- package/dist/_templates/init/package/01-src.index.ts.t +7 -0
- package/dist/_templates/init/package/01-test.tsconfig.json.t +19 -0
- package/dist/_templates/init/package/01-test.unit.index.ts.t +13 -0
- package/dist/_templates/init/package/01-tsconfig.json.t +22 -0
- package/dist/_templates/init/package/02-scriptRunner.t +7 -0
- package/dist/_templates/init/package/prompt.js +26 -0
- package/dist/_templates/init/package/prompt.js.map +1 -0
- package/dist/_templates/init/service/01-.env.example.t +59 -0
- package/dist/_templates/init/service/01-.env.test.t +4 -0
- package/dist/_templates/init/service/01-.eslintignore.t +8 -0
- package/dist/_templates/init/service/01-.gitignore.t +11 -0
- package/dist/_templates/init/service/01-.gitlab-ci.yml.t +20 -0
- package/dist/_templates/init/service/01-.prettierignore.t +6 -0
- package/dist/_templates/init/service/01-dockerfile.t +38 -0
- package/dist/_templates/init/service/01-migrate-mongo-config.ts.t +8 -0
- package/dist/_templates/init/service/01-migrations.sample-migration.ts.t +18 -0
- package/dist/_templates/init/service/01-migrations.tsconfig.json.t +21 -0
- package/dist/_templates/init/service/01-package.json.t +68 -0
- package/dist/_templates/init/service/01-proto.service.proto.t +22 -0
- package/dist/_templates/init/service/01-readme.md.t +7 -0
- package/dist/_templates/init/service/01-src.actions.v1.getAddResult.ts.t +29 -0
- package/dist/_templates/init/service/01-src.bootstrap.ts.t +18 -0
- package/dist/_templates/init/service/01-src.config.ts.t +160 -0
- package/dist/_templates/init/service/01-src.deps.ts.t +14 -0
- package/dist/_templates/init/service/01-src.index.ts.t +14 -0
- package/dist/_templates/init/service/01-src.interfaces.actions.v1.getAddResult.ts.t +13 -0
- package/dist/_templates/init/service/01-src.interfaces.config.ts.t +7 -0
- package/dist/_templates/init/service/01-src.interfaces.deps.ts.t +9 -0
- package/dist/_templates/init/service/01-tests.integration.actionts.getAddResult.spec.ts.t +39 -0
- package/dist/_templates/init/service/01-tests.interfaces.ts.t +9 -0
- package/dist/_templates/init/service/01-tests.jest.d.ts.t +5 -0
- package/dist/_templates/init/service/01-tests.tsconfig.json.t +23 -0
- package/dist/_templates/init/service/01-tests.utils.getApp.ts.t +26 -0
- package/dist/_templates/init/service/01-tests.utils.getDeps.ts.t +23 -0
- package/dist/_templates/init/service/01-tsconfig.json.t +25 -0
- package/dist/_templates/init/service/02-scriptRunner.ts.t +7 -0
- package/dist/_templates/init/service/prompt.js +36 -0
- package/dist/_templates/init/service/prompt.js.map +1 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -0
- package/dist/depsNames.js +45 -0
- package/dist/depsNames.js.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/_templates/add/action.js +3 -0
- package/dist/interfaces/_templates/add/action.js.map +1 -0
- package/dist/interfaces/_templates/add/eventListener.js +3 -0
- package/dist/interfaces/_templates/add/eventListener.js.map +1 -0
- package/dist/interfaces/_templates/add/externalEventListener.js +3 -0
- package/dist/interfaces/_templates/add/externalEventListener.js.map +1 -0
- package/dist/interfaces/_templates/add/generator.js +3 -0
- package/dist/interfaces/_templates/add/generator.js.map +1 -0
- package/dist/interfaces/_templates/add/model.js +3 -0
- package/dist/interfaces/_templates/add/model.js.map +1 -0
- package/dist/interfaces/_templates/add/scheduledTask.js +3 -0
- package/dist/interfaces/_templates/add/scheduledTask.js.map +1 -0
- package/dist/interfaces/_templates/add/task.js +3 -0
- package/dist/interfaces/_templates/add/task.js.map +1 -0
- package/dist/interfaces/_templates/add/test.js +3 -0
- package/dist/interfaces/_templates/add/test.js.map +1 -0
- package/dist/interfaces/_templates/init/matcher.js +9 -0
- package/dist/interfaces/_templates/init/matcher.js.map +1 -0
- package/dist/interfaces/_templates/init/package.js +3 -0
- package/dist/interfaces/_templates/init/package.js.map +1 -0
- package/dist/interfaces/_templates/init/service.js +11 -0
- package/dist/interfaces/_templates/init/service.js.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/prompt/autocomplete.js +3 -0
- package/dist/interfaces/prompt/autocomplete.js.map +1 -0
- package/dist/interfaces/prompt/multiselect.js +3 -0
- package/dist/interfaces/prompt/multiselect.js.map +1 -0
- package/dist/interfaces/prompt/select.js +9 -0
- package/dist/interfaces/prompt/select.js.map +1 -0
- package/dist/prompt/autocomplete.js +12 -0
- package/dist/prompt/autocomplete.js.map +1 -0
- package/dist/prompt/index.js +12 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/select/baseSelect.js +12 -0
- package/dist/prompt/select/baseSelect.js.map +1 -0
- package/dist/prompt/select/multiselect.js +15 -0
- package/dist/prompt/select/multiselect.js.map +1 -0
- package/dist/prompt/select/yesNoSelect.js +17 -0
- package/dist/prompt/select/yesNoSelect.js.map +1 -0
- package/dist/utils.js +29 -0
- package/dist/utils.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/src/config.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { BalancingStrategy, BaseConfig, MetricsConfig, TransporterConfig } from '@diia-inhouse/diia-app'
|
|
6
|
+
|
|
7
|
+
import { EnvService } from '@diia-inhouse/env'
|
|
8
|
+
import { HealthCheckConfig } from '@diia-inhouse/healthcheck'
|
|
9
|
+
|
|
10
|
+
<%if (h.isOptionSelected(selectedOptions, 'database')) {%>
|
|
11
|
+
import { AppDbConfig, ReplicaSetNodeConfig } from '@diia-inhouse/db'
|
|
12
|
+
<%}%>
|
|
13
|
+
<%if (h.isOptionSelected(selectedOptions, 'redis')) {%>
|
|
14
|
+
import { RedisConfig } from '@diia-inhouse/redis'
|
|
15
|
+
<%}%>
|
|
16
|
+
<%if (h.isOptionSelected(selectedOptions, ['internal', 'external'])) {%>
|
|
17
|
+
import {
|
|
18
|
+
InternalQueueConfig,
|
|
19
|
+
InternalQueueName,
|
|
20
|
+
ListenerOptions,
|
|
21
|
+
QueueConnectionConfig,
|
|
22
|
+
QueueConnectionType,
|
|
23
|
+
QueueConfig,
|
|
24
|
+
ScheduledTaskQueueName,
|
|
25
|
+
} from '@diia-inhouse/diia-queue'
|
|
26
|
+
<%}%>
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
29
|
+
export default (envService: EnvService <%= h.isOptionSelected(selectedOptions, ['internal', 'external']) ? ", serviceName: string" : '' %>) => ({
|
|
30
|
+
transporter: <TransporterConfig>{
|
|
31
|
+
type: envService.getVar('TRANSPORT_TYPE'),
|
|
32
|
+
options: envService.getVar('TRANSPORT_OPTIONS', 'object', {}),
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
balancing: <BalancingStrategy>{
|
|
36
|
+
strategy: envService.getVar('BALANCING_STRATEGY_NAME', 'string'),
|
|
37
|
+
strategyOptions: envService.getVar('BALANCING_STRATEGY_OPTIONS', 'object', {}),
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
healthCheck: <HealthCheckConfig>{
|
|
41
|
+
isEnabled: envService.getVar('HEALTH_CHECK_IS_ENABLED', 'boolean'),
|
|
42
|
+
port: envService.getVar('HEALTH_CHECK_IS_PORT', 'number', 4545),
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
metrics: <MetricsConfig>{
|
|
46
|
+
moleculer: {
|
|
47
|
+
prometheus: {
|
|
48
|
+
isEnabled: envService.getVar('METRICS_MOLECULER_PROMETHEUS_IS_ENABLED', 'boolean', true),
|
|
49
|
+
port: envService.getVar('METRICS_MOLECULER_PROMETHEUS_PORT', 'number', 3031),
|
|
50
|
+
path: envService.getVar('METRICS_MOLECULER_PROMETHEUS_PATH', 'string', '/metrics'),
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
custom: {
|
|
54
|
+
disabled: envService.getVar('METRICS_CUSTOM_DISABLED', 'boolean', false),
|
|
55
|
+
port: envService.getVar('METRICS_CUSTOM_PORT', 'number', 3030),
|
|
56
|
+
moleculer: {
|
|
57
|
+
disabled: envService.getVar('METRICS_CUSTOM_MOLECULER_DISABLED', 'boolean', false),
|
|
58
|
+
port: envService.getVar('METRICS_CUSTOM_MOLECULER_PORT', 'number', 3031),
|
|
59
|
+
path: envService.getVar('METRICS_CUSTOM_MOLECULER_PATH', 'string', '/metrics'),
|
|
60
|
+
},
|
|
61
|
+
disableDefaultMetrics: envService.getVar('METRICS_CUSTOM_DISABLE_DEFAULT_METRICS', 'boolean', false),
|
|
62
|
+
defaultLabels: envService.getVar('METRICS_CUSTOM_DEFAULT_LABELS', 'object', {}),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
grpc: {},
|
|
67
|
+
|
|
68
|
+
<%if (h.isOptionSelected(selectedOptions, 'database')) {%>
|
|
69
|
+
db: <AppDbConfig>{
|
|
70
|
+
database: envService.getVar('MONGO_DATABASE', 'string'),
|
|
71
|
+
replicaSet: envService.getVar('MONGO_REPLICA_SET', 'string'),
|
|
72
|
+
user: await envService.getSecret('MONGO_USER', { accessor: 'username', nullable: true }),
|
|
73
|
+
password: await envService.getSecret('MONGO_PASSWORD', { accessor: 'password', nullable: true }),
|
|
74
|
+
authSource: envService.getVar('MONGO_AUTH_SOURCE', 'string'),
|
|
75
|
+
port: envService.getVar('MONGO_PORT', 'number'),
|
|
76
|
+
replicaSetNodes: envService
|
|
77
|
+
.getVar('MONGO_HOSTS', 'string')
|
|
78
|
+
.split(',')
|
|
79
|
+
.map((replicaHost: string): ReplicaSetNodeConfig => ({ replicaHost })),
|
|
80
|
+
readPreference: envService.getVar('MONGO_READ_PREFERENCE', 'string'),
|
|
81
|
+
indexes: {
|
|
82
|
+
sync: envService.getVar('MONGO_INDEXES_SYNC', 'boolean'),
|
|
83
|
+
exitAfterSync: envService.getVar('MONGO_INDEXES_EXIT_AFTER_SYNC', 'boolean'),
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
<%}%>
|
|
87
|
+
|
|
88
|
+
<%if (h.isOptionSelected(selectedOptions, 'external')) {%>
|
|
89
|
+
redis: <RedisConfig>{
|
|
90
|
+
readWrite: envService.getVar('REDIS_READ_WRITE_OPTIONS', 'object'),
|
|
91
|
+
|
|
92
|
+
readOnly: envService.getVar('REDIS_READ_ONLY_OPTIONS', 'object'),
|
|
93
|
+
},
|
|
94
|
+
<%}%>
|
|
95
|
+
|
|
96
|
+
<%if (h.isOptionSelected(selectedOptions, 'redis')) {%>
|
|
97
|
+
store: <RedisConfig>{
|
|
98
|
+
readWrite: envService.getVar('STORE_READ_WRITE_OPTIONS', 'object'),
|
|
99
|
+
|
|
100
|
+
readOnly: envService.getVar('STORE_READ_ONLY_OPTIONS', 'object'),
|
|
101
|
+
},
|
|
102
|
+
<%}%>
|
|
103
|
+
|
|
104
|
+
<%if (h.isOptionSelected(selectedOptions, ['internal', 'external'])) {%>
|
|
105
|
+
rabbit: <QueueConnectionConfig>{
|
|
106
|
+
<%if (h.isOptionSelected(selectedOptions, 'internal')) {%>
|
|
107
|
+
[QueueConnectionType.Internal]: {
|
|
108
|
+
connection: {
|
|
109
|
+
hostname: envService.getVar('RABBIT_HOST', 'string'),
|
|
110
|
+
port: envService.getVar('RABBIT_PORT', 'number'),
|
|
111
|
+
username: await envService.getSecret('RABBIT_USERNAME', { accessor: 'username' }),
|
|
112
|
+
password: await envService.getSecret('RABBIT_PASSWORD', { accessor: 'password' }),
|
|
113
|
+
heartbeat: envService.getVar('RABBIT_HEARTBEAT', 'number'),
|
|
114
|
+
},
|
|
115
|
+
socketOptions: {
|
|
116
|
+
clientProperties: {
|
|
117
|
+
applicationName: `${serviceName} Service`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
reconnectOptions: {
|
|
121
|
+
reconnectEnabled: true,
|
|
122
|
+
},
|
|
123
|
+
listenerOptions: {
|
|
124
|
+
prefetchCount: envService.getVar('RABBIT_QUEUE_PREFETCH_COUNT', 'number', 10),
|
|
125
|
+
},
|
|
126
|
+
// Uncomment if listening to scheduled tasks needed
|
|
127
|
+
// scheduledTaskQueueName: ScheduledTaskQueueName.,
|
|
128
|
+
// Uncomment if listening to internal bus events needed
|
|
129
|
+
// queueName: InternalQueueName.,
|
|
130
|
+
},
|
|
131
|
+
<%}%>
|
|
132
|
+
<%if (h.isOptionSelected(selectedOptions, 'external')) {%>
|
|
133
|
+
[QueueConnectionType.External]: {
|
|
134
|
+
connection: {
|
|
135
|
+
hostname: envService.getVar('EXTERNAL_RABBIT_HOST', 'string'),
|
|
136
|
+
port: envService.getVar('EXTERNAL_RABBIT_PORT', 'number'),
|
|
137
|
+
username: await envService.getSecret('EXTERNAL_RABBIT_USERNAME', { accessor: 'username' }),
|
|
138
|
+
password: await envService.getSecret('EXTERNAL_RABBIT_PASSWORD', { accessor: 'password' }),
|
|
139
|
+
heartbeat: envService.getVar('EXTERNAL_RABBIT_HEARTBEAT', 'number'),
|
|
140
|
+
},
|
|
141
|
+
socketOptions: {
|
|
142
|
+
clientProperties: {
|
|
143
|
+
applicationName: `${serviceName} Service`,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
reconnectOptions: {
|
|
147
|
+
reconnectEnabled: true,
|
|
148
|
+
},
|
|
149
|
+
listenerOptions: {
|
|
150
|
+
prefetchCount: envService.getVar('EXTERNAL_RABBIT_QUEUE_PREFETCH_COUNT', 'number', 1),
|
|
151
|
+
},
|
|
152
|
+
assertExchanges: envService.getVar('EXTERNAL_RABBIT_ASSERT_EXCHANGES', 'boolean'),
|
|
153
|
+
custom: {
|
|
154
|
+
responseRoutingKeyPrefix: envService.getVar('EXTERNAL_RABBIT_RESPONSE_ROUTING_KEY_PREFIX', 'string', null),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
<%}%>
|
|
158
|
+
},
|
|
159
|
+
<%}%>
|
|
160
|
+
}) satisfies BaseConfig & Record<string, unknown>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/src/deps.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { DepsFactoryFn } from "@diia-inhouse/diia-app";
|
|
6
|
+
|
|
7
|
+
import { AppDeps } from "@interfaces/deps";
|
|
8
|
+
import { AppConfig } from "@interfaces/config";
|
|
9
|
+
|
|
10
|
+
export default (
|
|
11
|
+
config: AppConfig
|
|
12
|
+
): ReturnType<DepsFactoryFn<AppConfig, AppDeps>> => {
|
|
13
|
+
return {};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/src/index.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { initTracing } from '@diia-inhouse/diia-app'
|
|
6
|
+
|
|
7
|
+
const serviceName = '<%= h.changeCase.pascalCase(serviceName) %>'
|
|
8
|
+
|
|
9
|
+
initTracing(serviceName)
|
|
10
|
+
|
|
11
|
+
import 'module-alias/register'
|
|
12
|
+
import { bootstrap } from './bootstrap'
|
|
13
|
+
|
|
14
|
+
bootstrap(serviceName)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/src/interfaces/actions/v1/getAddResult.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { UserActionArguments } from '@diia-inhouse/types'
|
|
6
|
+
|
|
7
|
+
import { GetAddResultReq, GetAddResultRes } from '@src/generated'
|
|
8
|
+
|
|
9
|
+
export interface CustomActionArguments extends UserActionArguments {
|
|
10
|
+
params: GetAddResultReq
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ActionResult = GetAddResultRes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/tests/integration/actions/v1/addAction.spec.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import TestKit from '@diia-inhouse/test'
|
|
6
|
+
|
|
7
|
+
import GetAddResultAction from '@src/actions/v1/getAddResult'
|
|
8
|
+
|
|
9
|
+
import { getApp } from '@tests/utils/getApp'
|
|
10
|
+
|
|
11
|
+
describe(`Action ${GetAddResultAction.name}`, () => {
|
|
12
|
+
let app: Awaited<ReturnType<typeof getApp>>
|
|
13
|
+
let getAddResult: GetAddResultAction
|
|
14
|
+
const testKit = new TestKit()
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
app = await getApp()
|
|
18
|
+
getAddResult = app.container.build(GetAddResultAction)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
afterAll(async () => {
|
|
22
|
+
await app.stop()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should return correct result', async () => {
|
|
26
|
+
// Arrange
|
|
27
|
+
const session = testKit.session.getUserSession()
|
|
28
|
+
const headers = testKit.session.getHeaders()
|
|
29
|
+
|
|
30
|
+
const a = 2;
|
|
31
|
+
const b = 3;
|
|
32
|
+
|
|
33
|
+
// Act
|
|
34
|
+
const result = await getAddResult.handler({ params: { a, b }, session, headers })
|
|
35
|
+
|
|
36
|
+
// Assert
|
|
37
|
+
expect(result).toEqual({ result: 5 })
|
|
38
|
+
})
|
|
39
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/tests/tsconfig.json
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
"extends": "@diia-inhouse/configs/tsconfig",
|
|
7
|
+
"compilerOptions": {
|
|
8
|
+
"baseUrl": "../",
|
|
9
|
+
"paths": {
|
|
10
|
+
"@services/*": ["src/services/*"],
|
|
11
|
+
"@interfaces/*": ["src/interfaces/*"],
|
|
12
|
+
<%if (h.isOptionSelected(selectedOptions, 'database')) {%>
|
|
13
|
+
"@models/*": ["src/models/*"],
|
|
14
|
+
<%}%>
|
|
15
|
+
"@dataMappers/*": ["src/dataMappers/*"],
|
|
16
|
+
"@actions/*": ["src/actions/*"],
|
|
17
|
+
"@src/*": ["src/*"],
|
|
18
|
+
"@tests/*": ["tests/*"]
|
|
19
|
+
},
|
|
20
|
+
"noEmit": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["./**/*"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/tests/utils/getApp.ts
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import { asClass } from 'awilix'
|
|
6
|
+
|
|
7
|
+
import { Application, GrpcService, MoleculerService, ServiceContext, ServiceOperator } from '@diia-inhouse/diia-app'
|
|
8
|
+
|
|
9
|
+
import { mockClass } from '@diia-inhouse/test'
|
|
10
|
+
|
|
11
|
+
import config from '@src/config'
|
|
12
|
+
|
|
13
|
+
import { TestDeps } from '@tests/interfaces'
|
|
14
|
+
import deps from '@tests/utils/getDeps'
|
|
15
|
+
|
|
16
|
+
import { AppConfig } from '@interfaces/config'
|
|
17
|
+
import { AppDeps } from '@interfaces/deps'
|
|
18
|
+
|
|
19
|
+
export function getApp(): ServiceOperator<AppConfig, AppDeps & TestDeps> {
|
|
20
|
+
const app = new Application<ServiceContext<AppConfig, AppDeps & TestDeps>>('<%= h.changeCase.pascal(serviceName) %>')
|
|
21
|
+
.setConfig(config)
|
|
22
|
+
.setDeps(deps)
|
|
23
|
+
.initialize()
|
|
24
|
+
|
|
25
|
+
return app
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/tests/utils/getDeps.ts
|
|
3
|
+
---
|
|
4
|
+
import { asClass } from 'awilix'
|
|
5
|
+
|
|
6
|
+
import { DepsFactoryFn } from '@diia-inhouse/diia-app'
|
|
7
|
+
|
|
8
|
+
import { IdentifierService } from '@diia-inhouse/crypto'
|
|
9
|
+
import TestKit from '@diia-inhouse/test'
|
|
10
|
+
|
|
11
|
+
import deps from '@src/deps'
|
|
12
|
+
|
|
13
|
+
import { TestDeps } from '@tests/interfaces'
|
|
14
|
+
|
|
15
|
+
import { AppConfig } from '@interfaces/config'
|
|
16
|
+
import { AppDeps } from '@interfaces/deps'
|
|
17
|
+
|
|
18
|
+
export default (config: AppConfig): ReturnType<DepsFactoryFn<AppConfig, AppDeps & TestDeps>> => {
|
|
19
|
+
return {
|
|
20
|
+
...deps(config),
|
|
21
|
+
testKit: asClass(TestKit).singleton(),
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= serviceName %>/tsconfig.json
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
"extends": "@diia-inhouse/configs/tsconfig",
|
|
7
|
+
"compilerOptions": {
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"declarationDir": "dist/types",
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"paths": {
|
|
12
|
+
"@services/*": ["src/services/*"],
|
|
13
|
+
"@interfaces/*": ["src/interfaces/*"],
|
|
14
|
+
<%if (h.isOptionSelected(selectedOptions, 'database')) {%>
|
|
15
|
+
"@models/*": ["src/models/*"],
|
|
16
|
+
<%}%>
|
|
17
|
+
"@dataMappers/*": ["src/dataMappers/*"],
|
|
18
|
+
"@actions/*": ["src/actions/*"],
|
|
19
|
+
"@src/*": ["src/*"],
|
|
20
|
+
"@tests/*": ["tests/*"]
|
|
21
|
+
},
|
|
22
|
+
"plugins": [{ "transform": "typescript-transform-paths" }, { "transform": "typescript-transform-paths", "afterDeclarations": true }]
|
|
23
|
+
},
|
|
24
|
+
"include": ["src/**/*", "tests/jest.d.ts"]
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
sh: "cd <%= serviceName %> && npm install <%= dependencies.deps %> && npm install --save-dev <%= dependencies.devDeps %> && npm run lint-fix && cp .env.example .env && cp .env.test .env.test.local && npm run build && npm test"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
This file does not appear in the final package generation
|
|
6
|
+
|
|
7
|
+
You can think about this file like a post-generation script
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
|
+
const depsNames_1 = require("../../../depsNames");
|
|
8
|
+
const service_1 = require("../../../interfaces/_templates/init/service");
|
|
9
|
+
const index_1 = require("../../../prompt/index");
|
|
10
|
+
const choices = Object.values(service_1.ServiceDeps).map((choice) => ({ name: choice }));
|
|
11
|
+
exports.default = {
|
|
12
|
+
prompt: async ({ prompter }) => {
|
|
13
|
+
console.log(chalk_1.default.bold('After a files generation scaffold tries to run "npm install" and "prettier", please wait. \n'));
|
|
14
|
+
const { serviceName } = await prompter.prompt({
|
|
15
|
+
type: 'input',
|
|
16
|
+
name: 'serviceName',
|
|
17
|
+
message: "What's your new service name (e.g. super-gen)? Make sure new service is added to the ServiceName enum in the types package",
|
|
18
|
+
required: true,
|
|
19
|
+
});
|
|
20
|
+
const { description } = await prompter.prompt({
|
|
21
|
+
type: 'input',
|
|
22
|
+
name: 'description',
|
|
23
|
+
message: "What's your new service description?",
|
|
24
|
+
required: true,
|
|
25
|
+
});
|
|
26
|
+
const selectedOptions = await (0, index_1.promptMultiSelect)({
|
|
27
|
+
message: 'Which external dependencies do you want use with that service?',
|
|
28
|
+
choices,
|
|
29
|
+
});
|
|
30
|
+
console.log(chalk_1.default.red.bold('\n!!! REMINDER !!!\r'));
|
|
31
|
+
console.log(chalk_1.default.red.bold("Don't forget to add charts and envs to the infra repo manually\r"));
|
|
32
|
+
const { devDeps, deps } = depsNames_1.serviceDependencies;
|
|
33
|
+
return { serviceName, description, dependencies: { devDeps: devDeps.join(' '), deps: deps.join(' ') }, selectedOptions };
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../src/_templates/init/service/prompt.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AAEzB,kDAAwD;AAExD,yEAAkF;AAElF,iDAAyD;AAEzD,MAAM,OAAO,GAAwB,MAAM,CAAC,MAAM,CAAC,qBAAW,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAEnG,kBAAe;IACX,MAAM,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAU,EAAoB,EAAE;QACrD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8FAA8F,CAAC,CAAC,CAAA;QAEvH,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YAC1C,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EACH,4HAA4H;YAChI,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAA;QAEF,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YAC1C,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,sCAAsC;YAC/C,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAA;QAEF,MAAM,eAAe,GAAG,MAAM,IAAA,yBAAiB,EAAc;YACzD,OAAO,EAAE,gEAAgE;YACzE,OAAO;SACV,CAAC,CAAA;QAEF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACnD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC,CAAA;QAE/F,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,+BAAmB,CAAA;QAE7C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,eAAe,EAAE,CAAA;IAC5H,CAAC;CACJ,CAAA"}
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;;AACA,wCAAwC;AACxC,mBAAgB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serviceDependencies = exports.packageDependencies = void 0;
|
|
4
|
+
const devDeps = [
|
|
5
|
+
'@diia-inhouse/configs',
|
|
6
|
+
'@diia-inhouse/eslint-config',
|
|
7
|
+
'@diia-inhouse/test',
|
|
8
|
+
'@diia-inhouse/genproto',
|
|
9
|
+
'@diia-inhouse/test',
|
|
10
|
+
'@types/jest',
|
|
11
|
+
'eslint',
|
|
12
|
+
'jest',
|
|
13
|
+
'lockfile-lint',
|
|
14
|
+
'madge',
|
|
15
|
+
'prettier',
|
|
16
|
+
'rimraf',
|
|
17
|
+
'semantic-release',
|
|
18
|
+
'ts-node',
|
|
19
|
+
'ts-patch',
|
|
20
|
+
'typescript',
|
|
21
|
+
];
|
|
22
|
+
exports.packageDependencies = { devDeps };
|
|
23
|
+
exports.serviceDependencies = {
|
|
24
|
+
devDeps: [...devDeps, '@diia-inhouse/scaffold'],
|
|
25
|
+
deps: [
|
|
26
|
+
'@diia-inhouse/analytics',
|
|
27
|
+
'@diia-inhouse/crypto',
|
|
28
|
+
'@diia-inhouse/db',
|
|
29
|
+
'@diia-inhouse/diia-app',
|
|
30
|
+
'@diia-inhouse/diia-logger',
|
|
31
|
+
'@diia-inhouse/diia-queue',
|
|
32
|
+
'@diia-inhouse/diia-metrics',
|
|
33
|
+
'@diia-inhouse/env',
|
|
34
|
+
'@diia-inhouse/errors',
|
|
35
|
+
'@diia-inhouse/healthcheck',
|
|
36
|
+
'@diia-inhouse/http',
|
|
37
|
+
'@diia-inhouse/redis',
|
|
38
|
+
'@diia-inhouse/types',
|
|
39
|
+
'@diia-inhouse/utils',
|
|
40
|
+
'@diia-inhouse/validators',
|
|
41
|
+
'migrate-mongo',
|
|
42
|
+
'module-alias',
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=depsNames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depsNames.js","sourceRoot":"","sources":["../src/depsNames.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;IACZ,uBAAuB;IACvB,6BAA6B;IAC7B,oBAAoB;IACpB,wBAAwB;IACxB,oBAAoB;IACpB,aAAa;IACb,QAAQ;IACR,MAAM;IACN,eAAe;IACf,OAAO;IACP,UAAU;IACV,QAAQ;IACR,kBAAkB;IAClB,SAAS;IACT,UAAU;IACV,YAAY;CACf,CAAA;AAEY,QAAA,mBAAmB,GAAG,EAAE,OAAO,EAAE,CAAA;AAEjC,QAAA,mBAAmB,GAAG;IAC/B,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,wBAAwB,CAAC;IAC/C,IAAI,EAAE;QACF,yBAAyB;QACzB,sBAAsB;QACtB,kBAAkB;QAClB,wBAAwB;QACxB,2BAA2B;QAC3B,0BAA0B;QAC1B,4BAA4B;QAC5B,mBAAmB;QACnB,sBAAsB;QACtB,2BAA2B;QAC3B,oBAAoB;QACpB,qBAAqB;QACrB,qBAAqB;QACrB,qBAAqB;QACrB,0BAA0B;QAC1B,eAAe;QACf,cAAc;KACjB;CACJ,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
+
const hygen_1 = require("hygen");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
|
+
const defaultTemplates = node_path_1.default.resolve(__dirname, './_templates');
|
|
10
|
+
async function main() {
|
|
11
|
+
(0, hygen_1.runner)(process.argv.slice(2), {
|
|
12
|
+
logger: new hygen_1.Logger(console.log.bind(console)),
|
|
13
|
+
createPrompter: () => require('enquirer'),
|
|
14
|
+
exec: (action) => (0, utils_1.shExecutor)(action),
|
|
15
|
+
cwd: process.cwd(),
|
|
16
|
+
templates: defaultTemplates,
|
|
17
|
+
debug: Boolean(process.env.DEBUG),
|
|
18
|
+
helpers: utils_1.helpers,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
main();
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,0DAA4B;AAE5B,iCAAsC;AAEtC,mCAA6C;AAE7C,MAAM,gBAAgB,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAEhE,KAAK,UAAU,IAAI;IACf,IAAA,cAAM,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAC1B,MAAM,EAAE,IAAI,cAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;QACzC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,kBAAU,EAAC,MAAM,CAAC;QACpC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,SAAS,EAAE,gBAAgB;QAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;QACjC,OAAO,EAAP,eAAO;KACV,CAAC,CAAA;AACN,CAAC;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/action.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventListener.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/eventListener.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"externalEventListener.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/externalEventListener.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/generator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/model.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduledTask.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/scheduledTask.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/task.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/add/test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectJestType = void 0;
|
|
4
|
+
var ProjectJestType;
|
|
5
|
+
(function (ProjectJestType) {
|
|
6
|
+
ProjectJestType["Integration"] = "integration";
|
|
7
|
+
ProjectJestType["Unit"] = "unit";
|
|
8
|
+
})(ProjectJestType || (exports.ProjectJestType = ProjectJestType = {}));
|
|
9
|
+
//# sourceMappingURL=matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/init/matcher.ts"],"names":[],"mappings":";;;AAWA,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,8CAA2B,CAAA;IAC3B,gCAAa,CAAA;AACjB,CAAC,EAHW,eAAe,+BAAf,eAAe,QAG1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/init/package.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceDeps = void 0;
|
|
4
|
+
var ServiceDeps;
|
|
5
|
+
(function (ServiceDeps) {
|
|
6
|
+
ServiceDeps["database"] = "database";
|
|
7
|
+
ServiceDeps["redis"] = "redis";
|
|
8
|
+
ServiceDeps["external"] = "external";
|
|
9
|
+
ServiceDeps["internal"] = "internal";
|
|
10
|
+
})(ServiceDeps || (exports.ServiceDeps = ServiceDeps = {}));
|
|
11
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/interfaces/_templates/init/service.ts"],"names":[],"mappings":";;;AASA,IAAY,WAKX;AALD,WAAY,WAAW;IACnB,oCAAqB,CAAA;IACrB,8BAAe,CAAA;IACf,oCAAqB,CAAA;IACrB,oCAAqB,CAAA;AACzB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB"}
|