26 lines
743 B
TypeScript
26 lines
743 B
TypeScript
|
|
import type { APIRoute } from 'astro';
|
||
|
|
|
||
|
|
export const POST: APIRoute = async () => {
|
||
|
|
const token = import.meta.env.CLEVER_TOKEN;
|
||
|
|
const appId = import.meta.env.CLEVER_APP_ID_PRODUCTION;
|
||
|
|
|
||
|
|
if (!token || !appId) {
|
||
|
|
return new Response('Missing CLEVER_TOKEN or CLEVER_APP_ID_PRODUCTION', { status: 500 });
|
||
|
|
}
|
||
|
|
|
||
|
|
const response = await fetch(
|
||
|
|
`https://api.clever-cloud.com/v2/self/applications/${appId}/instances`,
|
||
|
|
{
|
||
|
|
method: 'POST',
|
||
|
|
headers: { Authorization: `Bearer ${token}` },
|
||
|
|
},
|
||
|
|
);
|
||
|
|
|
||
|
|
if (!response.ok) {
|
||
|
|
const body = await response.text();
|
||
|
|
return new Response(`Clever Cloud API error: ${response.status} ${body}`, { status: 502 });
|
||
|
|
}
|
||
|
|
|
||
|
|
return new Response('Rebuild triggered', { status: 200 });
|
||
|
|
};
|