Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
moved to process.env for env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
georgib0y committed Sep 30, 2023
1 parent 5625c31 commit a97f759
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 30 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"expo-constants": "~14.4.2",
"expo-file-system": "~15.4.4",
"expo-font": "~11.4.0",
"expo-image": "~1.3.3",
"expo-image-picker": "~14.3.2",
"expo-jwt": "^1.5.0",
"expo-linking": "~5.0.2",
Expand All @@ -32,7 +33,7 @@
"react": "18.2.0",
"react-hook-form": "^7.45.1",
"react-native": "0.72.5",
"react-native-dotenv": "^3.4.8",
"react-native-dotenv": "^3.4.9",
"react-native-gesture-handler": "~2.12.0",
"react-native-modal-datetime-picker": "^16.0.0",
"react-native-pager-view": "6.2.0",
Expand All @@ -42,8 +43,7 @@
"react-native-svg": "13.9.0",
"react-native-tab-view": "^3.5.2",
"react-native-web": "~0.19.6",
"typescript": "^5.1.3",
"expo-image": "~1.3.3"
"typescript": "^5.1.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
1 change: 1 addition & 0 deletions src/app/(auth)/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function Login() {
} = useForm<FormData>({});

const login: SubmitHandler<FormData> = async (formData) => {
console.log("logging in");
try {
const { data } = await axios.post<GetToken>("/login", formData);
console.log("new token in login.tsx", data.token);
Expand Down
3 changes: 1 addition & 2 deletions src/components/DynamicAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ImageURISource } from "react-native";
import { Avatar } from "react-native-paper";
import { AXIOS_BASE_URL } from "@env";
import { PetType, UserType } from "../types/types";

type DefaultPfpType = "user" | UserType | PetType;
Expand All @@ -24,7 +23,7 @@ export default function DynamicAvatar({

// otherwise convert it to an ImageUriSource
return {
uri: AXIOS_BASE_URL + "/images/" + pfp,
uri: process.env.AXIOS_BASE_URL + "/images/" + pfp,
};
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/DynamicCardCover.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Image, ImageProps, ImageSourcePropType } from "react-native";
import { AXIOS_BASE_URL } from "@env";
import { PetType, UserType } from "../types/types";

type DefaultImageType = "user" | UserType | PetType;
Expand All @@ -16,7 +15,7 @@ export default function DynamicCardCover({
}: DynamicCardCoverProps) {
const getImageSource = (): ImageSourcePropType => {
return {
uri: AXIOS_BASE_URL + "/images/" + imageId,
uri: process.env.AXIOS_BASE_URL + "/images/" + imageId,
method: "GET",
};
};
Expand Down
3 changes: 1 addition & 2 deletions src/contexts/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "react";
import JWT from "expo-jwt";
import * as SecureStore from "expo-secure-store";
import { JWT_SECRET } from "@env";
import axios from "axios";
import { UserType } from "../types/types";

Expand Down Expand Up @@ -76,7 +75,7 @@ export function AuthProvider({ children }: PropsWithChildren) {
// stores and sets the token
const updateTokenUser = async (token: string) => {
try {
const decode = JWT.decode<TokenUser>(token, JWT_SECRET);
const decode = JWT.decode<TokenUser>(token, process.env.JWT_SECRET ?? "");
// set the Authorization header to send in axios calls if decode is
// successful
axios.defaults.headers.common["Authorization"] = `Bearer ${token}`;
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { AXIOS_BASE_URL } from "@env";
import { LogBox } from "react-native";
import axios from "axios";
import "expo-router/entry";

axios.defaults.baseURL = AXIOS_BASE_URL;
axios.defaults.baseURL = process.env.AXIOS_BASE_URL;

// Ignore Stack deprecation warning as this is a bug in expo router
// https://github.com/expo/router/issues/834
Expand Down
4 changes: 0 additions & 4 deletions src/types/env.d.tsx

This file was deleted.

0 comments on commit a97f759

Please sign in to comment.