Skip to content

Commit

Permalink
Merge pull request #9 from utxostack/vercel-serverless
Browse files Browse the repository at this point in the history
Deployment cell deps json to vercel
  • Loading branch information
duanyytop authored Jan 8, 2025
2 parents 608e6ab + 1e6cfb6 commit e36d8ba
Show file tree
Hide file tree
Showing 6 changed files with 2,089 additions and 924 deletions.
28 changes: 28 additions & 0 deletions api/cell-deps.ts
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;
}
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "0.1.0",
"scripts": {
"update:cellDeps": "npx ts-node src/index.ts",
"format": "prettier --write 'src/*.ts'",
"format": "prettier --write '{src, api}/*.ts'",
"lint": "eslint --ext .ts src/*"
},
"types": "./lib/index.d.ts",
"dependencies": {
"@rgbpp-sdk/ckb": "^0.1.0",
"@vercel/node": "^3.2.23",
"axios": "^1.6.8"
},
"devDependencies": {
Expand All @@ -18,7 +19,8 @@
"eslint": "^8.56.0",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.4.3"
"typescript": "^5.4.3",
"zod": "^3.23.8"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit e36d8ba

Please sign in to comment.