Skip to content

Commit

Permalink
Removed commonJS
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanC112 committed Jun 3, 2024
1 parent d985a35 commit e3178d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions routes/projectsDB.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client } from "pg";
import activateDb from "../db";
import express from "express";
const router = express.Router();
import { Router } from "express";

const router = Router();

let client: Client | undefined;

Expand Down
19 changes: 11 additions & 8 deletions routes/projectsLocal.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import logger from "../utils/logger";
import express from "express";
import fs from "fs";
const router = express.Router();
import { Router } from "express";
import { readFile } from "fs";
import path from "path";

const router = Router();
const FILE_PATH: string = path.resolve(__dirname, "../data.json");

router.get("/", (req: any, res: any) => {
if (req.query) {
logger.warn("Query parameters ignored");
}

fs.readFile("../data.json", "utf8", (error: any, content: any) => {
readFile(FILE_PATH, "utf8", (error: any, content: any) => {
if (error) {
logger.error("Error reading data.json");
return res.status(500).send("Error reading file");
Expand All @@ -24,7 +27,7 @@ router.get("/team", (req: any, res: any) => {
return;
}

fs.readFile("../data.json", "utf8", (error: any, content: any) => {
readFile(FILE_PATH, "utf8", (error: any, content: any) => {
if (error) {
logger.error("Error reading data.json");
return res.status(500).send("Error reading file");
Expand Down Expand Up @@ -55,7 +58,7 @@ router.get("/cohort", (req: any, res: any) => {
return;
}

fs.readFile("../data.json", "utf8", (err: any, data: any) => {
readFile(FILE_PATH, "utf8", (err: any, data: any) => {
if (err) {
logger.error("Error reading data.json");
res.send("Error reading file").status(500);
Expand Down Expand Up @@ -87,7 +90,7 @@ router.get("/name", (req: any, res: any) => {
return;
}

fs.readFile("../data.json", "utf8", (err: any, data: any) => {
readFile(FILE_PATH, "utf8", (err: any, data: any) => {
if (err) {
logger.error("Error reading data.json");
res.send("Error reading file").status(500);
Expand Down
1 change: 0 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Client } from "pg";
import activateDb from "./db";
import logger from "./utils/logger";
import projectsLocal from "./routes/projectsLocal";
import projectsDB from "./routes/projectsDB";
import express from "express";

Expand Down

0 comments on commit e3178d9

Please sign in to comment.