-
Notifications
You must be signed in to change notification settings - Fork 2
Move to typescript and mongodb #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| node_modules/ | ||
| docs/ | ||
| coverage/ | ||
| logs/ | ||
| *.log | ||
| src-old/ | ||
| bin/ | ||
| .idea/ | ||
| .vscode/ | ||
| .nyc_output/ | ||
| dist/ | ||
| *.log | ||
| __tests__/ | ||
| __test__/ | ||
| docs/ |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| auth.sample.json | ||
| auth.json | ||
| dist/ | ||
| *.zip | ||
| src-old/ | ||
| *.md |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,11 +10,11 @@ jobs: | |||||||||||||||||||
|
|
||||||||||||||||||||
| steps: | ||||||||||||||||||||
| - uses: actions/checkout@v2 | ||||||||||||||||||||
| - name: Use Node 14.x | ||||||||||||||||||||
| - name: Use Node 18.x | ||||||||||||||||||||
| uses: actions/setup-node@v2 | ||||||||||||||||||||
| with: | ||||||||||||||||||||
| node-version: '14.x' | ||||||||||||||||||||
| node-version: '18.x' | ||||||||||||||||||||
|
Comment on lines
+13
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update GitHub Actions setup-node action to a newer version The runner for "actions/setup-node@v2" is outdated according to GitHub Actions standards. Update to a newer version of the action: - - name: Use Node 18.x
- uses: actions/setup-node@v2
+ - name: Use Node 18.x
+ uses: actions/setup-node@v3
with:
node-version: '18.x'📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)14-14: the runner of "actions/setup-node@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) |
||||||||||||||||||||
| - run: npm ci | ||||||||||||||||||||
| - run: npm run test-cov --if-present | ||||||||||||||||||||
| - run: npm run test:cov --if-present | ||||||||||||||||||||
| - run: npm run lint | ||||||||||||||||||||
| - run: npm run pretty-check --if-present | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,69 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
|
|
||
| # Runtime data | ||
| pids | ||
| *.pid | ||
| *.seed | ||
| *.pid.lock | ||
|
|
||
| # Directory for instrumented libs generated by jscoverage/JSCover | ||
| lib-cov | ||
|
|
||
| # Coverage directory used by tools like istanbul | ||
| coverage | ||
|
|
||
| # nyc test coverage | ||
| .nyc_output | ||
|
|
||
| # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
| .grunt | ||
|
|
||
| # Bower dependency directory (https://bower.io/) | ||
| bower_components | ||
|
|
||
| # node-waf configuration | ||
| .lock-wscript | ||
|
|
||
| # Compiled binary addons (https://nodejs.org/api/addons.html) | ||
| build/Release | ||
|
|
||
| # Dependency directories | ||
| node_modules/ | ||
| jspm_packages/ | ||
|
|
||
| # TypeScript v1 declaration files | ||
| typings/ | ||
|
|
||
| # Optional npm cache directory | ||
| .npm | ||
|
|
||
| # Optional eslint cache | ||
| .eslintcache | ||
|
|
||
| # Optional REPL history | ||
| .node_repl_history | ||
|
|
||
| # Output of 'npm pack' | ||
| *.tgz | ||
|
|
||
| # Yarn Integrity file | ||
| .yarn-integrity | ||
|
|
||
| # dotenv environment variables file | ||
| .env | ||
|
|
||
| # next.js build output | ||
| .next | ||
|
|
||
| # VSCode | ||
| .vscode/ | ||
|
|
||
| # Project files | ||
| *.log | ||
| logs/ | ||
| old-src/ | ||
|
|
||
| dist/ | ||
|
|
||
| config/local*.js |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "source":"pino", | ||
| "pump":"logstashHttp", | ||
| "mode":"http", | ||
| "host":"localhost", | ||
| "port":6002, | ||
| "echo":true | ||
| } |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,17 @@ | |
| * Bolt is golang specific, Alternative needed. | ||
| * Possible Candidates | ||
| * https://github.com/weyoss/redis-smq | ||
|
|
||
| ## Docker cleanup commands | ||
|
|
||
| - Remove dangling images | ||
|
|
||
| ``` | ||
| docker rmi $(docker image ls -f dangling=true -q --no-trunc) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add safety checks to Docker cleanup commands. The current commands might fail or produce errors if no matching images are found. Consider adding safety checks. For the first command: -docker rmi $(docker image ls -f dangling=true -q --no-trunc)
+docker image ls -f dangling=true -q --no-trunc | xargs -r docker rmiFor the second command: -docker image ls | grep mds-sf- | awk '{print $3}' | xargs docker rmi
+docker image ls | grep mds-sf- | awk '{print $3}' | xargs -r docker rmiThe Also applies to: 47-47 |
||
| ``` | ||
|
|
||
| - Remove previously built MDS Serverless Functions images | ||
|
|
||
| ``` | ||
| docker image ls | grep mds-sf- | awk '{print $3}' | xargs docker rmi | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,39 @@ | ||
| FROM node:10-alpine | ||
| FROM node:18 as builder | ||
|
|
||
| WORKDIR /usr/src/app | ||
| COPY package*.json ./ | ||
| RUN npm ci | ||
| COPY . . | ||
| RUN npm run build | ||
|
|
||
| ########################### | ||
| FROM node:18-alpine | ||
|
|
||
| WORKDIR /usr/src/app | ||
|
|
||
| COPY package*.json ./ | ||
| COPY ./config/default.js ./config/default.js | ||
| RUN npm install --only=prod | ||
|
|
||
| COPY . . | ||
| COPY --from=builder /usr/src/app/dist . | ||
| # COPY --from=builder /usr/src/app/src/infrastructure/grpc/protos/*.proto ./infrastructure/grpc/protos/ | ||
| EXPOSE 8888 | ||
|
|
||
| ENTRYPOINT [ "node", "./bin/entrypoint" ] | ||
| CMD [ "server" ] | ||
| # NOTE: the mds state machine is broken up into two components. The first is the | ||
| # API server which is the presentation/server.js file. The second is the worker | ||
| # which is the /worker/entry-point.js file. | ||
| CMD [ "node", "./presentation/server.js" ] | ||
|
|
||
| # To ship logs to the ELK stack extend the above command | ||
| # with either pino-socket, pino-logstash or mds-log-pump. | ||
| # An example using mds-log-pump can be found in the mds | ||
| # stack configurations. This utilizes a simple config file | ||
| # and allows a out-of-process to handle shipping logs to | ||
| # the ELK stack. | ||
| # | ||
| # If you chose to use pino-socket or pino-logstash you will | ||
| # need to refer to their documentation for configuration. | ||
| # | ||
| # Ex: CMD [ "node", "./server.js", "|", "mds-log-pump"] | ||
| # Ex: CMD [ "node", "./server.js", "|", "pino-logstash", "-h", "elk", "-p", "5000" ] | ||
| # Ex: CMD [ "node", "./server.js", "|", "pino-socket", "-h", "elk", "-p", "5000" ] |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { mockFunctionsClient, mockQueueClient } from '../../src/test-utilities'; | ||
|
|
||
| module.exports = { | ||
| MdsSdk: { | ||
| getQueueServiceClient: jest | ||
| .fn() | ||
| .mockReturnValue(Promise.resolve(mockQueueClient)), | ||
| getServerlessFunctionsClient: jest | ||
| .fn() | ||
| .mockReturnValue(Promise.resolve(mockFunctionsClient)), | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,29 @@ | ||||||||||||||||||||||||||||||
| #!/usr/bin/env node | ||||||||||||||||||||||||||||||
| const mdsSdk = require('@maddonkeysoftware/mds-cloud-sdk-node'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const src = require('../src'); | ||||||||||||||||||||||||||||||
| const globals = require('../src/globals'); | ||||||||||||||||||||||||||||||
| const worker = require('../src/workers'); | ||||||||||||||||||||||||||||||
| const appShutdown = require('../src/handlers/app_shutdown'); | ||||||||||||||||||||||||||||||
| const src = require('../src-old'); | ||||||||||||||||||||||||||||||
| const globals = require('../src-old/globals'); | ||||||||||||||||||||||||||||||
| const worker = require('../src-old/workers'); | ||||||||||||||||||||||||||||||
| const appShutdown = require('../src-old/handlers/app_shutdown'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const directive = process.argv[2]; | ||||||||||||||||||||||||||||||
| const logger = globals.getLogger(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const ensureSystemQueuesExist = async () => { | ||||||||||||||||||||||||||||||
| // mds qs create --env localAdmin mds-sm-inFlightQueue && mds qs create --env localAdmin mds-sm-pendingQueue | ||||||||||||||||||||||||||||||
| const queueNames = ['mds-sm-inFlightQueue', 'mds-sm-pendingQueue']; | ||||||||||||||||||||||||||||||
| const client = await mdsSdk.getQueueServiceClient() | ||||||||||||||||||||||||||||||
| const existingQueues = await client.listQueues(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| for (const queueName of queueNames) { | ||||||||||||||||||||||||||||||
| const queueExists = existingQueues.some((q) => q.name === queueName); | ||||||||||||||||||||||||||||||
| if (!queueExists) { | ||||||||||||||||||||||||||||||
| logger.info(`Creating queue ${queueName}`); | ||||||||||||||||||||||||||||||
| await client.createQueue(queueName); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const launchServer = async () => { | ||||||||||||||||||||||||||||||
| await mdsSdk.initialize({ | ||||||||||||||||||||||||||||||
| identityUrl: process.env.MDS_IDENTITY_URL, | ||||||||||||||||||||||||||||||
|
|
@@ -18,7 +33,9 @@ const launchServer = async () => { | |||||||||||||||||||||||||||||
| sfUrl: process.env.MDS_SM_SF_URL, | ||||||||||||||||||||||||||||||
| qsUrl: process.env.MDS_SM_QS_URL, | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| appShutdown.wire(); | ||||||||||||||||||||||||||||||
| appShutdown.wire(() => process.exit(0)); | ||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider more graceful shutdown approach Using - appShutdown.wire(() => process.exit(0));
+ appShutdown.wire(async () => {
+ logger.info('Server shutdown initiated');
+ // Wait for connections to drain or timeout
+ try {
+ // Close any active connections
+ await app.close();
+ logger.info('Server shutdown complete');
+ process.exit(0);
+ } catch (err) {
+ logger.error({ err }, 'Error shutting down server');
+ process.exit(1);
+ }
+ });📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| await ensureSystemQueuesExist(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const port = process.env.APP_PORT || 8888; | ||||||||||||||||||||||||||||||
| const app = src.buildApp(); | ||||||||||||||||||||||||||||||
|
|
@@ -37,6 +54,8 @@ const launchWorker = async () => { | |||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| appShutdown.wire(worker.handleAppShutdown); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| await ensureSystemQueuesExist(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| worker.startWorker(); | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the redundant trailing semicolon.
There's an extra semicolon at the end of the file that should be removed.
📝 Committable suggestion
🧰 Tools
🪛 ESLint
[error] 40-41: Delete
;⏎(prettier/prettier)