api_ianmenethil_cominfoService.ts4 matches
8586/**
87* API info handler function for use in service router
88* @param c - Hono context with Variables
89* @returns Response with API information
90*/
91export function getApiInfo(c: Context<{ Variables: Variables }>): Response {
92try {
93const info = infoService.getApiInfo();
102103/**
104* Version handler function for use in service router
105* @param c - Hono context with Variables
106* @returns Response with version information
107*/
108export function getVersion(c: Context<{ Variables: Variables }>): Response {
109try {
110const versionInfo = infoService.getVersionInfo();
api_ianmenethil_comhashService.ts12 matches
133* when calling Zenith's /initiate-payment endpoint.
134*/
135export async function hashData(c: Context<{ Variables: Variables }>): Promise<Response> {
136const requestId = crypto.randomUUID();
137251* Handle v1/v2 versions - Base64 encoding
252*/
253async function handleV1V2(
254c: Context<{ Variables: Variables }>,
255requestBody: any,
362* Handle v3/v4/v5 versions - Hash generation for Zenith fingerprint
363*/
364async function handleV3V4V5(
365c: Context<{ Variables: Variables }>,
366requestBody: any,
527}
528529// ==================== UTILITY FUNCTIONS ====================
530531/**
532* Generate hash using Web Crypto API
533*/
534async function generateHash(data: string, algorithm: string): Promise<string> {
535const encoder = new TextEncoder();
536const dataBuffer = encoder.encode(data);
575* Check if timestamp is in valid ISO 8601 format
576*/
577function isValidISO8601(timestamp: string): boolean {
578try {
579const date = new Date(timestamp);
594* Check if timestamp is within acceptable time window (5 minutes)
595*/
596function isTimestampRecent(timestamp: string): boolean {
597try {
598const providedTime = new Date(timestamp).getTime();
610* Format Zod errors for user-friendly error response
611*/
612function formatZodErrors(error: z.ZodError): HashErrorResponse["details"] {
613return error.errors.map((err) => {
614const field = err.path.join(".");
643* Create standardized error response
644*/
645function createHashErrorResponse(
646code: string,
647message: string,
666* Optional info endpoint handler for documentation
667*/
668export async function hashInfo(c: Context): Promise<Response> {
669const currentTime = new Date().toISOString();
670825826/**
827* Hash handler function for use in service router
828* @param c - Hono context with Variables
829* @returns Response with hash result
830*/
831export async function getHash(c: Context<{ Variables: Variables }>): Promise<Response> {
832return await hashData(c);
833}
api_ianmenethil_comhash.service.ts12 matches
133* when calling Zenith's /initiate-payment endpoint.
134*/
135export async function hashData(c: Context<{ Variables: Variables }>): Promise<Response> {
136const requestId = crypto.randomUUID();
137251* Handle v1/v2 versions - Base64 encoding
252*/
253async function handleV1V2(
254c: Context<{ Variables: Variables }>,
255requestBody: any,
362* Handle v3/v4/v5 versions - Hash generation for Zenith fingerprint
363*/
364async function handleV3V4V5(
365c: Context<{ Variables: Variables }>,
366requestBody: any,
527}
528529// ==================== UTILITY FUNCTIONS ====================
530531/**
532* Generate hash using Web Crypto API
533*/
534async function generateHash(data: string, algorithm: string): Promise<string> {
535const encoder = new TextEncoder();
536const dataBuffer = encoder.encode(data);
575* Check if timestamp is in valid ISO 8601 format
576*/
577function isValidISO8601(timestamp: string): boolean {
578try {
579const date = new Date(timestamp);
594* Check if timestamp is within acceptable time window (5 minutes)
595*/
596function isTimestampRecent(timestamp: string): boolean {
597try {
598const providedTime = new Date(timestamp).getTime();
610* Format Zod errors for user-friendly error response
611*/
612function formatZodErrors(error: z.ZodError): HashErrorResponse["details"] {
613return error.errors.map((err) => {
614const field = err.path.join(".");
643* Create standardized error response
644*/
645function createHashErrorResponse(
646code: string,
647message: string,
666* Optional info endpoint handler for documentation
667*/
668export async function hashInfo(c: Context): Promise<Response> {
669const currentTime = new Date().toISOString();
670825826/**
827* Hash handler function for use in service router
828* @param c - Hono context with Variables
829* @returns Response with hash result
830*/
831export async function getHash(c: Context<{ Variables: Variables }>): Promise<Response> {
832return await hashData(c);
833}
10} from "../external-apis/firecrawlClient.ts";
1112// Helper function to get error messages
13// In a real project, move this to a shared utility file (e.g., src/utils/error.utils.ts)
14function getLocalErrorMessage(error: unknown): string {
15if (error instanceof Error) return error.message;
16if (typeof error === "string") return error;
26* Handles requests to the Firecrawl scrape API for a single URL.
27*/
28export async function firecrawlScrapeHandler(
29c: Context<{ Variables: Variables }>,
30): Promise<Response> {
50const scrapeInput: ScraperInput = validationResult.data;
5152// Call the Firecrawl API through the client function
53const firecrawlResponse = await fetchFromFirecrawlAPI(scrapeInput);
5489* Handles requests to the Firecrawl map API for discovering URLs on a website.
90*/
91export async function firecrawlMapHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
92try {
93const requestBody = await c.req.json();
108const mapInput: FirecrawlMapInput = validationResult.data;
109110// Call the dedicated map function with validated input
111const firecrawlResponse = await performFirecrawlMap(mapInput);
112
api_ianmenethil_comechoService.ts3 matches
3637/**
38* Echo Service - Handles echo functionality
39* Returns request data for testing and debugging purposes
40*/
112113/**
114* Echo handler function for use in service router
115* @param c - Hono context with Variables
116* @returns Response with echo data
117*/
118export async function echo(c: any): Promise<Response> {
119try {
120const method = c.req.method;
23* @returns Sanitized string
24*/
25function sanitizeInput(input: string): string {
26return input.replace(/[<>\"'&]/g, "").trim();
27}
33* @returns Parsed timestamp filter object
34*/
35function parseTimestampFilters(from?: string, to?: string): { from?: Date; to?: Date } {
36const result: { from?: Date; to?: Date } = {};
3758* @returns Headers as key-value object
59*/
60function extractHeaders(request: Request): Record<string, string> {
61const headers: Record<string, string> = {};
62request.headers.forEach((value, key) => {
71* @returns Response with callback creation result
72*/
73export async function createCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
74const requestId = crypto.randomUUID();
75159* @returns Response with callback records list
160*/
161export async function listCallbacks(c: Context<{ Variables: Variables }>): Promise<Response> {
162const requestId = crypto.randomUUID();
163249* @returns Response with callback record details
250*/
251export async function getCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
252const requestId = crypto.randomUUID();
253316* @returns Response with deletion confirmation
317*/
318export async function deleteCallback(c: Context<{ Variables: Variables }>): Promise<Response> {
319const requestId = crypto.randomUUID();
320
api_ianmenethil_comauthService.ts4 matches
18* Generates and returns a new CSRF token for form protection
19*/
20export function getCsrfToken(c: Context<{ Variables: Variables }>): Response {
21try {
22// Generate a secure CSRF token
73* Returns the current authenticated user from the OAuth session
74*/
75export function getCurrentUser(c: Context<{ Variables: Variables }>): Response {
76try {
77// Get session data from cookie
197* Clears OAuth session cookies and ends the user session
198*/
199export function logout(c: Context<{ Variables: Variables }>): Response {
200try {
201// Get current session for logging
265* Converts API keys to JWT tokens for secure service access
266*/
267export async function exchangeToken(c: Context<{ Variables: Variables }>): Promise<Response> {
268try {
269// Extract token key from header or query parameter
api_ianmenethil_comtavilyClient.ts5 matches
104105// API configuration
106function getTavilyApiKey(): string {
107const key = Deno.env.get("TAVILY_API_KEY") || "";
108if (!key) {
117* Perform a search using the Tavily API.
118*/
119export async function performTavilySearch(input: TavilySearchInput): Promise<unknown> {
120const apiKey = getTavilyApiKey();
121const options = {
148* Perform an extract using the Tavily API.
149*/
150export async function performTavilyExtract(input: TavilyExtractInput): Promise<unknown> {
151const apiKey = getTavilyApiKey();
152186* Perform a crawl using the Tavily API (BETA).
187*/
188export async function performTavilyCrawl(input: TavilyCrawlInput): Promise<unknown> {
189const apiKey = getTavilyApiKey();
190228* Perform a site map using the Tavily API (BETA).
229*/
230export async function performTavilyMap(input: TavilyMapInput): Promise<unknown> {
231const apiKey = getTavilyApiKey();
232
107export type FirecrawlMapInput = z.infer<typeof FirecrawlMapInputSchema>;
108109function getApiKey(): string {
110const key = Deno.env.get("FIRECRAWL_API_KEY") || "";
111if (!key) {
115}
116117function getFirecrawlClient(): FirecrawlApp {
118const apiKey = getApiKey();
119return new FirecrawlApp({ apiKey });
124* Handles single page scraping with all supported options.
125*/
126export async function fetchFromFirecrawlAPI(
127input: ScraperInput,
128): Promise<unknown> {
173* Maps all URLs from a website using Firecrawl's dedicated map endpoint.
174*/
175export async function performFirecrawlMap(
176input: FirecrawlMapInput,
177): Promise<unknown> {
184185// Check if FirecrawlApp has a map method
186if ("mapUrl" in firecrawl && typeof firecrawl.mapUrl === "function") {
187// Use the SDK's map method if available
188return await firecrawl.mapUrl(input.url, {
12import { exchangeToken, getCsrfToken, getCurrentUser, logout } from "../handlers/authService.ts";
1314// Documentation services - Updated to use handler functions
15import { getOpenAPIJSON, getOpenAPIYAML } from "../handlers/openapiService.ts";
16import { getSwaggerUI } from "../handlers/swaggerService.ts";
49// import { hashData } from '@/handlers/hash.service.ts';
5051// // --- Helper function to get error messages ---
52// function getErrorMessage(error: unknown): string {
53// if (error instanceof Error) return error.message;
54// if (typeof error === 'string') return error;
6768// --- Service Router Creation ---
69export function createServiceRouter(): ServiceRouter {
70const router: ServiceRouter = {
71// === Core Auth Handlers ===
83handleSpotifyCallback,
8485// === Documentation Handlers - Now using imported functions ===
86getOpenAPIJSON,
87getOpenAPIYAML,
226}
227228// --- Utility functions for the router ---
229export function getServiceHandler(
230operationId: string,
231router: ServiceRouter,
234}
235236export function listOperations(router: ServiceRouter): string[] {
237return Object.keys(router);
238}