multiple random id

This commit is contained in:
Lamp 2022-07-31 17:23:18 -07:00
parent 88a6e5e692
commit 3ab1623bed
3 changed files with 22 additions and 9 deletions

@ -16,7 +16,6 @@ Here is an HTML site that makes use of it: https://random.miku.pics/
- Browser back button is not useful
- HTTP Refresh does not save to browser history
- legality is ?????
### todo

@ -114,9 +114,14 @@ app.get("/img/:id", (req, res, next) => {
serveId(req.params.id, req, res, next);
});
// plaintext random id for scripts
// plaintext random id(s) for scripts
app.get("/randomid", function (req, res) {
res.type("text/plain").send(getRandomId(req.query.allow_r18));
var count = Number(req.query.count) || 1;
count = Math.min(count, 100);
var ids = [];
for (let i = 0; i < count; i++) ids.push(getRandomId(req.query.allow_r18));
ids = ids.join(',');
res.type("text/plain").send(ids);
});

21
package-lock.json generated

@ -4,6 +4,7 @@
"requires": true,
"packages": {
"": {
"name": "random-miku-server",
"dependencies": {
"express": "^4.17.1",
"gm": "^1.23.1",
@ -372,14 +373,22 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-fetch/node_modules/tr46": {
@ -915,9 +924,9 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"node-fetch": {
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
},