Skip to content

Commit

Permalink
Upgrade backend dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cmorabito-woolpert committed Jan 14, 2025
1 parent c1593e9 commit d4cad7c
Show file tree
Hide file tree
Showing 9 changed files with 5,226 additions and 6,210 deletions.
15 changes: 5 additions & 10 deletions application/backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import bodyParser from "body-parser";
import compression from "compression";
import cors from "cors";
import express, { Response, Request } from "express";
import expressPinoLogger from "express-pino-logger";

import { router as apiRoutes } from "./routes/api";
import { router as optimizationRoutes } from "./routes/optimization";
Expand All @@ -30,11 +29,7 @@ import { log } from "./logging";
export const app = express();

// logging
app.use(
expressPinoLogger({
logger: log,
})
);
app.use(log);

// headers
app.disable("x-powered-by");
Expand Down Expand Up @@ -63,7 +58,7 @@ app.use(bodyParser.urlencoded({ limit: "1gb", extended: true }));
* Readiness/liveness probe
*/
app.get("/healthz", async (req: Request, res: Response) => {
log.debug("Health check");
log.logger.debug("Health check");
res.status(200).send("OK");
});

Expand All @@ -82,7 +77,7 @@ app.get("/config.json", async (req: Request, res: Response) => {
);
config = response.data;
} catch (err) {
log.error(err);
log.logger.error(err);
}
}

Expand All @@ -92,7 +87,7 @@ app.get("/config.json", async (req: Request, res: Response) => {
const data = await fs.readFile("public/config.json");
config = JSON.parse(data.toString());
} catch (err) {
log.error(err);
log.logger.error(err);
return res.sendStatus(404);
}
}
Expand Down Expand Up @@ -122,7 +117,7 @@ app.get("/config.json", async (req: Request, res: Response) => {

res.status(200).send(config);
} catch (err) {
log.error(err);
log.logger.error(err);
return res.sendStatus(500);
}
});
Expand Down
6 changes: 3 additions & 3 deletions application/backend/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { pino, Logger } from "pino";
import { pinoHttp, HttpLogger } from "pino-http";

// map pino level to google cloud logging severity
const levelToGoogleSeverity: { [level: string]: string } = {
Expand Down Expand Up @@ -82,6 +82,6 @@ else if (process.env.LOG_FORMAT === "pretty") {
);
}

const p = pino(options);
const p = pinoHttp(options);

export const log: Logger = p;
export const log: HttpLogger = p;
Loading

0 comments on commit d4cad7c

Please sign in to comment.