Skip to content

Commit

Permalink
Merge branch 'develop' into cleanupAfterRedisMigration
Browse files Browse the repository at this point in the history
  • Loading branch information
malteish committed Sep 12, 2024
2 parents dd9ed94 + 5797454 commit bbb9844
Show file tree
Hide file tree
Showing 66 changed files with 3,443 additions and 840 deletions.
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"start": "yarn prisma-init && node ./dist/index.js",
"start-inspect": "node --inspect=0.0.0.0:9229 ./dist/index.js",
"test": "yarn run before:tests && DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests?schema=public' yarn jest --coverage --runInBand --transformIgnorePatterns 'node_modules/(?!(dm3-lib-\\w*)/)'",
"build": "yarn prisma generate && yarn tsc && cp ./config.yml ./dist/config.yml | true",
"build": "yarn prisma generate && yarn tsc | true",
"build:schema": "sh ./schemas.sh",
"createDeliveryServiceProfile": "node --no-warnings ./cli.js",
"before:tests": "docker compose -f docker-compose.test.yml up -d && DATABASE_URL='postgresql://prisma:prisma@localhost:5433/tests?schema=public' yarn prisma-init"
Expand Down
175 changes: 0 additions & 175 deletions packages/backend/src/config/getDeliveryServiceProperties.test.ts

This file was deleted.

60 changes: 0 additions & 60 deletions packages/backend/src/config/getDeliveryServiceProperties.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/delivery-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"start-inspect": "node --inspect=0.0.0.0:9229 ./dist/index.js",
"test": "yarn run before:tests && jest --coverage --runInBand --transformIgnorePatterns 'node_modules/(?!(dm3-lib-\\w*)/)' ",
"build": "yarn tsc ",
"dev": "nodemon --exec 'ts-node ./src/index.ts' --watch src --ext ts",
"createDeliveryServiceProfile": "node --no-warnings ./cli.js",
"before:tests": "docker compose -f docker-compose.test.yml up -d",
"after:tests": "docker compose -f docker-compose.test.yml down"
Expand All @@ -45,6 +46,7 @@
"babel-preset-env": "^1.7.0",
"jest": "^29.2.2",
"jest-mock-extended": "2.0.4",
"nodemon": "^3.1.4",
"prettier": "^2.6.2",
"superagent": "^8.0.3",
"supertest": "^6.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ describe('ReadDeliveryServiceProperties', () => {
messageTTL: 12345,
sizeLimit: 456,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 600,
metricsRetentionDurationInSeconds: 172800,
});

expect(config).toStrictEqual({
messageTTL: 12345,
sizeLimit: 456,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 600,
metricsRetentionDurationInSeconds: 172800,
});
});

Expand All @@ -37,6 +41,8 @@ describe('ReadDeliveryServiceProperties', () => {
messageTTL: 12345,
sizeLimit: 456,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 900,
metricsRetentionDurationInSeconds: 259200,
}),
{ encoding: 'utf-8' },
);
Expand All @@ -46,8 +52,11 @@ describe('ReadDeliveryServiceProperties', () => {
messageTTL: 12345,
sizeLimit: 456,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 900,
metricsRetentionDurationInSeconds: 259200,
});
});

it('Adds default properties if config.yml is not fully specified', () => {
writeFileSync(
path,
Expand All @@ -68,6 +77,7 @@ describe('ReadDeliveryServiceProperties', () => {
},
},
],
metricsCollectionIntervalInSeconds: 1200,
}),
{ encoding: 'utf-8' },
);
Expand All @@ -91,8 +101,11 @@ describe('ReadDeliveryServiceProperties', () => {
},
},
],
metricsCollectionIntervalInSeconds: 1200,
metricsRetentionDurationInSeconds: 60 * 60 * 24 * 10,
});
});

it('Adds email channel from config.yml file & rest from default properties', () => {
writeFileSync(
path,
Expand Down Expand Up @@ -135,6 +148,8 @@ describe('ReadDeliveryServiceProperties', () => {
},
},
],
metricsCollectionIntervalInSeconds: 60 * 60 * 24,
metricsRetentionDurationInSeconds: 60 * 60 * 24 * 10,
});
});

Expand Down Expand Up @@ -170,6 +185,28 @@ describe('ReadDeliveryServiceProperties', () => {
},
},
],
metricsCollectionIntervalInSeconds: 60 * 60 * 24,
metricsRetentionDurationInSeconds: 60 * 60 * 24 * 10,
});
});

it('Uses default values for metrics properties if not specified', () => {
writeFileSync(
path,
stringify({
messageTTL: 54321,
sizeLimit: 789,
}),
{ encoding: 'utf-8' },
);
const config = getDeliveryServiceProperties(path);

expect(config).toStrictEqual({
messageTTL: 54321,
sizeLimit: 789,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 60 * 60 * 24,
metricsRetentionDurationInSeconds: 60 * 60 * 24 * 10,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const DEFAULT_DELIVERY_SERVICE_PROPERTIES: DeliveryServiceProperties = {
//100Kb
sizeLimit: 100000,
notificationChannel: [],
metricsCollectionIntervalInSeconds: 60 * 60 * 24, // 1 day
metricsRetentionDurationInSeconds: 60 * 60 * 24 * 10, // 10 days
};

export function getDeliveryServiceProperties(
Expand Down
6 changes: 2 additions & 4 deletions packages/delivery-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { Profile } from './profile/profile';
import RpcProxy from './rpc/rpc-proxy';
import { WebSocketManager } from './ws/WebSocketManager';
import { socketAuth } from './socketAuth';
import Metrics from './metrics';

const app = express();
app.use(express.json({ limit: '50mb' }));
Expand Down Expand Up @@ -139,10 +140,7 @@ app.use(bodyParser.json());
return res.status(200).send('Hello DM3');
});

//Auth
//socketAuth
//restAuth

app.use('/metrics', Metrics(db, deliveryServiceProperties));
app.use('/auth', Authenticate(db, serverSecret, web3Provider));
app.use('/profile', Profile(db, web3Provider, serverSecret));
app.use('/delivery', Delivery(web3Provider, db, serverSecret));
Expand Down
1 change: 1 addition & 0 deletions packages/delivery-service/src/message/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export class MessageProcessor {
deliveryInformation,
this.db.getUsersNotificationChannels,
);
await this.db.countNotification(this.deliveryServiceProperties);
} catch (err) {
console.log(
'Unable to send Notification. There might be an error in the config.yml. Message has been received regardless',
Expand Down
Loading

0 comments on commit bbb9844

Please sign in to comment.