Skip to content

Commit

Permalink
Use config for server name, refactor, build
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseHerminioCollas committed Feb 5, 2025
1 parent 8ba7226 commit fe2ea31
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ npm-debug.log*

.env

.vscode/
.vscode/

src/config.json
2 changes: 1 addition & 1 deletion backend/expressServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const metadata = {
image: '',
title: ''
};
app.post('/upload', async (req, res) => {
app.post('/server', async (req, res) => {
try {
const { title, svgString } = req.body;
metadata.title = title;
Expand Down
2 changes: 1 addition & 1 deletion docs/bundle.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/hooks/useUpload.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useState } from 'react';
import axios from 'axios';
import config from 'config.json';

interface UploadResponse {
ipfsHashMD: string;
}
const errorMessages = {
network: "Error: Could not access network",
general: "Error: An error occured whild trying to upload assest"
general: "Error: An error occured while trying to upload the assest"
};
const useUpload = () => {
const [uploading, setUploading] = useState<boolean>(false);
Expand All @@ -21,12 +22,12 @@ const useUpload = () => {
};

try {
const response = await axios.post<UploadResponse>('http://localhost:5000/upload', data);
const response = await axios.post<UploadResponse>(`${config.serverHost}/server`, data);
return response.data.ipfsHashMD;
} catch (err: any) {
const errMsg= err.message as string;
const errMsg = err.message as string;
let userMessage = errorMessages.general;
if(errMsg.includes('Network Error')){
if (errMsg.includes('Network Error')) {
userMessage = errorMessages.network;
}
setUploadError(userMessage);
Expand Down

0 comments on commit fe2ea31

Please sign in to comment.