feat: Lightsail + svg animation
This commit is contained in:
@@ -11,8 +11,10 @@ import type {
|
||||
VpcWizardInput,
|
||||
} from '../services/ec2'
|
||||
import {ec2Service} from '../services/ec2'
|
||||
import {SshCheckError, sshCheckService} from '../services/sshCheck'
|
||||
|
||||
type Ec2Service = typeof ec2Service
|
||||
type SshCheckService = typeof sshCheckService
|
||||
type CreateKeyPairInput = {name: string; keyType?: Ec2KeyPairType}
|
||||
|
||||
type Ec2DiagnosticResponse = {ec2?: {instances?: Array<{
|
||||
@@ -21,6 +23,21 @@ type Ec2DiagnosticResponse = {ec2?: {instances?: Array<{
|
||||
sshPort?: number
|
||||
containerId?: string
|
||||
containerStatus?: 'running' | 'stopped' | 'unavailable'
|
||||
state?: string
|
||||
launchStatus?: string
|
||||
launchEvents?: Array<{stage?: string; status?: string; timestamp?: string; message?: string}>
|
||||
selectedImageType?: string
|
||||
selectedImageReference?: string
|
||||
sshUser?: string
|
||||
sshPreinstalled?: boolean
|
||||
initType?: string
|
||||
sshServiceName?: string
|
||||
sshStatus?: string
|
||||
sshStatusMessage?: string
|
||||
keyName?: string
|
||||
keyInjectionStatus?: string
|
||||
publishedPorts?: Record<string, number>
|
||||
failure?: {code?: string; message?: string} | string
|
||||
}>}}
|
||||
|
||||
async function connectionDetails(instanceId: string) {
|
||||
@@ -49,7 +66,7 @@ function handleError(c: Context, error: unknown) {
|
||||
return c.json({error: msg}, 400)
|
||||
}
|
||||
|
||||
export function createEc2Router(svc: Ec2Service = ec2Service) {
|
||||
export function createEc2Router(svc: Ec2Service = ec2Service, sshChecker: SshCheckService = sshCheckService) {
|
||||
const app = new Hono()
|
||||
|
||||
// Instances
|
||||
@@ -108,9 +125,23 @@ export function createEc2Router(svc: Ec2Service = ec2Service) {
|
||||
}
|
||||
})
|
||||
|
||||
app.post('/instances/:instanceId/ssh/check', async (c) => {
|
||||
try {
|
||||
return c.json(await sshChecker.check(c.req.param('instanceId')))
|
||||
} catch (error) {
|
||||
if (error instanceof SshCheckError) {
|
||||
return c.json({ok: false, code: error.code, error: error.message}, error.status)
|
||||
}
|
||||
return c.json({ok: false, code: 'DIAGNOSTICS_UNAVAILABLE', error: 'SSH check failed'}, 502)
|
||||
}
|
||||
})
|
||||
|
||||
app.put('/instances/:instanceId/tags', async (c) => {
|
||||
try {
|
||||
const {toAdd, toRemove} = await c.req.json<{toAdd: Ec2Tag[]; toRemove: string[]}>()
|
||||
if (!Array.isArray(toAdd) || !Array.isArray(toRemove)) {
|
||||
return c.json({error: 'toAdd and toRemove must be arrays'}, 400)
|
||||
}
|
||||
await svc.updateInstanceTags(c.req.param('instanceId'), toAdd, toRemove)
|
||||
return c.json({ok: true})
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user