Compare commits
2 Commits
9897bcd577
...
7f57c0ed23
Author | SHA1 | Date | |
---|---|---|---|
7f57c0ed23 | |||
292ff9297d |
@ -17,8 +17,8 @@ The following environment variables are optional.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `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) |
|
||||
| `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) |
|
||||
| `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,12 +6,11 @@ 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");
|
||||
@ -53,7 +52,7 @@ app.post("*", (req, res, next) => {
|
||||
else {
|
||||
fs.rename(file.path, path.join(webroot, file.name), function (error) {
|
||||
if (error) return void next(error);
|
||||
let url = `${req.protocol}://${filecode}.${randomHostname?.() || req.hostname}`;
|
||||
var url = customUrlGen?.(filecode, req) || `${req.protocol}://${filecode}.${process.env.HOSTNAME || req.hostname}`;
|
||||
res.send(url);
|
||||
require("./discord-preloader.js")(url);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user