From f6640438a031bd76aa61f6f96291cd6159522dcf Mon Sep 17 00:00:00 2001 From: anilb Date: Tue, 9 Jan 2024 13:44:40 +0100 Subject: [PATCH] cache_worker scaffold start --- services/apps/cache_worker/.eslintrc.cjs | 21 ++++++++++ services/apps/cache_worker/.prettierignore | 3 ++ services/apps/cache_worker/.prettierrc.cjs | 7 ++++ services/apps/cache_worker/package.json | 47 ++++++++++++++++++++++ services/apps/cache_worker/src/main.ts | 31 ++++++++++++++ services/apps/cache_worker/tsconfig.json | 18 +++++++++ 6 files changed, 127 insertions(+) create mode 100644 services/apps/cache_worker/.eslintrc.cjs create mode 100644 services/apps/cache_worker/.prettierignore create mode 100644 services/apps/cache_worker/.prettierrc.cjs create mode 100644 services/apps/cache_worker/package.json create mode 100644 services/apps/cache_worker/src/main.ts create mode 100644 services/apps/cache_worker/tsconfig.json diff --git a/services/apps/cache_worker/.eslintrc.cjs b/services/apps/cache_worker/.eslintrc.cjs new file mode 100644 index 0000000000..25ba4e0d66 --- /dev/null +++ b/services/apps/cache_worker/.eslintrc.cjs @@ -0,0 +1,21 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + plugins: ['@typescript-eslint', 'prettier'], + parserOptions: { + ecmaVersion: 2022, + sourceType: 'module', + }, + env: { + es6: true, + node: true, + }, + rules: { + 'prettier/prettier': 'error', + '@typescript-eslint/explicit-module-boundary-types': 'off', + }, +} diff --git a/services/apps/cache_worker/.prettierignore b/services/apps/cache_worker/.prettierignore new file mode 100644 index 0000000000..2b24877309 --- /dev/null +++ b/services/apps/cache_worker/.prettierignore @@ -0,0 +1,3 @@ +dist/ +.eslintrc.cjs +.prettierrc.cjs diff --git a/services/apps/cache_worker/.prettierrc.cjs b/services/apps/cache_worker/.prettierrc.cjs new file mode 100644 index 0000000000..a8ca459839 --- /dev/null +++ b/services/apps/cache_worker/.prettierrc.cjs @@ -0,0 +1,7 @@ +module.exports = { + singleQuote: true, + arrowParens: 'always', + printWidth: 100, + trailingComma: 'all', + semi: false, +} diff --git a/services/apps/cache_worker/package.json b/services/apps/cache_worker/package.json new file mode 100644 index 0000000000..99b8591812 --- /dev/null +++ b/services/apps/cache_worker/package.json @@ -0,0 +1,47 @@ +{ + "name": "@crowd/merge-suggestions-worker", + "version": "1.0.0", + "private": true, + "scripts": { + "start": "CROWD_TEMPORAL_TASKQUEUE=merge-suggestions SERVICE=merge-suggestions-worker TS_NODE_TRANSPILE_ONLY=true node -r tsconfig-paths/register -r ts-node/register src/main.ts", + "start:debug:local": "set -a && . ../../../backend/.env.dist.local && . ../../../backend/.env.override.local && set +a && CROWD_TEMPORAL_TASKQUEUE=merge-suggestions SERVICE=merge-suggestions-worker TS_NODE_TRANSPILE_ONLY=true LOG_LEVEL=trace node --inspect=0.0.0.0:9232 -r tsconfig-paths/register -r ts-node/register src/main.ts", + "start:debug": "CROWD_TEMPORAL_TASKQUEUE=merge-suggestions SERVICE=merge-suggestions-worker TS_NODE_TRANSPILE_ONLY=true LOG_LEVEL=trace node --inspect=0.0.0.0:9232 -r tsconfig-paths/register -r ts-node/register src/main.ts", + "dev:local": "./node_modules/.bin/nodemon --watch src --watch ../../libs --ext ts --exec pnpm run start:debug:local", + "dev": "./node_modules/.bin/nodemon --watch src --watch ../../libs --ext ts --exec pnpm run start:debug", + "lint": "./node_modules/.bin/eslint --ext .ts src --max-warnings=0", + "format": "./node_modules/.bin/prettier --write \"src/**/*.ts\"", + "format-check": "./node_modules/.bin/prettier --check .", + "tsc-check": "./node_modules/.bin/tsc --noEmit" + }, + "dependencies": { + "@crowd/archetype-standard": "file:../../archetypes/standard", + "@crowd/archetype-worker": "file:../../archetypes/worker", + "@crowd/common": "file:../../libs/common", + "@crowd/cubejs": "file:../../libs/cubejs", + "@crowd/types": "file:../../libs/types", + "@crowd/feature-flags": "file:../../libs/feature-flags", + "@temporalio/activity": "~1.8.6", + "@temporalio/client": "~1.8.6", + "@temporalio/workflow": "~1.8.6", + "axios": "~1.5.1", + "fast-levenshtein": "^3.0.0", + "html-to-text": "~9.0.5", + "lodash": "~4.17.21", + "moment": "~2.29.4", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "^5.2.2", + "uuid": "~9.0.1" + }, + "devDependencies": { + "@types/node": "^20.8.2", + "@types/uuid": "~9.0.6", + "@typescript-eslint/eslint-plugin": "^6.7.4", + "@typescript-eslint/parser": "^6.7.4", + "eslint": "^8.50.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "nodemon": "^3.0.1", + "prettier": "^3.0.3" + } +} diff --git a/services/apps/cache_worker/src/main.ts b/services/apps/cache_worker/src/main.ts new file mode 100644 index 0000000000..840b025af4 --- /dev/null +++ b/services/apps/cache_worker/src/main.ts @@ -0,0 +1,31 @@ +import { Config } from '@crowd/archetype-standard' +import { ServiceWorker, Options } from '@crowd/archetype-worker' + +const config: Config = { + envvars: [], + producer: { + enabled: false, + }, + temporal: { + enabled: true, + }, + redis: { + enabled: true, + }, +} + +const options: Options = { + postgres: { + enabled: true, + }, + opensearch: { + enabled: false, + }, +} + +export const svc = new ServiceWorker(config, options) + +setImmediate(async () => { + await svc.init() + await svc.start() +}) diff --git a/services/apps/cache_worker/tsconfig.json b/services/apps/cache_worker/tsconfig.json new file mode 100644 index 0000000000..e20e712429 --- /dev/null +++ b/services/apps/cache_worker/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es2017", + "module": "Node16", + "lib": ["es6", "es7", "es2017", "es2017.object", "es2015.promise", "ES2021.String"], + "skipLibCheck": true, + "sourceMap": true, + "moduleResolution": "node16", + "experimentalDecorators": true, + "esModuleInterop": true, + "baseUrl": "./src", + "paths": { + "@crowd/*": ["../../../libs/*/src"], + "@crowd/archetype-*": ["../../../archetypes/*/src"] + } + }, + "include": ["src/**/*"] +}