add resize image based on url

This commit is contained in:
solehudin5699
2024-03-09 13:39:47 +07:00
parent 87b934ef12
commit 0e5cb94005
5 changed files with 133 additions and 17 deletions
+8
View File
@@ -15,10 +15,15 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static("public"));
//GET UI
app.get("/", async (req, res) => {
res.sendFile(path.join(__dirname, "./public/index.html"));
});
// GET/DOWNLOAD IMAGE
app.get("/public/:filename", resizer);
//UPLOAD IMAGE
app.post("/", uploadMiddleware, (req, res) => {
res.json({
success: true,
@@ -27,6 +32,9 @@ app.post("/", uploadMiddleware, (req, res) => {
});
});
//RESIZE IMG FROM URL (query-> width,height,format,quality)
app.get("/image/resize/*", resizer);
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});