Compare commits
No commits in common. "7f57c0ed23eb3f7e5682e31f565b38e81bb0b9aa" and "9897bcd577ee1c77bc27969163f165b98fd1b53a" have entirely different histories.
7f57c0ed23
...
9897bcd577
@ -17,8 +17,8 @@ The following environment variables are optional.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `HOSTNAME` | Overrides the hostname for generating URLs. | hostname of the upload request |
|
||||
| `DISCORD_WEBHOOK` | Discord webhook url that newly-uploaded URLs will be sent to to pre-load their embed, which theoretically makes them embed again faster. | `undefined` (disabled) |
|
||||
| `HOSTNAMES` | Comma-separated list of hostnames that will be chosen at random for the URL sent back after an upload. | request hostname |
|
||||
| `DISCORD_WEBHOOK` | Discord webhook url that uploads will be sent to to make them pre-load the embed, which theoretically makes it faster. | `undefined` (disabled) |
|
||||
| `PORT` | TCP port to listen on | `8568` |
|
||||
| `ADDRESS` | Address to bind to | `'0.0.0.0'` (all) |
|
||||
| `FILES_DIR` | Directory to store the files in | `'files'` (relative of working directory) |
|
||||
|
9
qonq.js
9
qonq.js
@ -6,11 +6,12 @@ var serveIndex = require("serve-index");
|
||||
var serveFavicon = require("serve-favicon");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
try {
|
||||
var customUrlGen = require("./custom-urlgen");
|
||||
} catch(e) {}
|
||||
|
||||
var FILES_DIR = process.env.FILES_DIR || "files";
|
||||
if (process.env.HOSTNAMES) {
|
||||
var HOSTNAMES = process.env.HOSTNAMES.split(',');
|
||||
var randomHostname = () => HOSTNAMES[Math.floor(Math.random() * HOSTNAMES.length)];
|
||||
}
|
||||
|
||||
var app = express();
|
||||
app.set("env", "production");
|
||||
@ -52,7 +53,7 @@ app.post("*", (req, res, next) => {
|
||||
else {
|
||||
fs.rename(file.path, path.join(webroot, file.name), function (error) {
|
||||
if (error) return void next(error);
|
||||
var url = customUrlGen?.(filecode, req) || `${req.protocol}://${filecode}.${process.env.HOSTNAME || req.hostname}`;
|
||||
let url = `${req.protocol}://${filecode}.${randomHostname?.() || req.hostname}`;
|
||||
res.send(url);
|
||||
require("./discord-preloader.js")(url);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user