mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
createAppController: parse formdata body
This commit is contained in:
parent
d572a43b5a
commit
9c645cf616
1 changed files with 8 additions and 1 deletions
|
|
@ -1,4 +1,7 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
import type { AppController } from '@/app.ts';
|
||||
import { parseBody } from '@/utils/api.ts';
|
||||
|
||||
/**
|
||||
* Apps are unnecessary cruft in Mastodon API, but necessary to make clients work.
|
||||
|
|
@ -14,10 +17,14 @@ const FAKE_APP = {
|
|||
vapid_key: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
||||
};
|
||||
|
||||
const createAppSchema = z.object({
|
||||
redirect_uris: z.string().url().optional(),
|
||||
});
|
||||
|
||||
const createAppController: AppController = async (c) => {
|
||||
// TODO: Handle both formData and json. 422 on parsing error.
|
||||
try {
|
||||
const { redirect_uris } = await c.req.json();
|
||||
const { redirect_uris } = createAppSchema.parse(await parseBody(c.req.raw));
|
||||
|
||||
return c.json({
|
||||
...FAKE_APP,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue