api_ianmenethil_comemailService.ts11 matches
191192// ============================================================================
193// UTILITY FUNCTIONS
194// ============================================================================
195198* @returns ISO date string in Sydney timezone
199*/
200function getCurrentDateInSydney(): string {
201return new Date().toLocaleString("en-AU", {
202timeZone: "Australia/Sydney",
214* @returns Basic configuration object
215*/
216function getConfig<T>(): T {
217return {} as T;
218} // ============================================================================
219// HTTP UTILITY FUNCTIONS
220// ============================================================================
221225* @returns Headers object
226*/
227function createHeaders(bearerToken?: string): Record<string, string> {
228const token = bearerToken || Deno.env.get("VALTOWN_TOKEN") || Deno.env.get("VALTOWN_API_KEY") ||
229"";
242* @returns Complete URL string
243*/
244function buildUrl(endpoint: string, baseUrl?: string): string {
245const base = baseUrl || DEFAULT_EMAIL_CONFIG.baseUrl;
246const cleanEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
254* @returns Promise resolving to Response
255*/
256async function makeRequest(url: string, options: RequestInit): Promise<Response> {
257const controller = new AbortController();
258const timeoutId = setTimeout(() => controller.abort(), DEFAULT_EMAIL_CONFIG.timeout);
274}
275} // ============================================================================
276// CORE EMAIL FUNCTIONS
277// ============================================================================
278294* ```
295*/
296export async function sendEmail(
297options: EmailOptions,
298): Promise<EmailOperationResult<{ message: string }>> {
366*/
367368export function sendSimpleEmail(
369to: string[],
370subject: string,
1051// ============================================================================
10521053// Export all types and functions
1054export type {
1055EmailAttachment,
api_ianmenethil_comblobService.ts19 matches
141* ```
142*/
143function validateBlobKey(key: string): void {
144if (typeof key !== "string") {
145throw new BlobServiceError("Blob key must be a string", STATUS_CODES.BAD_REQUEST);
172*/
173174function validateBearerToken(token: string): void {
175if (typeof token !== "string" || token.trim().length === 0) {
176throw new BlobServiceError(
197* ```
198*/
199function createHeaders(bearerToken?: string, contentType?: string): Record<string, string> {
200const headers: Record<string, string> = {};
201225* ```
226*/
227function buildUrl(endpoint: string, key?: string, queryParams?: Record<string, string>): string {
228const baseUrl = `${DEFAULT_BLOB_CONFIG.baseUrl}/${DEFAULT_BLOB_CONFIG.apiVersion}`;
229let url = `${baseUrl}${endpoint}`;
264*/
265266async function makeRequest(url: string, options: RequestInit): Promise<Response> {
267let lastError: Error | null = null;
268299300// ============================================================================
301// CORE BLOB SERVICE FUNCTIONS
302// ============================================================================
303318* ```
319*/
320export async function listBlobs(
321options: ListBlobsOptions = {},
322): Promise<BlobOperationResult<BlobListingItem[]>> {
371*/
372373export async function downloadBlob(key: string): Promise<BlobOperationResult<ArrayBuffer>> {
374try {
375validateBlobKey(key);
422* ```
423*/
424export async function downloadBlobAsText(
425key: string,
426encoding: string = "utf-8",
475*/
476477export async function storeBlob(
478key: string,
479data: ArrayBuffer | Uint8Array | string,
543* ```
544*/
545export async function storeBlobAsJson(
546key: string,
547data: unknown,
582*/
583584export async function deleteBlob(
585key: string,
586options: AuthenticatedBlobOptions,
622623// ============================================================================
624// UTILITY FUNCTIONS
625// ============================================================================
626639* ```
640*/
641export async function blobExists(key: string): Promise<boolean> {
642try {
643validateBlobKey(key);
668*/
669670export async function getBlobMetadata(key: string): Promise<BlobListingItem | null> {
671try {
672const result = await listBlobs();
695* ```
696*/
697export async function downloadBlobAsJson<T = unknown>(
698key: string,
699): Promise<BlobOperationResult<T>> {
740* ```
741*/
742export async function copyBlob(
743sourceKey: string,
744destinationKey: string,
788*/
789790export async function bulkDeleteBlobsByPrefix(
791prefix: string,
792options: AuthenticatedBlobOptions,
1188}
11891190// Export all types and functions
1191export type {
1192AuthenticatedBlobOptions,
api_ianmenethil_comwebhookService.ts7 matches
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 webhook creation result
72*/
73export async function createWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
74const requestId = crypto.randomUUID();
75159* @returns Response with webhook records list
160*/
161export async function listWebhooks(c: Context<{ Variables: Variables }>): Promise<Response> {
162const requestId = crypto.randomUUID();
163249* @returns Response with webhook record details
250*/
251export async function getWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
252const requestId = crypto.randomUUID();
253316* @returns Response with deletion confirmation
317*/
318export async function deleteWebhook(c: Context<{ Variables: Variables }>): Promise<Response> {
319const requestId = crypto.randomUUID();
320
16} from "@/external-apis/tavilyClient.ts";
1718function getLocalErrorMessage(error: unknown): string {
19if (error instanceof Error) return error.message;
20if (typeof error === "string") return error;
30* Handles requests to the Tavily search API.
31*/
32export async function tavilySearchHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
33try {
34const requestBody = await c.req.json();
95* Handles requests to the Tavily extract API.
96*/
97export async function tavilyExtractHandler(
98c: Context<{ Variables: Variables }>,
99): Promise<Response> {
162* Handles requests to the Tavily crawl API.
163*/
164export async function tavilyCrawlHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
165try {
166const requestBody = await c.req.json();
229* Handles requests to the Tavily map API.
230*/
231export async function tavilyMapHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
232try {
233const requestBody = await c.req.json();
api_ianmenethil_comswaggerService.ts2 matches
9899/**
100* Swagger UI handler function for use in service router
101* @param c - Hono context with Variables
102* @returns Response with Swagger UI HTML
103*/
104export function getSwaggerUI(c: Context<{ Variables: Variables }>): Response {
105try {
106const html = swaggerUIService.generateSwaggerHTML("/v1/openapi.json");
api_ianmenethil_comredoclyService.ts2 matches
7172/**
73* Redoc handler function for use in service router
74* @param c - Hono context with Variables
75* @returns Response with Redoc HTML
76*/
77export function getRedoc(c: Context<{ Variables: Variables }>): Response {
78try {
79const html = redoclyService.generateRedocHTML("/v1/openapi.json");
api_ianmenethil_comproxyService.ts4 matches
5859// Shared error message helper (ideally from a utils file)
60function getLocalErrorMessage(error: unknown): string {
61if (error instanceof Error) return error.message;
62if (typeof error === "string") return error;
222export const proxyService = new ProxyService();
223224// --- Add Hono Handler Functions directly in this file ---
225226export async function proxyGetHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
227try {
228const targetUrl = c.req.query("url");
259}
260261export async function proxyPostHandler(c: Context<{ Variables: Variables }>): Promise<Response> {
262try {
263const targetUrl = c.req.query("url");
api_ianmenethil_comopenapiService.ts5 matches
15* @returns A string representation of the error message
16*/
17function getErrorMessage(error: unknown): string {
18if (error instanceof Error) {
19return error.message;
115116/**
117* OpenAPI JSON handler function for use in service router
118* @param c - Hono context with Variables
119* @returns Response with OpenAPI JSON specification
120*/
121export async function getOpenAPIJSON(c: Context<{ Variables: Variables }>): Promise<Response> {
122try {
123const spec = await openapiSpecService.getOpenAPIJSONObject();
131132/**
133* OpenAPI YAML handler function for use in service router
134* @param c - Hono context with Variables
135* @returns Response with OpenAPI YAML specification
136*/
137export async function getOpenAPIYAML(c: Context<{ Variables: Variables }>): Promise<Response> {
138try {
139const yamlString = await openapiSpecService.getOpenAPIYAMLString();
18* Get Spotify OAuth URL - implements getSpotifyOAuthURL operation
19*/
20export function getSpotifyOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
21try {
22// Generate CSRF state token
32});
3334// Generate OAuth URL using existing function
35const authUrl = generateOAuthUrl("spotify", state);
3675* Handle Spotify OAuth callback - implements handleSpotifyCallback operation
76*/
77export async function handleSpotifyCallback(
78c: Context<{ Variables: Variables }>,
79): Promise<Response> {
230* Exchange authorization code for access tokens
231*/
232async function exchangeCodeForTokens(code: string) {
233try {
234const spotifyConfig = AUTH_CONFIG.oauth.providers.SPOTIFY;
290* Fetch user information from Spotify
291*/
292async function fetchSpotifyUserInfo(accessToken: string) {
293try {
294const userRequest = await fetch("https://api.spotify.com/v1/me", {
21* Get Google OAuth URL - implements getGoogleOAuthURL operation
22*/
23export function getGoogleOAuthURL(c: Context<{ Variables: Variables }>): Promise<Response> {
24try {
25// Generate CSRF state token
35});
3637// Generate OAuth URL using existing function
38const authUrl = generateOAuthUrl("google", state);
3978* Handle Google OAuth callback - implements handleGoogleCallback operation
79*/
80export async function handleGoogleCallback(
81c: Context<{ Variables: Variables }>,
82): Promise<Response> {
231* Exchange authorization code for access tokens
232*/
233async function exchangeCodeForTokens(code: string) {
234try {
235const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;
279* Fetch user information from Google
280*/
281async function fetchGoogleUserInfo(accessToken: string) {
282try {
283const googleConfig = AUTH_CONFIG.oauth.providers.GOOGLE;