Skip to content

Commit 23c2408

Browse files
committed
refactor: replace NEXTAUTH environment variables with CLERK
This commit introduces the Clerk authentication service to the project. It replaces the NEXTAUTH environment variables with the new Clerk environment variables. The following commits will structure the Clerk authentication service and the implementation in the `@louffee/auth` internal package. This commit is part of the issue #2.
1 parent 7afe3b3 commit 23c2408

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

.env.example

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ CLOUDFLARE_UPLOAD_BUCKET_ID="<bucket_id>"
1717
CLOUDFLARE_UPLOAD_BUCKET_NAME="louffee-dev-upload"
1818
CLOUDFLARE_STORAGE_BUCKET_NAME="louffee-dev"
1919

20-
# Next Auth environment variables
21-
NEXTAUTH_URL="http://localhost:3000"
22-
NEXTAUTH_SECRET="<secret>"
23-
GOOGLE_CLIENT_ID="<google_client_id>"
24-
GOOGLE_CLIENT_SECRET="<google_client_secret>"
20+
# Clerk (Auth service) environment variables
21+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="<clerk_publishable_key>"
22+
CLERK_SECRET_KEY="<clerk_secret_key>

packages/env/src/env.ts

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import path from 'node:path'
2-
3-
import dotenv from 'dotenv'
41
import { z } from 'zod'
2+
import loadEnvironment from './load-environment'
53

6-
dotenv.config({
7-
encoding: 'UTF-8',
8-
debug: true,
9-
path: path.resolve(process.cwd(), '..', '..', '.env'),
10-
})
4+
loadEnvironment()
115

126
/**
137
* The object which defines the environment key names.
@@ -46,11 +40,16 @@ const environmentKeyMap = {
4640
name: 'CLOUDFLARE_STORAGE_BUCKET_NAME',
4741
},
4842
},
49-
nextAuth: {
50-
secret: 'NEXTAUTH_SECRET',
51-
URL: 'NEXTAUTH_URL',
43+
clerkJS: {
44+
secret: {
45+
key: 'CLERK_SECRET_KEY',
46+
},
5247
public: {
53-
nextAuthURL: 'NEXT_PUBLIC_NEXTAUTH_URL',
48+
publishableKey: 'NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY',
49+
signInURL: 'NEXT_PUBLIC_CLERK_SIGN_IN_URL',
50+
signUpURL: 'NEXT_PUBLIC_CLERK_SIGN_UP_URL',
51+
afterSignInURL: 'NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL',
52+
afterSignUpURL: 'NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL',
5453
},
5554
},
5655
googleClient: {
@@ -101,9 +100,12 @@ const EnvironmentVariablesSchema = z.object({
101100
[environmentKeyMap.cloudflare.uploadBucket.name]: z.string().default('<upload_bucket_name>'),
102101
[environmentKeyMap.cloudflare.storage.name]: z.string().default('<storage_bucket_name>'),
103102

104-
[environmentKeyMap.nextAuth.secret]: z.string().default('<nextauth_secret>'),
105-
[environmentKeyMap.nextAuth.URL]: z.string().default('http://localhost:3000'),
106-
[environmentKeyMap.nextAuth.public.nextAuthURL]: z.string().default('http://localhost:3000'),
103+
[environmentKeyMap.clerkJS.secret.key]: z.string().default('<clerk_secret_key>'),
104+
[environmentKeyMap.clerkJS.public.publishableKey]: z.string().default('<clerk_publishable_key>'),
105+
[environmentKeyMap.clerkJS.public.signInURL]: z.string().default('<clerk_sign_in_url>'),
106+
[environmentKeyMap.clerkJS.public.signUpURL]: z.string().default('<clerk_sign_up_url>'),
107+
[environmentKeyMap.clerkJS.public.afterSignInURL]: z.string().default('<clerk_after_sign_in_url>'),
108+
[environmentKeyMap.clerkJS.public.afterSignUpURL]: z.string().default('<clerk_after_sign_up_url>'),
107109

108110
[environmentKeyMap.googleClient.id]: z.string().default('<google_client_id>'),
109111
[environmentKeyMap.googleClient.secret]: z.string().default('<google_client_secret>'),

0 commit comments

Comments
 (0)