Skip to content

Commit 7907ba9

Browse files
feat: refactor structure, prepare for new cli
1 parent e5352ff commit 7907ba9

File tree

196 files changed

+10675
-11217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+10675
-11217
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
with:
137137
name: "Lomray-Software/microservices/${{ env.MICROSERVICE_NAME }}"
138138
tags: "latest${{ needs.changed-microservices.outputs.docker-tag }},${{ steps.package-version.outputs.version}}"
139-
dockerfile: Dockerfile-nodejs
139+
dockerfile: node_modules/@lomray/microservice-config/Dockerfile-nodejs
140140
context: ${{ env.WORK_DIR }}
141141
buildoptions: "--compress --force-rm --no-cache"
142142
username: ${{ github.actor }}

Dockerfile-nodejs

Lines changed: 0 additions & 18 deletions
This file was deleted.

microservices/attachments/.mocharc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module.exports = {
2-
ui: 'bdd',
3-
timeout: 5000,
4-
extension: ['ts'],
5-
watchFiles: ['__tests__/**/*.ts', 'src/**/*.ts'],
6-
require: ['./__helpers__/sinon-chai.ts', './__helpers__/root-hooks.ts'],
2+
...require('@lomray/microservice-config/mocharc'),
73
};

microservices/attachments/README.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,13 @@ A microservice provides work with attachments for entities from other microservi
2323
- [MEMORY USAGE](#memory-usage)
2424

2525
### <a id="environments"></a>ENVIRONMENTS:
26-
- `NODE_ENV` - Can be `production` or `development` or `tests`. Default: `development`
27-
- `MS_CONNECTION` - Invert json host and port (with protocol). Default: `http://127.0.0.1:8001`
28-
- `MS_CONNECTION_SRV` - Invert json connection it is SRV record. Default: `false`
29-
- `MS_NAME` - Microservice name. Default: `attachments`
30-
- `MS_CONFIG_NAME` - Configuration microservice name. Default: `configuration`
31-
- `MS_WORKERS` - Microservice queue workers count. Default: `1`
32-
- `MS_ENABLE_REMOTE_MIDDLEWARE` - Enable remote middleware feature. Set `0` to disable. Default: `1` (enabled)
3326
- `MS_STORAGE_TYPE` - Microservice storage type.
34-
- `DB_FROM_CONFIG_MS` - Get db credentials from configuration microservice. Set `0` to disable. Default: `1`
35-
- `DB_URL` - Database url connection string. Default: `undefined`. Please use URL or credentials.
36-
- `DB_HOST` - Database host. Default: `127.0.0.1`
37-
- `DB_PORT` - Database port. Default: `5432`
38-
- `DB_USERNAME` - Database user name. Default: `postgres`
39-
- `DB_PASSWORD` - Database password. Default: `example`
40-
- `DB_DATABASE` - Database db name. Default: `ms-users`
41-
- `MS_GRAFANA_LOKI_CONFIG` - Grafana loki config. Default: `null`
42-
- `MS_ENABLE_GRAFANA_LOG` - Enable grafana loki log (config from configuration ms). Default: `0`
43-
- `MS_OPENTELEMETRY_ENABLE` - Enable opentelemetry tracers. Default: `0`
44-
- `MS_OPENTELEMETRY_OTLP_URL` - Custom opentelemetry OTLP exporter URL. Default: `undefined`
45-
- `MS_OPENTELEMETRY_OTLP_URL_SRV` - Custom opentelemetry OTLP URL it is SRV record. Default: `0`
46-
- `MS_OPENTELEMETRY_DEBUG` - Enable debug log opentelemetry. Default: `0`
47-
- `AWS_ACCESS_KEY_ID` - AWS access key ID, if you will use S3 to store files (if not configured from remote config.). Default: `empty`
48-
- `AWS_SECRET_ACCESS_KEY` - AWS secret access key, if you will use S3 to store files (if not configured from remote config.) Default: `empty`
49-
- `AWS_REGION` - AWS region, if you will use S3 to store files (if not configured from remote config.) Default: `empty`
50-
- `AWS_BUCKET_NAME` - AWS S3 bucket name, if you will use S3 to store files (if not configured from remote config.) Default: `empty`
51-
- `AWS_BUCKET_ACL` - AWS S3 bucket ACL (e.g.: public-read). Default: `empty`
52-
- `AWS_FROM_CONFIG_MS` - Get AWS credentials from configuration microservice. Set `0` to disable. Default: `1`
5327
- `MS_STORAGE_DOMAIN` - Access to attachments through storage domain. Default: ``
5428
- `STORAGE_PATH_PREFIX` - Path (url) prefix for attachments. Default: `empty`
5529
- `IMAGE_CONFIG_FROM_CONFIG_MS` - Get image processing configuration from configuration microservice. Set `0` to disable. Default: `1`
5630
- `IMAGE_PROCESSING_CONFIG` - Image processing configuration JSON string. Default: `{}`
5731
- `LOCAL_STORAGE_PATH` - Directory where files are saved for local storage provider. Default: `data/files`
58-
- `MS_CONSOLE_LOG_LEVEL` - Change console log level. Default: `info`
32+
- [See full list `COMMON ENVIRONMENTS`](https://github.com/Lomray-Software/microservice-helpers#common-environments)
5933

6034
### <a id="how-to-run"></a>HOW TO RUN:
6135
1. Run `Inverted Json` job server.

microservices/attachments/__tests__/index-test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { Log } from '@lomray/microservice-helpers';
21
import { expect } from 'chai';
32
import rewiremock from 'rewiremock';
43
import sinon from 'sinon';
5-
import { msParams } from '@config/ms';
64

75
describe('microservice: start', () => {
86
const sandbox = sinon.createSandbox();
@@ -26,15 +24,4 @@ describe('microservice: start', () => {
2624
expect(args).to.have.property('msParams');
2725
expect(args).to.have.property('registerMethods');
2826
});
29-
30-
it('should have microservice custom logger', () => {
31-
const { logDriver } = msParams;
32-
const LogInfoSpy = sandbox.spy(Log, 'log');
33-
34-
if (typeof logDriver !== 'boolean') {
35-
logDriver?.(() => 'test');
36-
}
37-
38-
expect(LogInfoSpy).to.calledOnce;
39-
});
4027
});

microservices/attachments/__tests__/methods/meta-test.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

microservices/attachments/__tests__/services/attachment/image-test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sinon from 'sinon';
55
import { getRepository } from 'typeorm';
66
import { bucketNameMock } from '@__mocks__/common';
77
import AttachmentType from '@constants/attachment-type';
8-
import { IMAGE_CONFIG_FROM_CONFIG_MS, IMAGE_PROCESSING_CONFIG } from '@constants/index';
8+
import CONST from '@constants/index';
99
import StorageType from '@constants/storage-type';
1010
import Attachment from '@entities/attachment';
1111
import Image from '@services/attachment/image';
@@ -29,8 +29,8 @@ describe('services/attachment/image', () => {
2929

3030
const storage = await StorageFactory.create(StorageType.s3);
3131
const config = await ImageProcessingConfig.get({
32-
isFromConfigMs: IMAGE_CONFIG_FROM_CONFIG_MS,
33-
config: IMAGE_PROCESSING_CONFIG,
32+
isFromConfigMs: CONST.IS_IMAGE_CONFIG_FROM_CONFIG_MS,
33+
config: CONST.IMAGE_PROCESSING_CONFIG,
3434
});
3535

3636
const service = new Image(AttachmentType.image, TypeormMock.entityManager, storage, config);
@@ -59,8 +59,8 @@ describe('services/attachment/image', () => {
5959

6060
const storage = await StorageFactory.create('S3');
6161
const config = await ImageProcessingConfig.get({
62-
isFromConfigMs: IMAGE_CONFIG_FROM_CONFIG_MS,
63-
config: IMAGE_PROCESSING_CONFIG,
62+
isFromConfigMs: CONST.IS_IMAGE_CONFIG_FROM_CONFIG_MS,
63+
config: CONST.IMAGE_PROCESSING_CONFIG,
6464
});
6565

6666
const service = new Image(AttachmentType.image, TypeormMock.entityManager, storage, config);
@@ -81,8 +81,8 @@ describe('services/attachment/image', () => {
8181

8282
const storage = await StorageFactory.create('S3');
8383
const config = await ImageProcessingConfig.get({
84-
isFromConfigMs: IMAGE_CONFIG_FROM_CONFIG_MS,
85-
config: IMAGE_PROCESSING_CONFIG,
84+
isFromConfigMs: CONST.IS_IMAGE_CONFIG_FROM_CONFIG_MS,
85+
config: CONST.IMAGE_PROCESSING_CONFIG,
8686
});
8787

8888
const service = new Image(AttachmentType.image, TypeormMock.entityManager, storage, config);

microservices/attachments/__tests__/services/external/image-processing-config-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('services/external/s3-aws-sdk', () => {
1818
it('should successfully create instance with options', async () => {
1919
ImageProcessingConfig.reset();
2020

21-
const configMs = await ImageProcessingConfig.get({ isFromConfigMs: 0, config });
21+
const configMs = await ImageProcessingConfig.get({ isFromConfigMs: false, config });
2222

2323
expect(configMs).to.deep.equal(config);
2424
});
@@ -34,7 +34,7 @@ describe('services/external/s3-aws-sdk', () => {
3434
sandbox.stub(RemoteConfig, 'get').resolves(fromRemoteConfig);
3535

3636
const remoteConfig = await ImageProcessingConfig.get({
37-
isFromConfigMs: 1,
37+
isFromConfigMs: true,
3838
config,
3939
});
4040

microservices/attachments/__tests__/services/external/s3-aws-sdk-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('services/external/s3-aws-sdk', () => {
2020
bucketName: bucketNameMock,
2121
};
2222

23-
const { s3, bucketName } = await S3AwsSdk.get({ isFromConfigMs: 0, options });
23+
const { s3, bucketName } = await S3AwsSdk.get({ isFromConfigMs: false, options });
2424

2525
expect(s3.config.accessKeyId).to.equal(options.accessKeyId);
2626
expect(s3.config.secretAccessKey).to.equal(options.secretAccessKey);
@@ -40,7 +40,7 @@ describe('services/external/s3-aws-sdk', () => {
4040

4141
sandbox.stub(RemoteConfig, 'get').resolves(fromRemoteConfig);
4242

43-
const { s3, bucketName } = await S3AwsSdk.get({ isFromConfigMs: 1 });
43+
const { s3, bucketName } = await S3AwsSdk.get({ isFromConfigMs: true });
4444

4545
expect(s3.config.accessKeyId).to.equal(fromRemoteConfig.accessKeyId);
4646
expect(s3.config.secretAccessKey).to.equal(fromRemoteConfig.secretAccessKey);

microservices/attachments/__tests__/services/storage/s3-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import S3Storage from '@services/storage/s3';
99

1010
describe('services/attachment/image', () => {
1111
const options = {
12-
isFromConfigMs: 1,
12+
isFromConfigMs: true,
1313
options: {
1414
accessKeyId: 'access_key_id',
1515
secretAccessKey: 'secret_access_key',

0 commit comments

Comments
 (0)