Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
parkrafael committed Dec 4, 2024
1 parent aaeb5ee commit cbdbfde
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import cors from "cors";
import dotenv from "dotenv";
import express from "express";
import authRoutes from "./src/routes/authRoutes.js";
import logRoutes from "./src/routes/logRoutes.js";
import transcriptionRoutes from "./src/routes/transcriptionRoutes.js";
import authRoutes from "./src/routes/auth-route.js";
import logbookRoutes from "./src/routes/logbooks-route.js";
import transcriptionRoutes from "./src/routes/transcription-route.js";
import fileUpload from "express-fileupload";

dotenv.config();
Expand All @@ -20,7 +20,7 @@ app.use(fileUpload());

//Routes
app.use("/api/auth", authRoutes);
app.use("/api/log", logRoutes);
app.use("/api/logbooks", logbookRoutes);
app.use("/api/transcriptions", transcriptionRoutes);

app.listen(PORT, () => {
Expand Down
28 changes: 14 additions & 14 deletions backend/package-lock.json

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

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dotenv": "^16.4.5",
"express": "^4.21.0",
"express-fileupload": "^1.5.1",
"form-data": "^4.0.1",
"jsonwebtoken": "^9.0.2",
"supabase": "^1.207.9"
},
Expand Down
8 changes: 4 additions & 4 deletions backend/src/services/logbooks-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function getUserLogbooks(req) {
const token = req.header("Authorization")?.split(" ")[1];
const userID = parseUserID(token);
if (userID.error) {
throw new Error(userID.error.message)
throw new Error(userID.error)
}
const userLogbooks = await getTable(supabase, "logbooks", "user_id", userID, "collection");
return userLogbooks;
Expand Down Expand Up @@ -47,7 +47,7 @@ export async function createLog(req) {
body["logbook_id"] = logbookID;
const logbookType = await getLogbookType(logbookID, supabase);
if (logbookType.error) {
throw new Error(logbookType.error.message);
throw new Error(logbookType.error);
}
if (body["type"] !== logbookType) {
throw new Error(`log type '${body["type"]}' does not match logbook type '${logbookType}'`);
Expand All @@ -69,7 +69,7 @@ export async function getLogbookLogs(req) {
const { logbookID } = req.params;
const logbookType = await getLogbookType(logbookID, supabase);
if (logbookType.error) {
throw new Error(logbookType.error.message);
throw new Error(logbookType.error);
}
const logbookLogs = await getTable(supabase, logbookType, "logbook_id", logbookID, "collection");
return logbookLogs;
Expand All @@ -84,7 +84,7 @@ export async function getLog(req) {
const { logbookID, logID } = req.params;
const logbookType = await getLogbookType(logbookID, supabase);
if (logbookType.error) {
throw new Error(logbookType.error.message);
throw new Error(logbookType.error);
}
const log = await getTable(supabase, logbookType, "id", logID, "resource");
if (typeof log == "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/get-logbook-type.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default async function getLogbookType(logbookID, supabase) {
try {
const { data, error } = await supabase.from("logbooks").select().eq("id", logbookID);
if (data.length == 0 && typeof error == "undefined") {
if (data.length == 0) {
throw new Error(`logbook ${logbookID} does not exist`);
} else if (error) {
throw new Error(error.message);
Expand Down

0 comments on commit cbdbfde

Please sign in to comment.