Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Job Launcher - add ssl to db config #821

Merged
merged 1 commit into from
Aug 24, 2023
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
1 change: 1 addition & 0 deletions packages/apps/job-launcher/server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ POSTGRES_PASSWORD=qwerty
POSTGRES_DB=job-launcher
POSTGRES_SYNC=false
POSTGRES_PORT=5432
POSTGRES_SSL=false

#Web3
WEB3_ENV=testnet
Expand Down
4 changes: 3 additions & 1 deletion packages/apps/job-launcher/server/src/common/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ConfigNames = {
POSTGRES_DB: 'POSTGRES_DB',
POSTGRES_PORT: 'POSTGRES_PORT',
POSTGRES_SYNC: 'POSTGRES_SYNC',
POSTGRES_SSL: 'POSTGRES_SSL',
WEB3_ENV: 'WEB3_ENV',
WEB3_PRIVATE_KEY: 'WEB3_PRIVATE_KEY',
JOB_LAUNCHER_FEE: 'JOB_LAUNCHER_FEE',
Expand Down Expand Up @@ -61,6 +62,7 @@ export const envValidator = Joi.object({
POSTGRES_DB: Joi.string().default('job-launcher'),
POSTGRES_PORT: Joi.string().default('5432'),
POSTGRES_SYNC: Joi.string().default(false),
POSTGRES_SSL: Joi.string().default(false),
// Web3
WEB3_ENV: Joi.string().default('testnet'),
WEB3_PRIVATE_KEY: Joi.string().required(),
Expand Down Expand Up @@ -88,4 +90,4 @@ export const envValidator = Joi.object({
SENDGRID_API_KEY: Joi.string().required(),
SENDGRID_FROM_EMAIL: Joi.string().default('[email protected]'),
SENDGRID_FROM_NAME: Joi.string().default('Human Protocol Job Launcher'),
});
});
26 changes: 20 additions & 6 deletions packages/apps/job-launcher/server/src/database/database.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { UserEntity } from '../modules/user/user.entity';
import { TypeOrmLoggerModule, TypeOrmLoggerService } from './typeorm';
import { JobEntity } from '../modules/job/job.entity';
import { PaymentEntity } from '../modules/payment/payment.entity';
import { ConfigNames } from '../common/config';

@Module({
imports: [
Expand Down Expand Up @@ -48,12 +49,25 @@ import { PaymentEntity } from '../modules/payment/payment.entity';
migrations: [path.join(__dirname, '/migrations/**/*{.ts,.js}')],
//"migrations": ["dist/migrations/*{.ts,.js}"],
logger: typeOrmLoggerService,
host: configService.get<string>('POSTGRES_HOST', 'localhost'),
port: configService.get<number>('POSTGRES_PORT', 5432),
username: configService.get<string>('POSTGRES_USER', 'operator'),
password: configService.get<string>('POSTGRES_PASSWORD', 'qwerty'),
database: configService.get<string>('POSTGRES_DB', 'job-launcher'),
keepConnectionAlive: configService.get<string>('NODE_ENV') === 'test',
host: configService.get<string>(
ConfigNames.POSTGRES_HOST,
'localhost',
),
port: configService.get<number>(ConfigNames.POSTGRES_PORT, 5432),
username: configService.get<string>(
ConfigNames.POSTGRES_USER,
'operator',
),
password: configService.get<string>(
ConfigNames.POSTGRES_PASSWORD,
'qwerty',
),
database: configService.get<string>(
ConfigNames.POSTGRES_DB,
'job-launcher',
),
keepConnectionAlive:
configService.get<string>(ConfigNames.NODE_ENV) === 'test',
migrationsRun: false,
};
},
Expand Down
1 change: 1 addition & 0 deletions packages/apps/job-launcher/server/typeorm.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export default new DataSource({
migrationsTableName: 'migrations_typeorm',
migrationsRun: true,
namingStrategy: new SnakeNamingStrategy(),
ssl: process.env.POSTGRES_SSL?.toLowerCase() === 'true',
});