refactor(cloud): add api key for autentication between servers

This commit is contained in:
Mauricio Siu
2024-10-06 01:56:53 -06:00
parent 3cf27a068a
commit 58c06fba86
7 changed files with 74 additions and 67 deletions

View File

@@ -9,13 +9,13 @@ type QueueJob =
cronSchedule: string;
serverId: string;
};
export const schedule = async (job: QueueJob, authSession: string) => {
export const schedule = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/create-backup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authSession}`,
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
@@ -28,13 +28,13 @@ export const schedule = async (job: QueueJob, authSession: string) => {
}
};
export const removeJob = async (job: QueueJob, authSession: string) => {
export const removeJob = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/remove-job`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authSession}`,
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});
@@ -47,13 +47,13 @@ export const removeJob = async (job: QueueJob, authSession: string) => {
}
};
export const updateJob = async (job: QueueJob, authSession: string) => {
export const updateJob = async (job: QueueJob) => {
try {
const result = await fetch(`${process.env.JOBS_URL}/update-backup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${authSession}`,
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(job),
});

View File

@@ -1,12 +1,12 @@
import type { DeploymentJob } from "../queues/deployments-queue";
export const deploy = async (jobData: DeploymentJob, sessionId: string) => {
export const deploy = async (jobData: DeploymentJob) => {
try {
const result = await fetch(`${process.env.SERVER_URL}/deploy`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${sessionId}`,
"X-API-Key": process.env.API_KEY || "NO-DEFINED",
},
body: JSON.stringify(jobData),
});