Skip to content

Commit

Permalink
fix: comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nolostra committed Sep 20, 2024
1 parent d7b6ec4 commit b43ecd2
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 29 deletions.
7 changes: 4 additions & 3 deletions src/app/api/upload-to-cdn/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { serverEnv } from '@/env/server';
import { NextResponse } from 'next/server';
import { v4 as uuidv4 } from 'uuid';

const CDN_BASE_UPLOAD_URL = process.env.CDN_BASE_UPLOAD_URL;
const CDN_BASE_ACCESS_URL = process.env.CDN_BASE_ACCESS_URL;
const CDN_API_KEY = process.env.CDN_API_KEY!;
const CDN_BASE_UPLOAD_URL = serverEnv.CDN_BASE_UPLOAD_URL;
const CDN_BASE_ACCESS_URL = serverEnv.CDN_BASE_ACCESS_URL;
const CDN_API_KEY = serverEnv.CDN_API_KEY!;

export async function POST(req: Request): Promise<NextResponse> {
try {
Expand Down
3 changes: 2 additions & 1 deletion src/components/gmaps-autosuggest.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Script from 'next/script';
import { Input } from './ui/input';
import { clientEnv } from '@/env/client';

export type TgmapsAddress = { city: string; fullAddress: string };

Expand All @@ -26,7 +27,7 @@ export function GmapsAutocompleteAddress({ form }: { form: any }) {
return (
<>
<Script
src={`https://maps.googleapis.com/maps/api/js?key=${process.env.GOOGLE_MAPS_API_KEY}&libraries=places`}
src={`https://maps.googleapis.com/maps/api/js?key=${clientEnv.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY}&libraries=places`}
strategy="lazyOnload"
onLoad={initializeGmaps}
/>
Expand Down
25 changes: 0 additions & 25 deletions src/env.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/env/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// client-env.ts
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

export const clientEnv = createEnv({
client: {
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY: z.string().min(1),
},
runtimeEnv: {
NEXT_PUBLIC_GOOGLE_MAPS_API_KEY:
process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
},
});
38 changes: 38 additions & 0 deletions src/env/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// server-env.ts
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

export const serverEnv = createEnv({
server: {
DATABASE_URL: z.string().url(),
NEXTAUTH_SECRET: z.string().min(1),
NEXTAUTH_URL: z.string().url(),
POSTGRES_URL: z.string().url(),
POSTGRES_HOST: z.string().min(1),
POSTGRES_USERNAME: z.string().min(1),
POSTGRES_PASSWORD: z.string().min(1),
AWS_S3_REGION: z.string().min(1),
AWS_S3_ACCESS_KEY_ID: z.string().min(1),
AWS_S3_SECRET_ACCESS_KEY: z.string().min(1),
AWS_S3_BUCKET_NAME: z.string().min(1),
CDN_API_KEY: z.string().min(1),
CDN_BASE_UPLOAD_URL: z.string().url(),
CDN_BASE_ACCESS_URL: z.string().url(),
},
runtimeEnv: {
DATABASE_URL: process.env.DATABASE_URL,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
POSTGRES_URL: process.env.POSTGRES_URL,
POSTGRES_HOST: process.env.POSTGRES_HOST,
POSTGRES_USERNAME: process.env.POSTGRES_USERNAME,
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
AWS_S3_REGION: process.env.AWS_S3_REGION,
AWS_S3_ACCESS_KEY_ID: process.env.AWS_S3_ACCESS_KEY_ID,
AWS_S3_SECRET_ACCESS_KEY: process.env.AWS_S3_SECRET_ACCESS_KEY,
AWS_S3_BUCKET_NAME: process.env.AWS_S3_BUCKET_NAME,
CDN_API_KEY: process.env.CDN_API_KEY,
CDN_BASE_UPLOAD_URL: process.env.CDN_BASE_UPLOAD_URL,
CDN_BASE_ACCESS_URL: process.env.CDN_BASE_ACCESS_URL,
},
});

0 comments on commit b43ecd2

Please sign in to comment.