Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use config for server name, refactor, build #40

Merged
merged 1 commit into from
Feb 5, 2025
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
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
Loading