Skip to content

Commit

Permalink
Fix image rendering on cards
Browse files Browse the repository at this point in the history
  • Loading branch information
BaldissaraMatheus committed Feb 12, 2024
1 parent 0c32fff commit 3c05f49
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
2 changes: 0 additions & 2 deletions backend/package-lock.json

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

1 change: 0 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"koa": "^2.14.1",
"koa-bodyparser": "^4.3.0",
"koa-mount": "^4.0.0",
"koa-send": "^5.0.1",
"koa-static": "^5.0.0",
"uuid": "^9.0.0"
},
Expand Down
10 changes: 1 addition & 9 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const router = require("@koa/router")();
const bodyParser = require("koa-bodyparser");
const cors = require("@koa/cors");
const multer = require("@koa/multer");
const send = require("koa-send");
const mount = require("koa-mount");
const serve = require("koa-static");

Expand Down Expand Up @@ -320,14 +319,6 @@ async function saveCardsSort(ctx) {

router.post("/sort/cards", saveCardsSort);

async function getImage(ctx) {
await send(ctx, `${process.env.CONFIG_DIR}/images/${ctx.params.image}`, {
root: process.env.NODE_ENV === "prod" ? "/" : __dirname,
});
}

router.get("/images/:image", getImage);

async function saveImage(ctx) {
const imageName = ctx.request.file.originalname;
await fs.promises.mkdir(`${process.env.CONFIG_DIR}/images`, {
Expand Down Expand Up @@ -374,6 +365,7 @@ app.use(async (ctx, next) => {
});
app.use(mount(`${BASE_PATH}api`, router.routes()));
app.use(mount(BASE_PATH, serve("/static")));
app.use(mount(`${BASE_PATH}api/images`, serve(`${process.env.CONFIG_DIR}/images`)));
app.use(
mount(
`${BASE_PATH}stylesheets/`,
Expand Down

0 comments on commit 3c05f49

Please sign in to comment.