Skip to content

Commit

Permalink
Merge pull request #123 from binaryoverload/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow authored Nov 6, 2024
2 parents 875e75f + 54dfed9 commit 374d468
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/config-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export const config: Config = {
s3: {
endpoint: process.env.PN_ACT_CONFIG_S3_ENDPOINT || '',
key: process.env.PN_ACT_CONFIG_S3_ACCESS_KEY || '',
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || ''
secret: process.env.PN_ACT_CONFIG_S3_ACCESS_SECRET || '',
region: process.env.PN_ACT_CONFIG_S3_REGION || '',
forcePathStyle: process.env.PN_ACT_CONFIG_S3_FORCE_PATH_STYLE === 'true'
},
hcaptcha: {
secret: process.env.PN_ACT_CONFIG_HCAPTCHA_SECRET || ''
Expand Down Expand Up @@ -195,6 +197,11 @@ if (!config.s3.secret) {
disabledFeatures.s3 = true;
}

if (!config.s3.region) {
LOG_WARN('Failed to find S3 region config. Disabling feature. To enable feature set the PN_ACT_CONFIG_S3_REGION environment variable');
disabledFeatures.s3 = true;
}

if (!config.server_environment) {
LOG_WARN('Failed to find server environment. To change the environment, set the PN_ACT_CONFIG_SERVER_ENVIRONMENT environment variable. Defaulting to prod');
config.server_environment = 'prod';
Expand Down
9 changes: 5 additions & 4 deletions src/services/api/routes/v1/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,16 @@ router.post('/', async (request: express.Request, response: express.Response): P
await pnid.save({ session });

await session.commitTransaction();
} catch (error) {
} catch (error: any) {
LOG_ERROR('[POST] /v1/register: ' + error);
if (error.stack) console.error(error.stack);

await session.abortTransaction();

response.status(400).json({
response.status(500).json({
app: 'api',
status: 400,
error: 'Password must have combination of letters, numbers, and/or punctuation characters'
status: 500,
error: 'Internal server error'
});

return;
Expand Down
2 changes: 2 additions & 0 deletions src/types/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface Config {
endpoint: string;
key: string;
secret: string;
region: string;
forcePathStyle: boolean;
};
hcaptcha: {
secret: string;
Expand Down
2 changes: 2 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let s3: S3;
if (!disabledFeatures.s3) {
s3 = new S3({
endpoint: config.s3.endpoint,
forcePathStyle: config.s3.forcePathStyle,
region: config.s3.region,

credentials: {
accessKeyId: config.s3.key,
Expand Down

0 comments on commit 374d468

Please sign in to comment.