Skip to content

Commit c379c95

Browse files
fix: vercel api error
1 parent b82a59a commit c379c95

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

.env.example

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ DISCORD_WEBHOOK_TOKEN=
33
DISCORD_WEBHOOK_USERNAME=
44
DISCORD_WEBHOOK_IMAGE_URL=
55

6-
AXIOS_TIMEOUT=1000
6+
AXIOS_TIMEOUT=
77

88
DEPLOY_PLATFORM_URL=
99
DEPLOY_PLATFORM_TOKEN=
10+
DEPLOY_PLATFORM_TEAM_ID=
1011

1112
PRODUCTION_URL=
1213

1314
ENVIRONMENT_RELEASE_NAME=
1415
ENVIRONMENT_NAME=
15-
DEPLOY_NAME=
16+
17+
DEPLOY_NAME=
18+
19+
HOST_PRODUCTION_URL=

src/config/axios.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import axiosProvider from 'axios';
2+
import dotenv from 'dotenv';
3+
4+
dotenv.config();
25

36
export const axios = axiosProvider.create({
4-
timeout: Number(process.env.AXIOS_TIMEOUT) || 1000,
7+
timeout: Number(process.env.AXIOS_TIMEOUT) || 5000,
58
baseURL: process.env.DEPLOY_PLATFORM_URL || '',
69
headers: {
710
Authorization: `Bearer ${process.env.DEPLOY_PLATFORM_TOKEN}`,
811
},
12+
params: {
13+
target: 'preview',
14+
teamId: process.env.DEPLOY_PLATFORM_TEAM_ID || '',
15+
},
916
});

src/middlewares/GlobalExceptionHandler.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export function globalExceptionHandler(
1717
const messageEmbed = new DiscordMessageEmbed();
1818
const embed = messageEmbed
1919
.setTitle('An error ocurred')
20-
.setDescription('Search in logs for more description')
20+
.setDescription(
21+
`See logs for further information\n${process.env.HOST_PRODUCTION_URL}/logs/error.log`,
22+
)
2123
.setColor(STATUS_FAILED);
2224

2325
const webhookClient = new DiscordWebhookClient();

src/server.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import 'reflect-metadata';
22
import 'express-async-errors';
3-
import dotenv from 'dotenv';
43

4+
import dotenv from 'dotenv';
55
import express from 'express';
6+
67
import { logger, logsPath } from './config/logger';
78

89
import { router } from './routes';

src/services/SendReleaseDeploymentStatusService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ export class SendReleaseDeploymentStatusService {
6565

6666
private async getURL({ name }: Environment): Promise<string> {
6767
if (name.toLowerCase() === process.env.ENVIRONMENT_NAME?.toLowerCase()) {
68-
const axiosURL = `${process.env.DEPLOY_PLATFORM_URL}?target=preview`;
68+
const axiosURL = `${process.env.DEPLOY_PLATFORM_URL}`;
6969

7070
const {
7171
data: { deployments },
7272
} = await axios.get(axiosURL);
7373

74-
if (!deployments)
74+
if (!deployments || deployments.length <= 0)
7575
throw new Error('Vercel API does not returned any value');
7676

7777
const { url }: IDeployPayload = deployments.find(

0 commit comments

Comments
 (0)