This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
761 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Fetching the minified node image on apline linux | ||
FROM node:18.19-slim | ||
|
||
WORKDIR /uploadService | ||
COPY . . | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y openssl && \ | ||
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -sha256 -days 3650 -subj /CN=localhost -out cert.pem | ||
|
||
RUN npm install | ||
|
||
CMD ["node", "index.js"] | ||
|
||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const fs = require("fs"); | ||
const https = require("https"); | ||
const express = require("express"); | ||
const bodyParser = require("body-parser"); | ||
const app = express(); | ||
const port = 3000; | ||
|
||
const key = fs.readFileSync("key.pem", "utf-8"); | ||
const cert = fs.readFileSync("cert.pem", "utf-8"); | ||
|
||
const UPLOADS = {}; | ||
|
||
app.use(bodyParser.raw({ type: "application/octet-stream" })); | ||
|
||
app.get("/:path", (req, res) => { | ||
const path = req.params.path; | ||
console.log(`GET /${path}`); | ||
const file = UPLOADS[path]; | ||
if (file) { | ||
res.header("Content-Type", "application/octet-stream"); | ||
res.send(file); | ||
} else { | ||
console.log(`Upload path found: ${path}`); | ||
} | ||
}); | ||
|
||
app.post("/:path", (req, res) => { | ||
const path = req.params.path; | ||
console.log(`POST /${path}`, req.body); | ||
UPLOADS[path] = req.body; | ||
res.sendStatus(200); | ||
}); | ||
|
||
https.createServer({ key, cert }, app).listen(port, () => { | ||
console.log(`Upload service listening on port ${port}`); | ||
}); |
Oops, something went wrong.