diff --git a/api/create-checkout-session.ts b/api/create-checkout-session.ts index 6466aafb..bc7ec797 100644 --- a/api/create-checkout-session.ts +++ b/api/create-checkout-session.ts @@ -21,7 +21,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { if (req.method === 'OPTIONS') { if (isOriginAllowed(requestOrigin)) { - res.setHeader('Access-Control-Allow-Origin', requestOrigin); + res.setHeader('Access-Control-Allow-Origin', requestOrigin as string); res.setHeader('Access-Control-Allow-Credentials', 'true'); res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS'); res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); @@ -33,7 +33,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { // Main CORS logic if (isOriginAllowed(requestOrigin)) { - res.setHeader('Access-Control-Allow-Origin', requestOrigin); + res.setHeader('Access-Control-Allow-Origin', requestOrigin as string); res.setHeader('Access-Control-Allow-Credentials', 'true'); } else if (requestOrigin) { res.setHeader('Access-Control-Allow-Origin', 'null'); diff --git a/api/deploy.ts b/api/deploy.ts index 1f7f2309..7df429dd 100644 --- a/api/deploy.ts +++ b/api/deploy.ts @@ -159,8 +159,20 @@ let deploymentManager: ZapdevDeploymentManager | null = null; // Helper function to get or initialize deployment manager function getDeploymentManager(): ZapdevDeploymentManager { if (!deploymentManager) { + const secrets = { + netlify: { + accessToken: validatedEnv.netlifyAccessToken, + teamId: process.env.NETLIFY_TEAM_ID, + }, + vercel: { + accessToken: validatedEnv.vercelAccessToken, + teamId: process.env.VERCEL_TEAM_ID, + }, + }; + deploymentManager = new ZapdevDeploymentManager({ config: deploymentConfig, + secrets, analytics: { track: analytics.track.bind(analytics) }, logger, }); @@ -378,7 +390,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { } } -async function handleDeploy(req: VercelRequest, res: VercelResponse, body: DeployRequest) { +async function handleDeploy(_req: VercelRequest, res: VercelResponse, body: DeployRequest) { const { platform, projectName, subdomain, files, gitRepo, environment } = body; if (!platform || !projectName) { @@ -446,7 +458,7 @@ async function handleStatus(req: VercelRequest, res: VercelResponse, body: Deplo }); } -async function handleSetupDomain(req: VercelRequest, res: VercelResponse, body: DeployRequest) { +async function handleSetupDomain(_req: VercelRequest, res: VercelResponse, body: DeployRequest) { const { subdomain, platform, projectId } = body; if (!subdomain || !platform) { @@ -465,7 +477,7 @@ async function handleSetupDomain(req: VercelRequest, res: VercelResponse, body: }); } -async function handleVerifyDomain(req: VercelRequest, res: VercelResponse, body: DeployRequest) { +async function handleVerifyDomain(_req: VercelRequest, res: VercelResponse, body: DeployRequest) { const { subdomain, platform, projectId } = body; if (!subdomain || !platform) { @@ -485,7 +497,7 @@ async function handleVerifyDomain(req: VercelRequest, res: VercelResponse, body: }); } -async function handleDelete(req: VercelRequest, res: VercelResponse, body: DeployRequest) { +async function handleDelete(_req: VercelRequest, res: VercelResponse, body: DeployRequest) { const { platform, deploymentId } = body; if (!platform || !deploymentId) { diff --git a/api/domains.ts b/api/domains.ts index d9b141fb..708ccc0d 100644 --- a/api/domains.ts +++ b/api/domains.ts @@ -321,7 +321,7 @@ async function handleCheckSubdomain(req: VercelRequest, res: VercelResponse, bod }); } -async function handleSetupDomain(req: VercelRequest, res: VercelResponse, body: DomainRequest) { +async function handleSetupDomain(_req: VercelRequest, res: VercelResponse, body: DomainRequest) { const { subdomain, platform, projectId, siteId } = body; if (!subdomain || !platform) { @@ -353,7 +353,7 @@ async function handleSetupDomain(req: VercelRequest, res: VercelResponse, body: }); } -async function handleVerifyDomain(req: VercelRequest, res: VercelResponse, body: DomainRequest) { +async function handleVerifyDomain(_req: VercelRequest, res: VercelResponse, body: DomainRequest) { const { subdomain, platform, projectId, siteId } = body; if (!subdomain || !platform) { diff --git a/api/hono-trpc.ts b/api/hono-trpc.ts index 619e23a5..0eae2667 100644 --- a/api/hono-trpc.ts +++ b/api/hono-trpc.ts @@ -31,8 +31,9 @@ app.use( '/trpc/*', trpcServer({ router: appRouter, - createContext: async (opts: FetchCreateContextFnOptions) => { - return await createContext({ req: opts.req }); + createContext: async (opts: FetchCreateContextFnOptions, c) => { + const context = await createContext({ req: opts.req }); + return context as Record; }, onError: ({ error, path, type }) => { console.error(`Hono tRPC Error on ${path} (${type}):`, { diff --git a/api/secret-chat.ts b/api/secret-chat.ts index 20ef3777..3951969f 100644 --- a/api/secret-chat.ts +++ b/api/secret-chat.ts @@ -45,9 +45,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { } // Configure the Google provider with the user's API key - const gemini = google({ - apiKey: apiKey, - }); + const gemini = google({ apiKey }); // Check if this is a streaming request const isStreaming = req.headers['accept']?.includes('text/stream') || @@ -62,7 +60,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { content: msg.content, })), temperature: 0.7, - maxTokens: 4000, + maxCompletionTokens: 4000, }); return result.toTextStreamResponse(); @@ -75,7 +73,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { content: msg.content, })), temperature: 0.7, - maxTokens: 4000, + maxCompletionTokens: 4000, }); return res.status(200).json({ diff --git a/api/success.ts b/api/success.ts index da667e84..9e9e8cf0 100644 --- a/api/success.ts +++ b/api/success.ts @@ -16,12 +16,20 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { return res.status(405).json({ error: 'Method not allowed' }); } + // Require authentication + const rawAuthHeader = Array.isArray(req.headers['authorization']) + ? req.headers['authorization'][0] + : req.headers['authorization']; + const authorization = typeof rawAuthHeader === 'string' ? rawAuthHeader : undefined; + try { + // Require authentication const rawAuthHeader = Array.isArray(req.headers['authorization']) ? req.headers['authorization'][0] : req.headers['authorization']; const authorization = typeof rawAuthHeader === 'string' ? rawAuthHeader : undefined; + if (!authorization) { return res.status(401).json({ error: 'Unauthorized' }); } diff --git a/lib/deployment/manager.ts b/lib/deployment/manager.ts index 74b0034c..89503b80 100644 --- a/lib/deployment/manager.ts +++ b/lib/deployment/manager.ts @@ -252,6 +252,7 @@ export class ZapdevDeploymentManager { event: 'domain_configured', properties: { platform, + project_name: projectId || 'unknown', subdomain, custom_domain: fullDomain, project_id: projectId, @@ -278,6 +279,7 @@ export class ZapdevDeploymentManager { event: 'domain_configured', properties: { platform, + project_name: projectId || 'unknown', subdomain, custom_domain: fullDomain, project_id: projectId, @@ -330,6 +332,8 @@ export class ZapdevDeploymentManager { event: 'domain_verified', properties: { platform, + project_name: projectId || 'unknown', + subdomain: domain.replace('.zapdev.link', ''), custom_domain: domain, project_id: projectId, success: result.success, diff --git a/vite.config.ts b/vite.config.ts index ad190cf1..3aa82913 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -80,9 +80,11 @@ export default defineConfig(({ mode }) => { }, cacheableResponse: { statuses: [0, 200], + headers: { 'Cache-Control': /^(?!.*no-store).*/, }, + }, plugins: [ {