also looking at this
Edit queued and scheduled posts (#21)
#22
6 files
+359
-7
| @@ -0,0 +1,27 @@ | ||
| 1 | import type { RequestInstance } from '@stacksjs/types' | |
| 2 | import { Action } from '@stacksjs/actions' | |
| 3 | import { response } from '@stacksjs/router' | |
| 4 | import { postQueue } from '../../Services/Social/QueueService' | |
| 5 | ||
| 6 | export default new Action({ | |
| 7 | name: 'Postline Queue Get', | |
| 8 | description: 'Fetch one queued post\'s editable state for the composer.', | |
| 9 | method: 'GET', | |
| 10 | ||
| 11 | async handle(request: RequestInstance) { | |
| 12 | const id = Number(request.get('id') || 0) | |
| 13 | if (!id) | |
| 14 | return response.json({ ok: false, error: 'Post id is required.' }, { status: 422 }) | |
| 15 | ||
| 16 | try { | |
| 17 | const data = await postQueue.get(id) | |
| 18 | return response.json({ ok: true, data }) | |
| 19 | } | |
| 20 | catch (error) { | |
| 21 | return response.json({ | |
| 22 | ok: false, | |
| 23 | error: error instanceof Error ? error.message : String(error), | |
| 24 | }, { status: 404 }) | |
| 25 | } | |
| 26 | }, | |
| 27 | }) | |