feat: add contact form with SMS OTP verification

This commit is contained in:
badblocks 2025-07-17 19:34:29 -07:00
parent 91b162fb44
commit 3874443c34
No known key found for this signature in database
14 changed files with 729 additions and 54 deletions

45
server/lib/http-client.js Normal file
View file

@ -0,0 +1,45 @@
/**
* A simple HTTP client wrapper around the global fetch function.
* This is used by the android-sms-gateway client.
*/
export const httpFetchClient = {
get: async (url, headers) => {
const response = await fetch(url, {
method: "GET",
headers,
});
if (!response.ok) {
const errorBody = await response.text();
console.error("Gateway GET error:", errorBody);
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
},
post: async (url, body, headers) => {
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json", ...headers },
body: JSON.stringify(body),
});
if (!response.ok) {
const errorBody = await response.text();
console.error("Gateway POST error:", errorBody);
throw new Error(
`HTTP error! status: ${response.status}, body: ${errorBody}`,
);
}
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();
},
};