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

fix: gracefully handle missing deeplink domain url from env #894

Merged
merged 1 commit into from
Aug 5, 2024
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
8 changes: 7 additions & 1 deletion libs/common/src/common.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { NotFoundException } from '@nestjs/common';
import * as dotenv from 'dotenv';
import { ResponseMessages } from './response-messages';
dotenv.config();
/* eslint-disable camelcase */
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/explicit-function-return-type
Expand Down Expand Up @@ -49,7 +51,11 @@ export function orderValues(key, order = 'asc') {


export function convertUrlToDeepLinkUrl(url: string): string {
const deepLinkUrl = (process.env.DEEPLINK_DOMAIN as string).concat(url);
const deepLinkDomain = process.env.DEEPLINK_DOMAIN
if(!deepLinkDomain) {
throw new NotFoundException(ResponseMessages.shorteningUrl.error.deepLinkDomainNotFound)
}
const deepLinkUrl = deepLinkDomain.concat(url);
return deepLinkUrl;
}

Expand Down
3 changes: 3 additions & 0 deletions libs/common/src/response-messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ export const ResponseMessages = {
success: {
getshorteningUrl: 'Shortening Url fetched successfully',
createShorteningUrl: 'Shortening Url created successfully'
},
error: {
deepLinkDomainNotFound: 'Deeplink Domain not found. Please make sure to add it in your environment variables'
}
},
notification: {
Expand Down