mirror of
https://github.com/zoo-apps/vote.git
synced 2026-10-30 14:56:32 +00:00
- Full app extraction from zoo monorepo (source only) - Configured for GitHub Pages deployment - Static export enabled - Custom domain: vote.zoo.ngo - Excludes node_modules and build artifacts
28 lines
926 B
TypeScript
28 lines
926 B
TypeScript
import { createMiddleware } from 'hono/factory';
|
|
import { isAddress } from 'viem';
|
|
import { moralisSupportedChainIds } from '../../src/providers/NetworkConfig/useNetworkConfigStore';
|
|
import type { Env, Var } from '../types';
|
|
|
|
export const getParams = createMiddleware<{ Bindings: Env; Variables: Var }>(async (c, next) => {
|
|
const address = c.req.query('address');
|
|
if (!address) {
|
|
return c.json({ error: 'Address is required' }, 400);
|
|
}
|
|
if (!isAddress(address)) {
|
|
return c.json({ error: 'Provided address is not a valid address' }, 400);
|
|
}
|
|
c.set('address', address);
|
|
|
|
const network = c.req.query('network');
|
|
if (!network) {
|
|
return c.json({ error: 'Network is required' }, 400);
|
|
}
|
|
const chainId = parseInt(network);
|
|
if (!moralisSupportedChainIds.includes(chainId)) {
|
|
return c.json({ error: 'Requested network is not supported' }, 400);
|
|
}
|
|
c.set('network', network);
|
|
|
|
await next();
|
|
});
|