From d236b31d9f16f51cfbcb1610ce8b17d341824ea6 Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Tue, 24 Jan 2023 21:39:13 +0530 Subject: [PATCH 1/4] Support to send messages via chosen SMS adapter (can be configured using environment variable `SMS_ADAPTER_TYPE`) --- docker-compose.yml | 20 +++++- sample.env | 17 ++++- src/app.module.ts | 11 ++++ src/app.service.ts | 55 ++--------------- src/sms-adapter/cdac/cdac.service.spec.ts | 18 ++++++ src/sms-adapter/cdac/cdac.service.ts | 68 ++++++++++++++++++++ src/sms-adapter/sms-adapter.interface.ts | 3 + src/sms-adapter/uci/uci.service.spec.ts | 18 ++++++ src/sms-adapter/uci/uci.service.ts | 75 +++++++++++++++++++++++ src/sms.templates.ts | 40 ++++++++++-- 10 files changed, 268 insertions(+), 57 deletions(-) create mode 100644 src/sms-adapter/cdac/cdac.service.spec.ts create mode 100644 src/sms-adapter/cdac/cdac.service.ts create mode 100644 src/sms-adapter/sms-adapter.interface.ts create mode 100644 src/sms-adapter/uci/uci.service.spec.ts create mode 100644 src/sms-adapter/uci/uci.service.ts diff --git a/docker-compose.yml b/docker-compose.yml index 81a26ae..d0e2f70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,7 +53,25 @@ services: - redisinsight:/db ports: - 8088:8001 - + + cdac: + image: samagragovernance/cdac-service:latest + restart: always + networks: + - my-network + environment: + USERNAME: "${USERNAME}" + SENDER_ID: "${SENDER_ID}" + PASSWORD: "${PASSWORD}" + SECURE_KEY: "${SECURE_KEY}" + ports: + - "${CDAC_PORT}:8080" + healthcheck: + test: ["CMD", "curl", "-f", "http://cdac:8080/api"] + interval: 2s + timeout: 5s + retries: 20 + web: build: context: . diff --git a/sample.env b/sample.env index 4ef086a..01c2a27 100644 --- a/sample.env +++ b/sample.env @@ -18,6 +18,7 @@ GQL_HOST= GQL_URL= GQL_HEADERS={"content-type":"application/json","x-hasura-admin-secret": "xxxx"} +# UCI variables UCI_500_ALLOWED=false # if allowed then we'll consider 500s from UCI as success UCI_URL= UCI_ADAPTER_ID= @@ -32,4 +33,18 @@ DATABASE_URL= # for /health endpoint HASURA_URL=http://gql:8080 -APP_URL=http://localhost:3000 \ No newline at end of file +APP_URL=http://localhost:3000 + +# SMS Adapter +SMS_ADAPTER_TYPE= # CDAC or UCI + +# CDAC Variables +CDAC_SERVICE_URL=http://cdac:8081 + +# if CDAC service is deployed via current project's docker-compose +CDAC_HOST=cdac +CDAC_PORT=8081 +USERNAME= +SENDER_ID= +PASSWORD= +SECURE_KEY= \ No newline at end of file diff --git a/src/app.module.ts b/src/app.module.ts index 6020f71..d1a3344 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -15,6 +15,9 @@ import { TerminusModule } from '@nestjs/terminus'; import { PrismaHealthIndicator } from '../prisma/prisma.health'; import { RedisModule } from '@liaoliaots/nestjs-redis'; import { RedisHealthModule } from '@liaoliaots/nestjs-redis-health'; +import { SmsAdapterType, SmsAdapterTypeToken } from './sms.templates'; +import { UciService } from './sms-adapter/uci/uci.service'; +import { CdacService } from './sms-adapter/cdac/cdac.service'; @Module({ imports: [ @@ -85,6 +88,14 @@ import { RedisHealthModule } from '@liaoliaots/nestjs-redis-health'; AnnouncementProcessor, HomeworkProcessor, PrismaHealthIndicator, + { + provide: SmsAdapterTypeToken, + useClass: + process.env.SMS_ADAPTER_TYPE == SmsAdapterType.CDAC + ? CdacService + : UciService, + }, ], + exports: [SmsAdapterTypeToken], }) export class AppModule {} diff --git a/src/app.service.ts b/src/app.service.ts index 4ab0781..455fa7c 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -1,8 +1,10 @@ import { HttpService } from '@nestjs/axios'; -import { HttpException, Injectable, Logger } from '@nestjs/common'; +import { HttpException, Inject, Injectable, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { catchError, lastValueFrom, map } from 'rxjs'; import { PrismaService } from './prisma.service'; +import { SmsAdapterTypeToken } from './sms.templates'; +import { SmsAdapterInterface } from './sms-adapter/sms-adapter.interface'; @Injectable() export class AppService { @@ -14,6 +16,8 @@ export class AppService { private prisma: PrismaService, private readonly httpService: HttpService, private configService: ConfigService, + @Inject(SmsAdapterTypeToken) + private readonly smsService: SmsAdapterInterface, ) { this.adapterId = this.configService.get('UCI_ADAPTER_ID'); this.UCI_500_ALLOWED = @@ -51,54 +55,7 @@ export class AppService { templateId: string, payload: string, ): Promise { - this.logger.debug( - `Processing registerSms() callback: ${JSON.stringify([ - phone, - templateId, - payload, - ])}`, - ); - const data = { - adapterId: this.adapterId, - to: { - userID: phone, - deviceType: 'PHONE', - meta: { - templateId: templateId, - }, - }, - payload: { - text: payload, - }, - }; - return await lastValueFrom( - this.httpService - .post(`${this.configService.get('UCI_URL')}/message/send`, data) - .pipe( - map((response: any) => { - this.logger.debug( - `Processed registerSms() SUCCESS: ${JSON.stringify( - response.data, - )}`, - ); - return response.data; - }), - catchError((e) => { - this.logger.error( - `Processing registerSms() FAILURE: ${JSON.stringify( - e.response.data, - )}`, - ); - if (this.UCI_500_ALLOWED && e.response.status == 500) { - // simply just resolve the promise as success even in case of 500s - return new Promise((resolve) => { - resolve(e.response.data); - }); - } - throw new HttpException(e.response.error, e.response.status); // or else throw exception - }), - ), - ); + return this.smsService.sendSms(phone, templateId, payload); } async updateSubmissionStatus(id, status, remarks = ''): Promise { diff --git a/src/sms-adapter/cdac/cdac.service.spec.ts b/src/sms-adapter/cdac/cdac.service.spec.ts new file mode 100644 index 0000000..103ede1 --- /dev/null +++ b/src/sms-adapter/cdac/cdac.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { CdacService } from './cdac.service'; + +describe('CdacService', () => { + let service: CdacService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [CdacService], + }).compile(); + + service = module.get(CdacService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/sms-adapter/cdac/cdac.service.ts b/src/sms-adapter/cdac/cdac.service.ts new file mode 100644 index 0000000..1c642d4 --- /dev/null +++ b/src/sms-adapter/cdac/cdac.service.ts @@ -0,0 +1,68 @@ +import { HttpException, Injectable, Logger } from '@nestjs/common'; +import { SmsAdapterInterface } from '../sms-adapter.interface'; +import { ConfigService } from '@nestjs/config'; +import { HttpService } from '@nestjs/axios'; +import { catchError, lastValueFrom, map } from 'rxjs'; + +@Injectable() +export class CdacService implements SmsAdapterInterface { + private readonly cdacServiceUrl; + protected readonly logger = new Logger(CdacService.name); // logger instance + constructor( + private configService: ConfigService, + private httpService: HttpService, + ) { + this.logger.log(`${CdacService.name} initialized..`); + this.cdacServiceUrl = configService.get('CDAC_SERVICE_URL'); + } + + async sendSms(phone: string, templateId: string, payload: string) { + this.logger.debug( + `Processing registerSms() callback: ${JSON.stringify([ + phone, + templateId, + payload, + ])}`, + ); + const params = new URLSearchParams({ + message: payload, + mobileNumber: phone, + templateid: templateId, + }); + const url = `${ + this.cdacServiceUrl + }/api/send_single_unicode_sms?${params.toString()}`; + console.log(url); + return await lastValueFrom( + this.httpService.get(url).pipe( + map((response: any) => { + let messageId = response.data.toString(); + messageId = messageId.trim('402,MsgID = '); + messageId = messageId.trim('hpgovt-hpssa'); + const resp = { + timestamp: new Date(), + status: 200, + error: null, + message: response.data.toString(), + path: '/api/send_single_sms', + result: { + messageId: messageId, + }, + }; + this.logger.debug( + `Processed registerSms() SUCCESS: ${JSON.stringify(resp)}`, + ); + return resp; + }), + catchError((e) => { + this.logger.error( + `Processing registerSms() FAILURE: ${JSON.stringify( + e.response.data, + )}`, + ); + throw new HttpException(e.response.error, e.response.status); // or else throw exception + }), + ), + ); + } +} diff --git a/src/sms-adapter/sms-adapter.interface.ts b/src/sms-adapter/sms-adapter.interface.ts new file mode 100644 index 0000000..2bd092b --- /dev/null +++ b/src/sms-adapter/sms-adapter.interface.ts @@ -0,0 +1,3 @@ +export declare interface SmsAdapterInterface { + sendSms(phone: string, templateId: string, payload: string); +} diff --git a/src/sms-adapter/uci/uci.service.spec.ts b/src/sms-adapter/uci/uci.service.spec.ts new file mode 100644 index 0000000..fabcb69 --- /dev/null +++ b/src/sms-adapter/uci/uci.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { UciService } from './uci.service'; + +describe('UciService', () => { + let service: UciService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [UciService], + }).compile(); + + service = module.get(UciService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/sms-adapter/uci/uci.service.ts b/src/sms-adapter/uci/uci.service.ts new file mode 100644 index 0000000..cd136e1 --- /dev/null +++ b/src/sms-adapter/uci/uci.service.ts @@ -0,0 +1,75 @@ +import { HttpException, Injectable, Logger } from '@nestjs/common'; +import { SmsAdapterInterface } from '../sms-adapter.interface'; +import { ConfigService } from '@nestjs/config'; +import { catchError, lastValueFrom, map } from 'rxjs'; +import { HttpService } from '@nestjs/axios'; + +@Injectable() +export class UciService implements SmsAdapterInterface { + private readonly adapterId: string; + private readonly UCI_500_ALLOWED: boolean; + protected readonly logger = new Logger(UciService.name); // logger instance + + constructor( + private configService: ConfigService, + private httpService: HttpService, + ) { + this.logger.log(`${UciService.name} initialized..`); + + // initializing env variables in use + this.adapterId = configService.get('UCI_ADAPTER_ID'); + this.UCI_500_ALLOWED = + configService.get('UCI_500_ALLOWED', 'false') == 'true'; + } + + async sendSms(phone: string, templateId: string, payload: string) { + this.logger.debug( + `Processing registerSms() callback: ${JSON.stringify([ + phone, + templateId, + payload, + ])}`, + ); + const data = { + adapterId: this.adapterId, + to: { + userID: phone, + deviceType: 'PHONE', + meta: { + templateId: templateId, + }, + }, + payload: { + text: payload, + }, + }; + return await lastValueFrom( + this.httpService + .post(`${this.configService.get('UCI_URL')}/message/send`, data) + .pipe( + map((response: any) => { + this.logger.debug( + `Processed registerSms() SUCCESS: ${JSON.stringify( + response.data, + )}`, + ); + return response.data; + }), + catchError((e) => { + this.logger.error( + `Processing registerSms() FAILURE: ${JSON.stringify( + e.response.data, + )}`, + ); + if (this.UCI_500_ALLOWED && e.response.status == 500) { + // simply just resolve the promise as success even in case of 500s + return new Promise((resolve) => { + resolve(e.response.data); + }); + } + throw new HttpException(e.response.error, e.response.status); // or else throw exception + }), + ), + ); + } +} diff --git a/src/sms.templates.ts b/src/sms.templates.ts index 5e51662..46a62ac 100644 --- a/src/sms.templates.ts +++ b/src/sms.templates.ts @@ -1,6 +1,34 @@ -export const holidayTemplate = (name: string, start_date: string, end_date: string, reopen_date: string): string =>`प्रिय अभिभावक!स्कूल की छुट्टियां ${start_date} से ${end_date} तक हैं। कृपया ${name} को ${reopen_date} से रोज़ स्कूल भेजना सुनिश्चित करें। समग्र शिक्षा, हिमाचल प्रदेश`; -export const meetingTemplate = (meetingDate: string, meeting: string): string => `प्रिय अभिभावक! कृपया ${meetingDate} को होने वाली ${meeting} में अपनी भागीदारी सुनिश्चित करें और अपने पुत्र/पुत्री की पढ़ाई से संबंधित विभिन्न विषयों पर विस्तृत चर्चा करें। समग्र शिक्षा, हिमाचल प्रदेश` -export const examAnnouncementTemplate = (assessment: string, start_date: string, end_date: string, name: string):string => `प्रिय अभिभावक!${assessment} का आकलन ${start_date} से ${end_date} तक होना है।कृपया सुनिश्चित करें कि ${name} अभी से ही इसकी तैयारी शुरू करें। समग्र शिक्षा, हिमाचल प्रदेश` -export const examResultAnnouncementTemplate = (assessment: string, result_date: string, name: string):string => `प्रिय अभिभावक!${name} के ${assessment} आकलन का परिणाम ${result_date} को घोषित किया जाएगा। कृपया इस दिन स्कूल में अपनी उपस्थिति सुनिश्चित करें और शिक्षकों से मिलकर परिणाम पर विस्तृत चर्चा करें ताकि भविष्य में ${name} की शिक्षण अधिगम में सुधार हो सके। समग्र शिक्षा, हिमाचल प्रदेश` -export const announcementTemplate = (event_date: string, event: string):string => `प्रिय अभिभावक!कृपया आपके पुत्र/पुत्री के विद्यालय में ${event_date} को होने वाली ${event} में अपनी भागीदारी सुनिश्चित करें। समग्र शिक्षा, हिमाचल प्रदेश` -export const homeworkTemplate = (name: string, subject: string):string => `प्रिय अभिभावक!${name} ने इस सप्ताह ${subject} का गृहकार्य पूरा नहीं किया है। कृपया उसकी नोटबुक चेक करें और नियमित रूप से गृहकार्य करने में उस का सहयोग करें।समग्र शिक्षा, हिमाचल प्रदेश` \ No newline at end of file +export const SmsAdapterTypeToken = 'SmaAdapterTypeToken'; +export enum SmsAdapterType { + UCI = 'UCI', + CDAC = 'CDAC', +} +export const holidayTemplate = ( + name: string, + start_date: string, + end_date: string, + reopen_date: string, +): string => + `प्रिय अभिभावक!स्कूल की छुट्टियां ${start_date} से ${end_date} तक हैं। कृपया ${name} को ${reopen_date} से रोज़ स्कूल भेजना सुनिश्चित करें। समग्र शिक्षा, हिमाचल प्रदेश`; +export const meetingTemplate = (meetingDate: string, meeting: string): string => + `प्रिय अभिभावक! कृपया ${meetingDate} को होने वाली ${meeting} में अपनी भागीदारी सुनिश्चित करें और अपने पुत्र/पुत्री की पढ़ाई से संबंधित विभिन्न विषयों पर विस्तृत चर्चा करें। समग्र शिक्षा, हिमाचल प्रदेश`; +export const examAnnouncementTemplate = ( + assessment: string, + start_date: string, + end_date: string, + name: string, +): string => + `प्रिय अभिभावक!${assessment} का आकलन ${start_date} से ${end_date} तक होना है।कृपया सुनिश्चित करें कि ${name} अभी से ही इसकी तैयारी शुरू करें। समग्र शिक्षा, हिमाचल प्रदेश`; +export const examResultAnnouncementTemplate = ( + assessment: string, + result_date: string, + name: string, +): string => + `प्रिय अभिभावक!${name} के ${assessment} आकलन का परिणाम ${result_date} को घोषित किया जाएगा। कृपया इस दिन स्कूल में अपनी उपस्थिति सुनिश्चित करें और शिक्षकों से मिलकर परिणाम पर विस्तृत चर्चा करें ताकि भविष्य में ${name} की शिक्षण अधिगम में सुधार हो सके। समग्र शिक्षा, हिमाचल प्रदेश`; +export const announcementTemplate = ( + event_date: string, + event: string, +): string => + `प्रिय अभिभावक!कृपया आपके पुत्र/पुत्री के विद्यालय में ${event_date} को होने वाली ${event} में अपनी भागीदारी सुनिश्चित करें। समग्र शिक्षा, हिमाचल प्रदेश`; +export const homeworkTemplate = (name: string, subject: string): string => + `प्रिय अभिभावक!${name} ने इस सप्ताह ${subject} का गृहकार्य पूरा नहीं किया है। कृपया उसकी नोटबुक चेक करें और नियमित रूप से गृहकार्य करने में उस का सहयोग करें।समग्र शिक्षा, हिमाचल प्रदेश`; From 5eda1ce9d0a3f486b5841d12747c4ccfdafbf594 Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Wed, 25 Jan 2023 11:40:00 +0530 Subject: [PATCH 2/4] AppService: fixes for failures; Docker: using docker hub image for pulling image; added docker-compose.local.yml to support local development --- Dockerfile.local | 22 +++++++ docker-compose.local.yml | 99 ++++++++++++++++++++++++++++ docker-compose.yml | 3 +- src/app.service.ts | 1 + src/sms-adapter/cdac/cdac.service.ts | 4 +- 5 files changed, 125 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.local create mode 100644 docker-compose.local.yml diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 0000000..95a17c7 --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,22 @@ +FROM node:16 + +# Create app directory +WORKDIR /app + +# A wildcard is used to ensure both package.json AND package-lock.json are copied +COPY package.json ./ +COPY yarn.lock ./ +COPY prisma ./prisma/ + +# Install app dependencies +RUN yarn install +COPY . . +RUN npx prisma generate +RUN yarn run build +COPY . . + +# install hasura cli +RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash + +EXPOSE 3000 +CMD [ "yarn", "run", "start:dev" ] \ No newline at end of file diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 0000000..f779410 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,99 @@ +version: '3.7' + +services: + db: + image: postgres:12 + environment: + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + networks: + - my-network + ports: + - ${POSTGRES_PORT}:5432 + volumes: + - pgdata:/var/lib/postgresql/data + + gql: + image: hasura/graphql-engine:v2.7.0 + ports: + - ${HASURA_PORT}:8080 + env_file: + - .env + environment: + HASURA_GRAPHQL_DATABASE_URL: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB} + HASURA_GRAPHQL_ENABLE_CONSOLE: "true" + HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_ADMIN_SECRET} + WEBHOOK_URL: http://web:${PORT}/submit + networks: + - my-network + depends_on: + - db + restart: always + + redis: + image: redis:alpine + ports: + - 127.0.0.1:${QUEUE_PORT}:6379 + command: ["redis-server", "--appendonly", "yes", "--replica-read-only", "no"] + networks: + - my-network + volumes: + - ./redis-data:/data + - ./redis.conf:/usr/local/etc/redis/redis.conf + restart: on-failure + + redis-ui: + # container_name: redis-ui + image: redislabs/redisinsight:latest + restart: always + networks: + - my-network + volumes: + - redisinsight:/db + ports: + - 8088:8001 + + cdac: + image: samagragovernance/cdac-service:latest + restart: always + networks: + - my-network + environment: + USERNAME: "${USERNAME}" + SENDER_ID: "${SENDER_ID}" + PASSWORD: "${PASSWORD}" + SECURE_KEY: "${SECURE_KEY}" + ports: + - "${CDAC_PORT}:8080" + healthcheck: + test: ["CMD", "curl", "-f", "http://cdac:8080/api"] + interval: 2s + timeout: 5s + retries: 20 + + web: + build: + dockerfile: Dockerfile.local + context: . + networks: + - my-network + env_file: + - .env + depends_on: + - redis + - gql + - db + ports: + - '${PORT}:3000' + restart: always + volumes: + - ./src:/app/src # using local volume + +volumes: + pgdata: + redisinsight: + driver: local +networks: + my-network: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index d0e2f70..120e900 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -73,8 +73,7 @@ services: retries: 20 web: - build: - context: . + image: samagragovernance/odk-uci-adapter:latest networks: - my-network env_file: diff --git a/src/app.service.ts b/src/app.service.ts index 455fa7c..2e9339a 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -84,6 +84,7 @@ export class AppService { this.logger.debug( `Processing insertSmsTrackEntry() callback: ${JSON.stringify(data)}`, ); + data.status = data.status || 'UNKNOWN'; // marking the status as unknown in case nothing received return this.prisma.sms_track.create({ data: data, }); diff --git a/src/sms-adapter/cdac/cdac.service.ts b/src/sms-adapter/cdac/cdac.service.ts index 1c642d4..7668e2b 100644 --- a/src/sms-adapter/cdac/cdac.service.ts +++ b/src/sms-adapter/cdac/cdac.service.ts @@ -44,7 +44,7 @@ export class CdacService implements SmsAdapterInterface { status: 200, error: null, message: response.data.toString(), - path: '/api/send_single_sms', + path: '/api/send_single_unicode_sms', result: { messageId: messageId, }, @@ -60,7 +60,7 @@ export class CdacService implements SmsAdapterInterface { e.response.data, )}`, ); - throw new HttpException(e.response.error, e.response.status); // or else throw exception + throw new HttpException(e.response.error, e?.response?.status || 500); // or else throw exception }), ), ); From faf03423455b1539ed4f61e0cb3bd7c416bfb038 Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Wed, 25 Jan 2023 12:22:30 +0530 Subject: [PATCH 3/4] Docker: stopped exposing redis port; commented out inhouse CDAC service --- docker-compose.local.yml | 38 +++++++++++++++++++------------------- docker-compose.yml | 38 +++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docker-compose.local.yml b/docker-compose.local.yml index f779410..d486f1a 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -33,8 +33,8 @@ services: redis: image: redis:alpine - ports: - - 127.0.0.1:${QUEUE_PORT}:6379 +# ports: +# - 127.0.0.1:${QUEUE_PORT}:6379 command: ["redis-server", "--appendonly", "yes", "--replica-read-only", "no"] networks: - my-network @@ -54,23 +54,23 @@ services: ports: - 8088:8001 - cdac: - image: samagragovernance/cdac-service:latest - restart: always - networks: - - my-network - environment: - USERNAME: "${USERNAME}" - SENDER_ID: "${SENDER_ID}" - PASSWORD: "${PASSWORD}" - SECURE_KEY: "${SECURE_KEY}" - ports: - - "${CDAC_PORT}:8080" - healthcheck: - test: ["CMD", "curl", "-f", "http://cdac:8080/api"] - interval: 2s - timeout: 5s - retries: 20 +# cdac: +# image: samagragovernance/cdac-service:latest +# restart: always +# networks: +# - my-network +# environment: +# USERNAME: "${USERNAME}" +# SENDER_ID: "${SENDER_ID}" +# PASSWORD: "${PASSWORD}" +# SECURE_KEY: "${SECURE_KEY}" +# ports: +# - "${CDAC_PORT}:8080" +# healthcheck: +# test: ["CMD", "curl", "-f", "http://cdac:8080/api"] +# interval: 2s +# timeout: 5s +# retries: 20 web: build: diff --git a/docker-compose.yml b/docker-compose.yml index 120e900..4d6208b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,8 +33,8 @@ services: redis: image: redis:alpine - ports: - - 127.0.0.1:${QUEUE_PORT}:6379 +# ports: +# - 127.0.0.1:${QUEUE_PORT}:6379 command: ["redis-server", "--appendonly", "yes", "--replica-read-only", "no"] networks: - my-network @@ -54,23 +54,23 @@ services: ports: - 8088:8001 - cdac: - image: samagragovernance/cdac-service:latest - restart: always - networks: - - my-network - environment: - USERNAME: "${USERNAME}" - SENDER_ID: "${SENDER_ID}" - PASSWORD: "${PASSWORD}" - SECURE_KEY: "${SECURE_KEY}" - ports: - - "${CDAC_PORT}:8080" - healthcheck: - test: ["CMD", "curl", "-f", "http://cdac:8080/api"] - interval: 2s - timeout: 5s - retries: 20 +# cdac: +# image: samagragovernance/cdac-service:latest +# restart: always +# networks: +# - my-network +# environment: +# USERNAME: "${USERNAME}" +# SENDER_ID: "${SENDER_ID}" +# PASSWORD: "${PASSWORD}" +# SECURE_KEY: "${SECURE_KEY}" +# ports: +# - "${CDAC_PORT}:8080" +# healthcheck: +# test: ["CMD", "curl", "-f", "http://cdac:8080/api"] +# interval: 2s +# timeout: 5s +# retries: 20 web: image: samagragovernance/odk-uci-adapter:latest From 488ccb4ef628f4948a1ef4507b04adfbf0500a18 Mon Sep 17 00:00:00 2001 From: Abhishek Mishra Date: Wed, 25 Jan 2023 12:41:50 +0530 Subject: [PATCH 4/4] Tests: fixes --- src/sms-adapter/cdac/cdac.service.spec.ts | 3 +++ src/sms-adapter/uci/uci.service.spec.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/sms-adapter/cdac/cdac.service.spec.ts b/src/sms-adapter/cdac/cdac.service.spec.ts index 103ede1..454179f 100644 --- a/src/sms-adapter/cdac/cdac.service.spec.ts +++ b/src/sms-adapter/cdac/cdac.service.spec.ts @@ -1,11 +1,14 @@ import { Test, TestingModule } from '@nestjs/testing'; import { CdacService } from './cdac.service'; +import { ConfigModule } from '@nestjs/config'; +import { HttpModule } from '@nestjs/axios'; describe('CdacService', () => { let service: CdacService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ + imports: [ConfigModule, HttpModule], providers: [CdacService], }).compile(); diff --git a/src/sms-adapter/uci/uci.service.spec.ts b/src/sms-adapter/uci/uci.service.spec.ts index fabcb69..b8a63a4 100644 --- a/src/sms-adapter/uci/uci.service.spec.ts +++ b/src/sms-adapter/uci/uci.service.spec.ts @@ -1,11 +1,14 @@ import { Test, TestingModule } from '@nestjs/testing'; import { UciService } from './uci.service'; +import { ConfigModule } from '@nestjs/config'; +import { HttpModule } from '@nestjs/axios'; describe('UciService', () => { let service: UciService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ + imports: [ConfigModule, HttpModule], providers: [UciService], }).compile();