Skip to content

Commit

Permalink
refactor: hardcode env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mbappai committed Nov 14, 2024
1 parent 8597b0c commit 4a658d4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- name: Code Checkout
uses: actions/checkout@v3 # Checkout the code

- uses: actions/setup-node@v3 # Install Node.js in the Runner, and allow us to run npm commands
- uses: actions/setup-node@v4 # Install Node.js in the Runner, and allow us to run npm commands
with:
node-version: "16"

- uses: actions/cache@v3 # Caches the node_modules folder across builds, and makes the Runner use the cache as long as package-lock.json doesn’t change.
- uses: actions/cache@v4 # Caches the node_modules folder across builds, and makes the Runner use the cache as long as package-lock.json doesn’t change.
with:
# Next.js stores its cache in the .next/cache directory. This will persist the cache across builds for faster application rebuilds.
path: |
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
run: cat .env

- name: Upload Next build # Upload the artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: build
path: |
Expand All @@ -61,7 +61,7 @@ jobs:
uses: actions/checkout@v3

- name: Download next build # Download the above uploaded artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: build

Expand Down
6 changes: 4 additions & 2 deletions components/Redirect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
import supabase from "../utils/supabaseClient"
import utils from "../utils/envVars"
import envUtils from "../utils/envVars"

interface RedirectProps {
paseto: string
Expand All @@ -16,9 +18,9 @@ export default function Redirect() {
const checkoutStatus = localStorage.getItem('checkout');
const paseto = localStorage.getItem('PLATFORM_PASETO')

const marketplaceReturnUrl = paymentStatus ? `${process.env.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}&payment=pending` : checkoutStatus? `${process.env.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}&checkout=pending`: `${process.env.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}`
const marketplaceReturnUrl = paymentStatus ? `${envUtils.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}&payment=pending` : checkoutStatus? `${utils.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}&checkout=pending`: `${utils.NEXT_PUBLIC_MARKETPLACE}?paseto=${paseto}`

const redirectUrl = redirectTo === 'portal' ? `${process.env.NEXT_PUBLIC_PORTAL}?paseto=${paseto}` : marketplaceReturnUrl
const redirectUrl = redirectTo === 'portal' ? `${envUtils.NEXT_PUBLIC_PORTAL}?paseto=${paseto}` : marketplaceReturnUrl
// const redirectUrl = redirectTo === 'portal'?`http://localhost:3000/login?paseto=${paseto}`: `http://localhost:3006/login?paseto=${paseto}&payment=pending`
setTimeout(() => {
router.replace(redirectUrl)
Expand Down
3 changes: 2 additions & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import theme from '../theme'
import {
GoogleReCaptchaProvider,
} from 'react-google-recaptcha-v3';
import envUtils from "../utils/envVars";

function MyApp({ Component, pageProps }) {
return (
Expand All @@ -17,7 +18,7 @@ function MyApp({ Component, pageProps }) {
</Head>
<div className="h-[92vh]">
<ChakraProvider theme={theme}>
<GoogleReCaptchaProvider reCaptchaKey={process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY}>
<GoogleReCaptchaProvider reCaptchaKey={envUtils.NEXT_PUBLIC_RECAPTCHA_SITE_KEY}>
<AuthContextProvider>
<Component {...pageProps} />
</AuthContextProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/api/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

export const axiosApp = axios.create({
// baseURL: process.env.NEXT_PUBLIC_API_URL
// baseURL: utils.NEXT_PUBLIC_API_URL
baseURL: 'https://platform.flexabledats.com/api/v1.0/'
})
7 changes: 4 additions & 3 deletions utils/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { removePlatformPaseto, setPlatformPaseto } from "../src/storage";
import envUtils from "./envVars";
import supabase from "./supabaseClient";

// todo: signIn
Expand All @@ -25,7 +26,7 @@ export const signInWithProvider = async (provider) => {
provider,
},
// only redirects to a page in thesame domain
{ redirectTo: `${process.env.NEXT_PUBLIC_ORIGIN}/dashboard` } // no way to pass the paceto using this option
{ redirectTo: `${envUtils.NEXT_PUBLIC_ORIGIN}/dashboard` } // no way to pass the paceto using this option
);
return { session, error };

Expand All @@ -38,15 +39,15 @@ export const signUp = async ({ email, password }) => {
email,
password,
},
{ redirectTo: `${process.env.NEXT_PUBLIC_ORIGIN}/dashboard` }
{ redirectTo: `${envUtils.NEXT_PUBLIC_ORIGIN}/dashboard` }
);
return { user, session, error };
};

// todo: create Recovery for the forgotten password
export const createRecovery = async (email) => {
const { data, error } = await supabase.auth.api.resetPasswordForEmail(email, {
redirectTo: `${process.env.NEXT_PUBLIC_ORIGIN}/update-password`,
redirectTo: `${envUtils.NEXT_PUBLIC_ORIGIN}/update-password`,
});
return { data, error };
};
Expand Down
17 changes: 17 additions & 0 deletions utils/envVars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const NEXT_PUBLIC_SUPABASE_URL = 'https://sqfhktjlzezxxfvypqiu.supabase.co'
const NEXT_PUBLIC_SUPABASE_API_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNxZmhrdGpsemV6eHhmdnlwcWl1Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjM5NTM5NzgsImV4cCI6MTk3OTUyOTk3OH0.RCLswqFgQm0VHQj-z6CJX5QP_dL0GKY7_wXPGzKmOfU'
const NEXT_PUBLIC_ORIGIN = 'https://auth.flexabledats.com'
const NEXT_PUBLIC_API_URL = 'https://platform.flexabledats.com/api/v1.0/'
const NEXT_PUBLIC_MARKETPLACE = 'https://marketplace.flexabledats.com'
const NEXT_PUBLIC_PORTAL = 'https://portal.flexabledats.com'

const envUtils = {
NEXT_PUBLIC_SUPABASE_URL,
NEXT_PUBLIC_SUPABASE_API_KEY,
NEXT_PUBLIC_ORIGIN,
NEXT_PUBLIC_API_URL,
NEXT_PUBLIC_MARKETPLACE,
NEXT_PUBLIC_PORTAL
}

export default envUtils
5 changes: 3 additions & 2 deletions utils/supabaseClient.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { createClient } from "@supabase/supabase-js";
import envUtils from "./envVars";

const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_API_KEY
envUtils.NEXT_PUBLIC_SUPABASE_URL,
envUtils.NEXT_PUBLIC_SUPABASE_API_KEY
);

export default supabase;

0 comments on commit 4a658d4

Please sign in to comment.