Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 115 additions & 10 deletions Frontend/package-lock.json

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

5 changes: 5 additions & 0 deletions Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,18 @@
"@babel/plugin-proposal-private-property-in-object": "^7.16.7",
"@babel/preset-env": "^7.25.3",
"@babel/preset-react": "^7.24.7",
"@types/node": "^22.5.5",
"@types/react": "^18.3.8",
"@types/react-native": "^0.73.0",
"babel-plugin-inline-dotenv": "^1.7.0",
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"cp-cli": "^2.0.0",
"eslint": "^8.56.0",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.7.0",
"tsc-alias": "^1.8.10",
"typescript": "^4.9.5",
"webpack": "^5.92.1"
},
"version": "1.0.0",
Expand Down
15 changes: 0 additions & 15 deletions Frontend/shared/.babelrc

This file was deleted.

4 changes: 2 additions & 2 deletions Frontend/shared/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_API_DOMAIN=api.speedcartapp.com
REACT_APP_API_PORT=8443
API_DOMAIN=api.speedcartapp.com
API_PORT=8443
1 change: 1 addition & 0 deletions Frontend/shared/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
src/constants/config.json
15 changes: 15 additions & 0 deletions Frontend/shared/generate-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const fs = require('fs');
const path = require('path');
const dotenv = require('dotenv');

// Load environment variables from the .env file
dotenv.config();

const config = {
API_DOMAIN: process.env.API_DOMAIN,
API_PORT: process.env.API_PORT,
};

// Write the config to a file in the shared directory
fs.writeFileSync(path.resolve(__dirname, './src/constants/config.json'), JSON.stringify(config, null, 2));
console.log('Config file generated successfully.');
2 changes: 1 addition & 1 deletion Frontend/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "./dist/index.js",
"scripts": {
"build": "babel src --out-dir dist && echo Success"
"build": "node generate-config.js && tsc && tsc-alias && echo Success"
},
"keywords": [],
"author": "",
Expand Down
8 changes: 8 additions & 0 deletions Frontend/shared/src/constants/BaseUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// src/constants/config/config.ts
import config from './config.json';

const API_DOMAIN = config.API_DOMAIN;
const API_PORT = config.API_PORT;

// This can be reused for all backend interactions
export const BASE_URL: string = `https://${API_DOMAIN}:${API_PORT}`;
2 changes: 0 additions & 2 deletions Frontend/shared/src/constants/config/config.js

This file was deleted.

1 change: 0 additions & 1 deletion Frontend/shared/src/constants/config/index.js

This file was deleted.

5 changes: 5 additions & 0 deletions Frontend/shared/src/constants/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// src/constants/index.d.ts

declare module '@constants' {
export const BASE_URL;
}
1 change: 0 additions & 1 deletion Frontend/shared/src/constants/index.js

This file was deleted.

1 change: 1 addition & 0 deletions Frontend/shared/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './BaseUrl';

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BASE_URL } from '@constants';
import { GroceryItem } from '@types';

export const createGroceryItem = async (item: GroceryItem) => {
return fetch(`${BASE_URL}/grocery-items`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify(item)
});
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL } from '@constants/config';
import { BASE_URL } from '@constants';

export const createShareLink = async (shareListId, permissions) => {
export const createShareLink = async (shareListId: string, permissions: any) => {
return fetch(`${BASE_URL}/share/${shareListId}`, {
method: 'POST',
headers: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL } from "@constants/config";
import { BASE_URL } from '@constants';

export const createSharingPermissions = async (token) => {
export const createSharingPermissions = async (token: string) => {
return fetch(`${BASE_URL}/share/${token}`, {
method: 'GET',
headers: {
Expand Down
Loading