Skip to content

Commit

Permalink
Add logs, change errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkovicmilos committed Sep 24, 2023
1 parent 08f00b1 commit 1b911b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
11 changes: 0 additions & 11 deletions signup/functions/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,19 @@ export enum ApplicationEnv {
}

const {
NODE_PORT,
NODE_HOST,
NODE_ENV,
REDIS_URL,
MAILCHIMP_API_KEY,
MAILCHIMP_API_SERVER,
MAILCHIMP_AUDIENCE_ID,
MAILCHIMP_JOURNEY_ID,
MAILCHIMP_JOURNEY_STEP,
TOKEN_LIST
} = process.env;

const ENV: ApplicationEnv =
(NODE_ENV as ApplicationEnv) || ApplicationEnv.DEVELOPMENT;

export const CONFIG = {
REDIS_URL,
MAILCHIMP_API_KEY,
MAILCHIMP_API_SERVER,
MAILCHIMP_AUDIENCE_ID,
MAILCHIMP_JOURNEY_ID,
MAILCHIMP_JOURNEY_STEP,
TOKEN_LIST,
NODE_PORT,
NODE_HOST,
NODE_ENV: ENV
};
7 changes: 4 additions & 3 deletions signup/functions/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export async function handler(event: HandlerEvent): Handler {
// Validate the request
const subscribeRequest: SubscribeRequest = JSON.parse(event.body);

console.log(subscribeRequest)
// Intentional; TODO Remove
console.log(subscribeRequest);

const isValid: boolean = ajv.validate(
subscribeUserSchema,
Expand All @@ -46,15 +47,15 @@ export async function handler(event: HandlerEvent): Handler {
if (!isValid) {
return {
statusCode: 400,
body: JSON.stringify({ errors: 'Bad request' })
body: JSON.stringify({ errors: 'Unable to validate request' })
};
}

// Make sure the ToC is accepted if the game is played
if (subscribeRequest.termsAndConditions !== subscribeRequest.participate) {
return {
statusCode: 400,
body: JSON.stringify({ errors: { message: 'Bad request' } })
body: JSON.stringify({ errors: { message: 'Request is invalid' } })
};
}

Expand Down

0 comments on commit 1b911b3

Please sign in to comment.