Skip to content

Commit

Permalink
feat: rewrite chat service
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladivo committed Oct 29, 2024
1 parent 181583a commit f166bcc
Show file tree
Hide file tree
Showing 107 changed files with 7,239 additions and 152 deletions.
26 changes: 26 additions & 0 deletions apps/chat-service/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

NODE_ENV=test
LOGIN_CODE_DUMMY_NUMBERS=+420733333331
LOGIN_CODE_DUMMY_CODE=111111

SECRET_PUBLIC_KEY="LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUZZd0VBWUhLb1pJemowQ0FRWUZLNEVFQUFvRFFnQUVidE9rYzJ0RmZ5VHhkVmxqSzlPQUZGYXFMMVRwU3FUaQpLbGpNenVPbjh5WjVUM3I4c04vdmUvbWdlUzg4ckNBZ29tVnJpK2pMdFU1WXQvVzlVbVozS1E9PQotLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0K"
SECRET_PRIVATE_KEY="LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JR0VBZ0VBTUJBR0J5cUdTTTQ5QWdFR0JTdUJCQUFLQkcwd2F3SUJBUVFnK0Raa0VIMHN0K1VjcmhHTkhGRVgKL0RKVkFaZmtwMjlMSTZ3eERwbHVubDJoUkFOQ0FBUnUwNlJ6YTBWL0pQRjFXV01yMDRBVVZxb3ZWT2xLcE9JcQpXTXpPNDZmekpubFBldnl3Mys5NythQjVMenlzSUNDaVpXdUw2TXUxVGxpMzliMVNabmNwCi0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K"
SECRET_HMAC_KEY=test
SECRET_EAS_KEY=VexlVexl
DB_DEBUG=true

# Local db
# DB_URL=postgresql://localhost:5432
# DB_USER=postgres
# DB_PASSWORD=root

TEST_DB_PREFIX=chat_service_test_
TEST_DB_PORT=5432
TEST_DB_USER=postgres
TEST_DB_PASSWORD=root
# TEST_KEEP_DB=false
# TEST_DB_FORCE_NAME=offer_service_test_ef4fba48e4174743864e39ac439dd7a9


CHALLENGE_EXPIRATION_MINUTES=10
REQUEST_TIMEOUT_DAYS=1
1 change: 1 addition & 0 deletions apps/chat-service/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
29 changes: 29 additions & 0 deletions apps/chat-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM node:19 as builder

WORKDIR /app

COPY . .

WORKDIR /app/apps/chat-service

RUN yarn workspaces focus @vexl-next/chat-service
RUN yarn build
# RUN npx @sentry/wizard@latest -i sourcemaps


FROM node:19 as runner


ARG SERVICE_VERSION
ARG ENVIRONMENT

ENV SERVICE_VERSION=${SERVICE_VERSION}
ENV SERVICE_NAME="Chat service - ${ENVIRONMENT}"

COPY --from=builder /app/apps/chat-service/ /app/apps/chat-service
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package.json /app/package.json

WORKDIR /app/apps/chat-service

CMD ["node", "dist/index.cjs"]
3 changes: 3 additions & 0 deletions apps/chat-service/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import esbuild from '@vexl-next/esbuild'

void esbuild()
12 changes: 12 additions & 0 deletions apps/chat-service/jest.afterenv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
disposeRuntime,
startRuntime,
} from './src/__tests__/utils/runPromiseInMockedEnvironment'

beforeAll(async () => {
await startRuntime()
})

afterAll(async () => {
await disposeRuntime()
})
29 changes: 29 additions & 0 deletions apps/chat-service/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type {JestConfigWithTsJest} from 'ts-jest'

const config: JestConfigWithTsJest = {
preset: 'ts-jest',
verbose: true,

testEnvironment: 'node',
extensionsToTreatAsEsm: ['.ts'],
setupFiles: ['<rootDir>/jest.setup.ts'],
setupFilesAfterEnv: ['<rootDir>/jest.afterenv.ts'],

testTimeout: 20000,
testMatch: ['**/*.test.ts'], // This line ensures only files with .test.ts suffix are run
transform: {
'^.+\\.(ts|js)$': [
'ts-jest',
{
useESM: true,
tsconfig: {
module: 'ESNext',
rootDir: '../..',
allowJs: true,
},
},
],
},
}

export default config
3 changes: 3 additions & 0 deletions apps/chat-service/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import dotenv from 'dotenv'

dotenv.config({path: '.env.test'})
77 changes: 77 additions & 0 deletions apps/chat-service/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "@vexl-next/chat-service",
"main": "dist/index.js",
"type": "module",
"scripts": {
"test": "TEST_DB_HOST=localhost yarn jest",
"test:watch": "NODE_OPTIONS=--experimental-vm-modules yarn jest --watch",
"build": "yarn typecheck && yarn build:esbuild",
"build:esbuild": "node esbuild.config.js",
"typecheck": "tsc --noEmit",
"clean": "rimraf ./dist",
"format": "prettier --check \"**/*.{js,mjs,cjs,jsx,ts,tsx,md,json}\"",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
"dev": "npx tsx -r dotenv/config src/index.ts",
"start": "node dist"
},
"eslintConfig": {
"root": true,
"extends": [
"@vexl-next/eslint-config/index"
]
},
"dependencies": {
"@effect/experimental": "^0.22.6",
"@effect/opentelemetry": "^0.35.3",
"@effect/platform": "^0.62.3",
"@effect/platform-node": "^0.56.9",
"@effect/schema": "^0.70.4",
"@effect/sql": "^0.8.7",
"@effect/sql-pg": "^0.8.7",
"@opentelemetry/exporter-trace-otlp-http": "^0.52.1",
"@opentelemetry/sdk-trace-node": "^1.23.0",
"@opentelemetry/sdk-trace-web": "^1.23.0",
"@sentry/esbuild-plugin": "^2.10.2",
"@sentry/node": "^7.93.0",
"@sentry/profiling-node": "^1.3.5",
"@vexl-next/cryptography": "0.0.0",
"@vexl-next/domain": "0.0.0",
"@vexl-next/generic-utils": "0.0.0",
"@vexl-next/rest-api": "0.0.0",
"@vexl-next/server-utils": "0.0.0",
"dayjs": "^1.11.11",
"dotenv": "^16.4.5",
"effect": "^3.6.3",
"effect-http": "^0.77.4",
"effect-http-node": "^0.17.7",
"fast-check": "^3.20.0",
"firebase-admin": "^12.3.1",
"ioredis": "^5.4.1",
"node-fetch": "^3.3.2",
"pg": "^8.12.0",
"twilio": "^5.2.1"
},
"devDependencies": {
"@types/jest": "^29.4.0",
"@types/pg": "^8",
"@types/source-map-support": "^0.5.10",
"@vexl-next/esbuild": "0.0.0",
"@vexl-next/eslint-config": "0.0.0",
"@vexl-next/prettier-config": "0.0.0",
"@vexl-next/tsconfig": "0.0.0",
"esbuild": "^0.17.16",
"eslint": "^8.50.0",
"glob": "^11.0.0",
"jest": "^29.7.0",
"nodemon": "^2.0.21",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.2",
"rimraf": "^4.4.0",
"ts-jest": "^29.2.0",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.10",
"tsx": "^4.16.0",
"typescript": "^5.5.2"
},
"prettier": "@vexl-next/prettier-config"
}
Loading

0 comments on commit f166bcc

Please sign in to comment.