mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add save API endpoint to frontend for URL based saving
This commit is contained in:
parent
3bb1fc05ad
commit
381c69f32c
1 changed files with 18 additions and 0 deletions
18
packages/web/pages/api/save.ts
Normal file
18
packages/web/pages/api/save.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import { saveUrlMutation } from '../../lib/networking/mutations/saveUrlMutation'
|
||||
|
||||
// eslint-disable-next-line import/no-anonymous-default-export
|
||||
export default async (
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
): Promise<void> => {
|
||||
const urlStr = req.query['url']
|
||||
const url = new URL(urlStr as string)
|
||||
const saveResult = await saveUrlMutation(url.toString())
|
||||
if (saveResult?.jobId) {
|
||||
res.redirect(`/sr/${saveResult?.jobId}`)
|
||||
return
|
||||
}
|
||||
|
||||
res.status(200).send('ok')
|
||||
}
|
||||
Loading…
Reference in a new issue