-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from utxostack/vercel-serverless
Deployment cell deps json to vercel
- Loading branch information
Showing
6 changed files
with
2,089 additions
and
924 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { VercelResponse } from '@vercel/node'; | ||
import { ZodError } from 'zod'; | ||
import { fetchCellDeps } from "../src/index" | ||
|
||
export default async function handler(res: VercelResponse) { | ||
try { | ||
const cellDeps = await fetchCellDeps(); | ||
return res.json(JSON.parse(cellDeps)); | ||
} catch (e: any) { | ||
if (e instanceof ZodError) { | ||
const error = e.errors[0]; | ||
res.status(400).send({ | ||
error: { | ||
code: error.code ?? 400, | ||
message: `(${error.path.join('.')}): ${error.message}`, | ||
}, | ||
}); | ||
} else { | ||
res.status(500).send({ | ||
error: { | ||
code: e?.code ?? e.status ?? null, | ||
message: e?.message ?? 'internal server error', | ||
}, | ||
}); | ||
} | ||
throw e; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.