Skip to content

Commit

Permalink
change port to something unlikely to be used
Browse files Browse the repository at this point in the history
  • Loading branch information
targoninc-alex committed Jun 22, 2024
1 parent fefc466 commit e3e970c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
19 changes: 17 additions & 2 deletions src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@ app.setAppUserModelId('fetchcat');
import {updateElectronApp} from 'update-electron-app';
updateElectronApp();

function startServer() {
const port = 48676;

async function startServer() {
try {
const test = await fetch(`http://localhost:${port}`);
if (test.status === 200) {
console.log('Server already running on a different instance');
return;
}
} catch (e) {
console.log('Server not running, starting...');
}

const app = express();
app.use(express.json());
app.get('/', (req, res) => {
res.send('Hello World');
});
app.post('/send-request', sendRequest());
app.post('/save-request', saveRequest());
app.get('/get-saved-request', getSavedRequest());
Expand Down Expand Up @@ -38,7 +53,7 @@ function startServer() {
StorageCache.set(key, value);
res.status(200).send();
});
app.listen(8080, () => {
app.listen(port, () => {
console.log("Server started");
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/classes/apicache.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class ApiCache {
static apiUrl = "http://localhost:8080/cache";
static apiUrl = "http://localhost:48676/cache";

static async set(key, value) {
await fetch(this.apiUrl, {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/classes/request.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ApiCache} from "./apicache.mjs";
import {newId} from "./ui.mjs";

export class Request {
static apiUrl = "http://localhost:8080/";
static apiUrl = "http://localhost:48676/";
cache = ApiCache;

constructor({url, method, headers, body, name, id, saved}) {
Expand Down
1 change: 0 additions & 1 deletion src/ui/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const saving = signal(false);
const sideBarOpen = signal(true);
const requests = signal([]);
Request.getSaved().then(reqs => {
console.log({reqs});
requests.value = reqs;
});

Expand Down
8 changes: 4 additions & 4 deletions src/ui/templates/layout.templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ export class LayoutTemplates {
}
});
}),
create("span")
.classes("status-text", savedClass)
.text(savedText)
.build(),
GenericTemplates.input("text", "name", name, "Name", "Name", "name", ["flex-grow"], (val) => {
request.updateName(val);
}),
Expand All @@ -135,6 +131,10 @@ export class LayoutTemplates {
});
});
}),
create("span")
.classes("status-text", savedClass)
.text(savedText)
.build(),
).build(),
create("div")
.classes("flex", "restrict-to-window")
Expand Down

0 comments on commit e3e970c

Please sign in to comment.