Files
esign/packages/api/hono.ts
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

43 lines
1.8 KiB
TypeScript

import { TsRestHttpError, fetchRequestHandler } from '@ts-rest/serverless/fetch';
import { Hono } from 'hono';
import { ApiContractV1 } from '@hanzo/esign-api/v1/contract';
import { ApiContractV1Implementation } from '@hanzo/esign-api/v1/implementation';
import { OpenAPIV1 } from '@hanzo/esign-api/v1/openapi';
import { testCredentialsHandler } from '@hanzo/esign-lib/server-only/public-api/test-credentials';
import { listDocumentsHandler } from '@hanzo/esign-lib/server-only/webhooks/zapier/list-documents';
import { subscribeHandler } from '@hanzo/esign-lib/server-only/webhooks/zapier/subscribe';
import { unsubscribeHandler } from '@hanzo/esign-lib/server-only/webhooks/zapier/unsubscribe';
// This is a bit nasty. Todo: Extract
import type { HonoEnv } from '@hanzo/esign-remix/server/router';
// This is bad, ts-router will be created on each request.
// But don't really have a choice here.
export const tsRestHonoApp = new Hono<HonoEnv>();
tsRestHonoApp
.get('/openapi', (c) => c.redirect('https://openapi-v1.esign.hanzo.ai'))
.get('/openapi.json', (c) => c.json(OpenAPIV1))
.get('/me', async (c) => testCredentialsHandler(c.req.raw));
// Zapier. Todo: (RR7) Check methods. Are these get/post/update requests?
tsRestHonoApp
.all('/zapier/list-documents', async (c) => listDocumentsHandler(c.req.raw))
.all('/zapier/subscribe', async (c) => subscribeHandler(c.req.raw))
.all('/zapier/unsubscribe', async (c) => unsubscribeHandler(c.req.raw));
tsRestHonoApp.mount('/', async (request) => {
return fetchRequestHandler({
request,
contract: ApiContractV1,
router: ApiContractV1Implementation,
options: {
errorHandler: (err) => {
if (err instanceof TsRestHttpError && err.statusCode === 500) {
console.error(err);
}
},
},
});
});