kopia lustrzana https://github.com/cloudflare/wildebeest
Merge pull request #117 from cloudflare/sven/MOW-106
MOW-106: /api/v1/apps support JSON and FormDatapull/120/head
commit
c559bde6f7
|
@ -93,6 +93,9 @@ describe('Mastodon APIs', () => {
|
|||
const request = new Request('https://example.com', {
|
||||
method: 'POST',
|
||||
body: '{"redirect_uris":"mastodon://joinmastodon.org/oauth","website":"https://app.joinmastodon.org/ios","client_name":"Mastodon for iOS","scopes":"read write follow push"}',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
})
|
||||
|
||||
const res = await apps.handleRequest(db, request, vapidKeys)
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Env } from 'wildebeest/backend/src/types/env'
|
|||
import { createClient } from 'wildebeest/backend/src/mastodon/client'
|
||||
import { VAPIDPublicKey } from 'wildebeest/backend/src/mastodon/subscription'
|
||||
import { getVAPIDKeys } from 'wildebeest/backend/src/config'
|
||||
import { readBody } from 'wildebeest/backend/src/utils/body'
|
||||
|
||||
type AppsPost = {
|
||||
redirect_uris: string
|
||||
|
@ -21,7 +22,7 @@ export async function handleRequest(db: D1Database, request: Request, vapidKeys:
|
|||
return new Response('', { status: 400 })
|
||||
}
|
||||
|
||||
const body = await request.json<AppsPost>()
|
||||
const body = await readBody<AppsPost>(request)
|
||||
|
||||
const client = await createClient(db, body.client_name, body.redirect_uris, body.website, body.scopes)
|
||||
const vapidKey = VAPIDPublicKey(vapidKeys)
|
||||
|
|
Ładowanie…
Reference in New Issue