Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Request, Response } from 'express';
import { IDependency } from '../../frameworks/types/dependency';
import { kafkaClient } from '../../config/kafka.connection';
// import { JobUpdatedEventPublisher } from "../../frameworks/services/kafka-events/publishers/job-updated-publisher";
import { MemberShipPlanUpdatedEventPublisher } from '../../frameworks/utils/kafka-events/publishers/membership-plan-updated-publisher ';
import { NotFoundError } from '@abijobportal/common';

Expand Down
2 changes: 1 addition & 1 deletion auth/src/config/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IAppConfig {
export interface IAppConfig {
PORT: string | number;
API_PREFIX: string;
MONGO_URL_AUTH: string;
Expand Down
29 changes: 17 additions & 12 deletions auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ import { connectDB } from './config/db.connection';
import { app } from './frameworks/express/app';
import { UserUpdatedEventConsumer } from './frameworks/utils/kafka-events/consumers/user-updated-consumer';
import { kafkaClient } from './config/kafka.connection';
import { appConfig } from './config/appConfig';
import { appConfig, IAppConfig } from './config/appConfig';

const start = async () => {
console.log('Starting up....');

if (!process.env.JWT_SECRET_KEY) throw new Error('JWT_SECRET_KEY must be defined');

if (!appConfig.JWT_REFRESH_SECRET_KEY) throw new Error('JWT_REFRESH_SECRET_KEY must be defined');

if (!appConfig.MONGO_URL_AUTH) throw new Error('MONGO_URL_AUTH must be defined');

if (!appConfig.TWILIO_AUTH_TOKEN) throw new Error('TWILIO_AUTH_TOKEN must be defined');

if (!appConfig.TWILIO_ACCOUNT_SID) throw new Error('TWILIO_ACCOUNT_SID must be defined');

if (!appConfig.TWILIO_SERVICE_SID) throw new Error('TWILIO_SERVICE_SID must be defined');
// Env checking
const REQUIRED_ENV_VARIABLES = (Object.keys(appConfig) as (keyof IAppConfig)[])

const missingEnvVariables: string[] = REQUIRED_ENV_VARIABLES.filter((key: keyof IAppConfig) => {
const value: string | number | string[] = appConfig[key];
return !value || (Array.isArray(value) && !value.length);
});

if (missingEnvVariables.length) {
// eslint-disable-next-line no-console
console.error(
`🚨 Missing the following required environment variable${missingEnvVariables.length === 1 ? '' : 's'}: ` +
`${missingEnvVariables.map((variable) => `"${variable}"`).join(', ')} `,
);
process.exit(1);
}

// to connect to mongodb
await connectDB();
Expand Down
2 changes: 1 addition & 1 deletion chat/src/config/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IAppConfig {
export interface IAppConfig {
PORT: string | number;
API_PREFIX: string;
MONGO_URL_CHAT: string;
Expand Down
21 changes: 17 additions & 4 deletions chat/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { appConfig } from './config/appConfig';
import { appConfig, IAppConfig } from './config/appConfig';
import { connectDB } from './config/db.connection';
import { kafkaClient } from './config/kafka.connection';
import { httpServer } from './frameworks/express/app';
Expand All @@ -10,9 +10,22 @@ import { setupSocketIO } from './frameworks/webSocket/socket';
const start = async () => {
console.log('chat service Starting up....');

if (!appConfig.MONGO_URL_CHAT) throw new Error('MONGO_URL_CHAT must be defined');
if (!appConfig.JWT_SECRET_KEY) throw new Error('JWT_SECRET_KEY must be defined');
if (!appConfig.JWT_REFRESH_SECRET_KEY) throw new Error('JWT_REFRESH_SECRET_KEY must be defined');
// Env checking
const REQUIRED_ENV_VARIABLES = (Object.keys(appConfig) as (keyof IAppConfig)[])

const missingEnvVariables: string[] = REQUIRED_ENV_VARIABLES.filter((key: keyof IAppConfig) => {
const value: string | number | string[] = appConfig[key];
return !value || (Array.isArray(value) && !value.length);
});

if (missingEnvVariables.length) {
// eslint-disable-next-line no-console
console.error(
`🚨 Missing the following required environment variable${missingEnvVariables.length === 1 ? '' : 's'}: ` +
`${missingEnvVariables.map((variable) => `"${variable}"`).join(', ')} `,
);
process.exit(1);
}

console.log('before socket instance');
setupSocketIO(httpServer);
Expand Down
2 changes: 1 addition & 1 deletion job/src/config/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IAppConfig {
export interface IAppConfig {
PORT: string | number;
API_PREFIX: string;
MONGO_URL_JOB: string;
Expand Down
25 changes: 18 additions & 7 deletions job/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,27 @@ import { kafkaClient } from './config/kafka.connection';
import { jobUpdatedEventConsumer } from './frameworks/utils/kafka-events/consumers/jobUpdatedConsumer';
import { UserCreatedEventConsumer } from './frameworks/utils/kafka-events/consumers/userCreatedConsumer';
import { UserUpdatedEventConsumer } from './frameworks/utils/kafka-events/consumers/userUpdatedConsumer';
import { appConfig } from './config/appConfig';
import { appConfig, IAppConfig } from './config/appConfig';

const start = async () => {
console.log('Job service Starting up....');

if (!appConfig.JWT_SECRET_KEY) throw new Error('JWT_SECRET_KEY must be defined');
// Env checking
const REQUIRED_ENV_VARIABLES = (Object.keys(appConfig) as (keyof IAppConfig)[])

if (!appConfig.JWT_REFRESH_SECRET_KEY) throw new Error('JWT_REFRESH_SECRET_KEY must be defined');
const missingEnvVariables: string[] = REQUIRED_ENV_VARIABLES.filter((key: keyof IAppConfig) => {
const value: string | number | string[] = appConfig[key];
return !value || (Array.isArray(value) && !value.length);
});

if (!appConfig.MONGO_URL_JOB) throw new Error('MONGO_URL_JOB must be defined');
if (missingEnvVariables.length) {
// eslint-disable-next-line no-console
console.error(
`🚨 Missing the following required environment variable${missingEnvVariables.length === 1 ? '' : 's'}: ` +
`${missingEnvVariables.map((variable) => `"${variable}"`).join(', ')} `,
);
process.exit(1);
}

await connectDB();

Expand All @@ -22,9 +33,9 @@ const start = async () => {
const userUpdatedEvent = new UserUpdatedEventConsumer(kafkaClient);
const jobUpdatedEvent = new jobUpdatedEventConsumer(kafkaClient);

// await userUpdatedEvent.subscribe();
// await userCreatedEvent.subscribe();
// await jobUpdatedEvent.subscribe();
await userUpdatedEvent.subscribe();
await userCreatedEvent.subscribe();
await jobUpdatedEvent.subscribe();

app.listen(appConfig.PORT, () => {
console.log(`job service Listening on port ${appConfig.PORT}....`);
Expand Down
2 changes: 1 addition & 1 deletion payment/src/config/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IAppConfig {
export interface IAppConfig {
PORT: string | number;
API_PREFIX: string;
MONGO_URL_PAYMENT: string;
Expand Down
20 changes: 15 additions & 5 deletions payment/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ import { connectDB } from './config/db.connection';
import { app } from './frameworks/express/app';
import { kafkaClient } from './config/kafka.connection';
import { MembershipPlanCreatedEventConsumer } from './frameworks/utils/kafka-events/consumers/premiumPlanCreatedConsumer';
import { appConfig } from './config/appConfig';
import { appConfig, IAppConfig } from './config/appConfig';

const start = async () => {
console.log('Starting up profile....');

if (!appConfig.JWT_SECRET_KEY) throw new Error('JWT_SECRET_KEY must be defined');
// Env checking
const REQUIRED_ENV_VARIABLES = (Object.keys(appConfig) as (keyof IAppConfig)[])

if (!appConfig.JWT_REFRESH_SECRET_KEY) throw new Error('JWT_REFRESH_SECRET_KEY must be defined');
const missingEnvVariables: string[] = REQUIRED_ENV_VARIABLES.filter((key: keyof IAppConfig) => {
const value: string | number | string[] = appConfig[key];
return !value || (Array.isArray(value) && !value.length);
});

if (!appConfig.MONGO_URL_PAYMENT) throw new Error('MONGO_URL_PROFILE must be defined');
if (missingEnvVariables.length) {
// eslint-disable-next-line no-console
console.error(
`🚨 Missing the following required environment variable${missingEnvVariables.length === 1 ? '' : 's'}: ` +
`${missingEnvVariables.map((variable) => `"${variable}"`).join(', ')} `,
);
process.exit(1);
}

if (!appConfig.STRIPE_SECRET_KEY) throw new Error('STRIPE_SECRET_KEY must be defined');

const membershipPlanCreatedEvent = new MembershipPlanCreatedEventConsumer(kafkaClient);

Expand Down
2 changes: 1 addition & 1 deletion profile/src/config/appConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IAppConfig {
export interface IAppConfig {
PORT: string | number;
API_PREFIX: string;
MONGO_URL_PROFILE: string;
Expand Down
29 changes: 17 additions & 12 deletions profile/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,27 @@ import { UserCreatedEventConsumer } from './frameworks/utils/kafka-events/consum
import { UserUpdatedEventConsumer } from './frameworks/utils/kafka-events/consumers/user-updated-consumer';
import { kafkaClient } from './config/kafka.connection';
import { paymentCreatedEventConsumer } from './frameworks/utils/kafka-events/consumers/payment-created-consumer';
import { appConfig } from './config/appConfig';
import { appConfig, IAppConfig } from './config/appConfig';

const start = async () => {
console.log('Starting up profile....');

if (!appConfig.JWT_SECRET_KEY) throw new Error('JWT_SECRET_KEY must be defined');

if (!appConfig.JWT_REFRESH_SECRET_KEY) throw new Error('JWT_REFRESH_SECRET_KEY must be defined');

if (!appConfig.MONGO_URL_PROFILE) throw new Error('MONGO_URL_PROFILE must be defined');

if (!appConfig.CLOUDINARY_API_KEY) throw new Error('CLOUDINARY_API_KEY must be defined');

if (!appConfig.CLOUDINARY_API_SECRET) throw new Error('CLOUDINARY_API_SECRET must be defined');

if (!appConfig.CLOUDINARY_CLOUD_NAME) throw new Error('CLOUDINARY_CLOUD_NAME must be defined');
// Env checking
const REQUIRED_ENV_VARIABLES = (Object.keys(appConfig) as (keyof IAppConfig)[])

const missingEnvVariables: string[] = REQUIRED_ENV_VARIABLES.filter((key: keyof IAppConfig) => {
const value: string | number | string[] = appConfig[key];
return !value || (Array.isArray(value) && !value.length);
});

if (missingEnvVariables.length) {
// eslint-disable-next-line no-console
console.error(
`🚨 Missing the following required environment variable${missingEnvVariables.length === 1 ? '' : 's'}: ` +
`${missingEnvVariables.map((variable) => `"${variable}"`).join(', ')} `,
);
process.exit(1);
}

await connectDB();

Expand Down