diff --git a/Dockerfile b/Dockerfile index 70aae75..510f968 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,6 @@ FROM node:18-bullseye-slim AS builder WORKDIR /app COPY . . -COPY ./config/config.template.ts ./config/index.ts RUN apt-get update -y && apt-get install g++ python3 make -y && yarn cache clean && yarn install && yarn build && rm -rf node_modules/ && yarn install --production # Production stage diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..3807fe3 --- /dev/null +++ b/config.yml @@ -0,0 +1,28 @@ +urls: &urls + backend_url: &backend_url "http://wallet-backend-server:8002" + wallet_url: &wallet_url "http://localhost:3000" + wallet_host: &wallet_host "localhost" + +backend: + url: *backend_url + port: 8002 + appSecret: dsfkwfkwfwdfdsfSaSe2e34r4frwr42rAFdsf2lfmfsmklfwmer + ssl: SSL_FLAG + db: + host: wallet-db + port: 3307 + username: root + password: root + dbname: wallet + walletClientUrl: *wallet_url + webauthn: + attestation: direct + origin: *wallet_url + rp: + id: *wallet_host + name: wwWallet demo + alg: EdDSA + notifications: + enabled: true + serviceAccount: firebaseConfig.json + diff --git a/config/config.template.ts b/config/config.template.ts deleted file mode 100644 index 591ce73..0000000 --- a/config/config.template.ts +++ /dev/null @@ -1,27 +0,0 @@ -export const config = { - url: "SERVICE_URL", - port: "SERVICE_PORT", - appSecret: "SERVICE_SECRET", - ssl: "SSL_FLAG", - db: { - host: "DB_HOST", - port: "DB_PORT", - username: "DB_USER", - password: "DB_PASSWORD", - dbname: "DB_NAME" - }, - walletClientUrl: "WALLET_CLIENT_URL", - webauthn: { - attestation: "direct", - origin: "WEBAUTHN_ORIGIN", - rp: { - id: "WEBAUTHN_RP_ID", - name: "wwWallet demo", - }, - }, - alg: "EdDSA", - notifications: { - enabled: "NOTIFICATIONS_ENABLED", - serviceAccount: "firebaseConfig.json" - } -} diff --git a/config/index.ts b/config/index.ts new file mode 100644 index 0000000..6efe73b --- /dev/null +++ b/config/index.ts @@ -0,0 +1,35 @@ +import path from 'node:path'; +import fs from 'node:fs'; +import { parse } from 'yaml'; + +const yamlConfig = fs.readFileSync(path.join(process.cwd(), 'config.yml')).toString() + +console.log(parse(yamlConfig)); + +export const config: { + url: string; + port: string; + appSecret: string; + ssl: string; + db: { + host: string; + port: string; + username: string; + password: string; + dbname: string; + } + walletClientUrl: string; + webauthn: { + attestation: string; + origin: string; + rp: { + id: string; + name: string; + } + } + alg: string; + notifications: { + enabled: string; + serviceAccount: string; + } +}= parse(yamlConfig).backend diff --git a/package.json b/package.json index 523e6f2..61526c2 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "typeorm": "^0.3.9", "uuid": "^9.0.0", "ws": "^8.14.1", + "yaml": "^2.8.1", "zod": "^3.21.4" }, "devDependencies": {