Endpoint
Pubblicare un’app
Metti online l’app salvata, come fa il pulsante Publish.
https://www.setherion.com/api/v1/projects/{id}/publishPiano: Ogni piano
Mette online l’app esattamente com’è salvata, attraverso gli stessi passaggi del pulsante Publish nell’editor. Un’app già pubblicata in precedenza mantiene il suo indirizzo; una pubblicata per la prima volta ottiene un indirizzo ricavato dal suo nome, su setherion.app.
Pubblicare non usa crediti. Devi poter modificare l’app. Tramite l’API è limitato a 100 pubblicazioni al giorno per account, un limite che nessuno che lavora a mano raggiunge; il pulsante dell’editor non ha alcun limite del genere.
Richiesta
Non serve alcun corpo.
curl -X POST https://www.setherion.com/api/v1/projects/7c1e4a52-9b0d-4f3e-8a61-2d5f0c9e7b14/publish \
-H "Authorization: Bearer $SETHERION_API_KEY"Risposta
{ "ok": true, "url": "https://coffee-shop.setherion.app", "ready": true }| Campo | Tipo | Significato |
|---|---|---|
ok | boolean | true quando l’app è stata pubblicata. |
url | string | Dove l’app è online. |
ready | boolean | false quando l’indirizzo è ancora in preparazione. Funziona entro un minuto o due. |
Pubblicare due volte la stessa app salvata è sicuro: la seconda chiamata risponde con lo stesso indirizzo.
Modifica, poi pubblica
Ciò che viene pubblicato è ciò che è salvato, e una modifica viene salvata quando finisce. Quindi una modifica seguita da una pubblicazione mette online il cambiamento:
const base = 'https://www.setherion.com/api/v1/projects'
const headers = {
Authorization: `Bearer ${process.env.SETHERION_API_KEY}`,
'Content-Type': 'application/json',
}
const edit = await fetch(`${base}/${appId}/edit`, {
method: 'POST',
headers,
body: JSON.stringify({ prompt: 'Add a contact form' }),
}).then(r => r.json())
if (edit.ok) {
const live = await fetch(`${base}/${appId}/publish`, { method: 'POST', headers }).then(r => r.json())
console.log(live.url)
}Errori
| Stato | Quando |
|---|---|
400 | Il codice dell’app contiene un segreto, come una chiave API, e non è stata pubblicata. L’errore indica dove. |
401 | La chiave manca, è sbagliata o è stata revocata. |
404 | Non esiste un’app del genere, oppure la tua chiave non può modificarla. |
409 | L’app non ha ancora codice, oppure l’indirizzo di cui ha bisogno non è disponibile, oppure è un’app privata che non può andare su un dominio tuo. L’errore dice quale caso. |
429 | Hai pubblicato 100 volte tramite l’API oggi. Il conteggio riparte domani. |
502 | La pubblicazione è fallita da parte nostra, oppure la build sull’host è fallita. Riprova. |
503 | La pubblicazione è temporaneamente non disponibile. Riprova tra un minuto. |
Le frasi esatte
| Stato | error |
|---|---|
400 | Publishing would put a secret key on the open internet: ... followed by the kind of secret, the file and the line, and what to do instead. |
404 | No such app on this account. |
409 | This app has no code yet. Build it in Setherion first. |
409 | The address coffee-shop.setherion.app belongs to another app. Choose a different one. |
409 | Could not find a free address for this app. Rename it and publish again. |
409 | This app is private, and a private app can only be published on its setherion.app address. To use a domain of your own, make it public first. Otherwise try again in a moment. Nothing was published. |
429 | That is 100 publishes through the API today. The count resets tomorrow. |
502 | The build failed on the host, so this version is not online. Publish again, and if it fails again, ask for a fix in the editor. |
502 | The build was cancelled on the host, so this version is not online. Publish again. |
503 | Publishing is briefly unavailable. Try again in a minute. |
Questa pagina ti è stata utile?
