d7002057d7
This PR moves the tldraw.com app into the public repo. ### Change Type - [x] `internal` — Any other changes that don't affect the published package[^2] --------- Co-authored-by: Dan Groshev <git@dgroshev.com> Co-authored-by: alex <alex@dytry.ch>
25 lines
562 B
TypeScript
25 lines
562 B
TypeScript
// @ts-expect-error
|
|
import grabity from 'grabity'
|
|
import { runCorsMiddleware } from './_cors'
|
|
|
|
interface RequestBody {
|
|
url: string
|
|
}
|
|
|
|
interface ResponseBody {
|
|
title?: string
|
|
description?: string
|
|
image?: string
|
|
}
|
|
|
|
export default async function handler(req: any, res: any) {
|
|
try {
|
|
await runCorsMiddleware(req, res)
|
|
const { url } = typeof req.body === 'string' ? JSON.parse(req.body) : (req.body as RequestBody)
|
|
const it = await grabity.grabIt(url)
|
|
res.send(it)
|
|
} catch (error: any) {
|
|
console.error(error)
|
|
res.status(500).send(error.message)
|
|
}
|
|
}
|