feat: add Docker deployment with HAProxy and blue-green strategy
This commit is contained in:
parent
3cfa59d3a5
commit
5be1e5add5
26 changed files with 56198 additions and 582 deletions
|
|
@ -1,12 +1,13 @@
|
|||
/**
|
||||
* A simple HTTP client wrapper around the global fetch function.
|
||||
* This is used by the android-sms-gateway client.
|
||||
*/
|
||||
import { ProxyAgent } from "undici";
|
||||
|
||||
const proxyAgent = new ProxyAgent("http://wireguard:8888");
|
||||
|
||||
export const httpFetchClient = {
|
||||
get: async (url, headers) => {
|
||||
const response = await fetch(url, {
|
||||
const response = await $fetch(url, {
|
||||
method: "GET",
|
||||
headers,
|
||||
agent: proxyAgent,
|
||||
});
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
|
|
@ -16,10 +17,11 @@ export const httpFetchClient = {
|
|||
return response.json();
|
||||
},
|
||||
post: async (url, body, headers) => {
|
||||
const response = await fetch(url, {
|
||||
const response = await $fetch(url, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", ...headers },
|
||||
body: JSON.stringify(body),
|
||||
agent: proxyAgent,
|
||||
});
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
|
|
@ -30,16 +32,4 @@ export const httpFetchClient = {
|
|||
}
|
||||
return response.json();
|
||||
},
|
||||
delete: async (url, headers) => {
|
||||
const response = await fetch(url, {
|
||||
method: "DELETE",
|
||||
headers,
|
||||
});
|
||||
if (!response.ok) {
|
||||
const errorBody = await response.text();
|
||||
console.error("Gateway DELETE error:", errorBody);
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue