diff --git a/package-lock.json b/package-lock.json index b2405b5..ec15890 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,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", @@ -8685,9 +8685,9 @@ } }, "node_modules/dotenv": { - "version": "16.1.4", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.4.tgz", - "integrity": "sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==", + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", "engines": { "node": ">=12" }, @@ -14677,11 +14677,11 @@ } }, "node_modules/react-native-dotenv": { - "version": "3.4.8", - "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.8.tgz", - "integrity": "sha512-fg9F8X/cG1kDTwRLgLz3t+AMbsULoFHbUVltdQarmrJ3kNllD1Zq7ZgY85bp8BnPwk0DnYQzKbooiLsUoKd10w==", + "version": "3.4.9", + "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.9.tgz", + "integrity": "sha512-dbyd+mcy7SUzxEgmt33TRf1FGcNe6swJhXmB0unKkI49F7+pidog9kPtjxMLTAfmKA8gcN2XHQSKltGfGbGCLQ==", "dependencies": { - "dotenv": "^16.0.3" + "dotenv": "^16.3.1" }, "peerDependencies": { "@babel/runtime": "^7.20.6" @@ -23232,9 +23232,9 @@ } }, "dotenv": { - "version": "16.1.4", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.1.4.tgz", - "integrity": "sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==" + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==" }, "dotenv-expand": { "version": "10.0.0", @@ -27636,11 +27636,11 @@ } }, "react-native-dotenv": { - "version": "3.4.8", - "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.8.tgz", - "integrity": "sha512-fg9F8X/cG1kDTwRLgLz3t+AMbsULoFHbUVltdQarmrJ3kNllD1Zq7ZgY85bp8BnPwk0DnYQzKbooiLsUoKd10w==", + "version": "3.4.9", + "resolved": "https://registry.npmjs.org/react-native-dotenv/-/react-native-dotenv-3.4.9.tgz", + "integrity": "sha512-dbyd+mcy7SUzxEgmt33TRf1FGcNe6swJhXmB0unKkI49F7+pidog9kPtjxMLTAfmKA8gcN2XHQSKltGfGbGCLQ==", "requires": { - "dotenv": "^16.0.3" + "dotenv": "^16.3.1" } }, "react-native-gesture-handler": { diff --git a/package.json b/package.json index 4579e94..365b279 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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", diff --git a/src/app/(auth)/login.tsx b/src/app/(auth)/login.tsx index 96397cf..3019f8b 100644 --- a/src/app/(auth)/login.tsx +++ b/src/app/(auth)/login.tsx @@ -36,6 +36,7 @@ export default function Login() { } = useForm({}); const login: SubmitHandler = async (formData) => { + console.log("logging in"); try { const { data } = await axios.post("/login", formData); console.log("new token in login.tsx", data.token); diff --git a/src/components/DynamicAvatar.tsx b/src/components/DynamicAvatar.tsx index bccab2c..646328a 100644 --- a/src/components/DynamicAvatar.tsx +++ b/src/components/DynamicAvatar.tsx @@ -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; @@ -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, }; }; diff --git a/src/components/DynamicCardCover.tsx b/src/components/DynamicCardCover.tsx index 6638a8b..40646bb 100644 --- a/src/components/DynamicCardCover.tsx +++ b/src/components/DynamicCardCover.tsx @@ -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; @@ -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", }; }; diff --git a/src/contexts/auth.tsx b/src/contexts/auth.tsx index cb89edf..b708f26 100644 --- a/src/contexts/auth.tsx +++ b/src/contexts/auth.tsx @@ -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"; @@ -76,7 +75,7 @@ export function AuthProvider({ children }: PropsWithChildren) { // stores and sets the token const updateTokenUser = async (token: string) => { try { - const decode = JWT.decode(token, JWT_SECRET); + const decode = JWT.decode(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}`; diff --git a/src/index.ts b/src/index.ts index 0c9e91f..ef5cdb2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 diff --git a/src/types/env.d.tsx b/src/types/env.d.tsx deleted file mode 100644 index 2810481..0000000 --- a/src/types/env.d.tsx +++ /dev/null @@ -1,4 +0,0 @@ -declare module "@env" { - export const AXIOS_BASE_URL: string; - export const JWT_SECRET: string; -}