Replace shortid with nanoid

master
Joe Biellik 4 years ago
parent 05f852fd64
commit 8ce1beccbe

@ -12,7 +12,7 @@ Try it out at [paste.fyi](https://paste.fyi/)
* Automatic and configurable paste expiry * Automatic and configurable paste expiry
* Full support for CLI requests with [curl](https://curl.haxx.se/), [Wget](https://www.gnu.org/software/wget/) etc * Full support for CLI requests with [curl](https://curl.haxx.se/), [Wget](https://www.gnu.org/software/wget/) etc
* <kbd>CTRL</kbd>+<kbd>Enter</kbd> hotkey for quick paste submission * <kbd>CTRL</kbd>+<kbd>Enter</kbd> hotkey for quick paste submission
* Short URLs via [shortid](https://github.com/dylang/shortid), e.g. `NyQO9puMe` * Short and readable URLs via [nanoid](https://github.com/ai/nanoid), e.g. `/qNGDwRyx`
* Textarea grows to fit content via [autosize.js](https://github.com/jackmoore/autosize) * Textarea grows to fit content via [autosize.js](https://github.com/jackmoore/autosize)
* Runs fully containerized with [Docker](https://www.docker.com/) * Runs fully containerized with [Docker](https://www.docker.com/)
@ -20,7 +20,7 @@ Try it out at [paste.fyi](https://paste.fyi/)
```sh ```sh
# Simple paste # Simple paste
$ echo 'Hello World' | curl -F 'paste=<-' paste.fyi $ echo 'Hello World' | curl -F 'paste=<-' paste.fyi
http://paste.fyi/N15FNVqfg http://paste.fyi/qNGDwRyx
# Either form, multipart or raw text data is accepted # Either form, multipart or raw text data is accepted
$ curl -F 'paste=Sent as form data' https://paste.fyi $ curl -F 'paste=Sent as form data' https://paste.fyi

@ -1,8 +1,10 @@
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const shortid = require('shortid'); const { customAlphabet } = require('nanoid');
const dictionary = require('nanoid-dictionary');
const nanoid = customAlphabet(dictionary.nolookalikes, 8);
const paste = new mongoose.Schema({ const paste = new mongoose.Schema({
_id: { type: String, default: shortid.generate }, _id: { type: String, default: nanoid },
paste: { type: String }, paste: { type: String },
expiresAt: { type: Date, expires: 0 } expiresAt: { type: Date, expires: 0 }
}, { }, {

25
package-lock.json generated

@ -1880,9 +1880,9 @@
} }
}, },
"mongoose": { "mongoose": {
"version": "5.9.25", "version": "5.9.26",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.9.25.tgz", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.9.26.tgz",
"integrity": "sha512-vz/DqJ3mrHqEIlfRbKmDZ9TzQ1a0hCtSQpjHScIxr4rEtLs0tjsXDeEWcJ/vEEc3oLfP6vRx9V+uYSprXDUvFQ==", "integrity": "sha512-mVddZM1mB8xg9oJQZAXaN762B01puV+jL5mPqg1HBXpEs7TG6ZZ/hEk98YRJMJff/YhIzuK3a3oos6XWtTaVUQ==",
"requires": { "requires": {
"bson": "^1.1.4", "bson": "^1.1.4",
"kareem": "2.3.1", "kareem": "2.3.1",
@ -1954,9 +1954,14 @@
} }
}, },
"nanoid": { "nanoid": {
"version": "2.1.11", "version": "3.1.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.11.tgz",
"integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==" "integrity": "sha512-HyrIRpCB2uS1/sEoS7/UIAM/Jn72uXf2/yWgQRP0e16/UdMsfH/1JyLj2SqyQlkMkeeN1ad61tpT6FPRRimxnA=="
},
"nanoid-dictionary": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/nanoid-dictionary/-/nanoid-dictionary-3.0.0.tgz",
"integrity": "sha512-dYCOXltfavrN7LGYt3DEAGl6Ya3UcnypXPsYR7HZ5k1eIesakVm+zlfv7V75uSe+Zhyxvyhg9yEbPl8qMx1dwA=="
}, },
"natural-compare": { "natural-compare": {
"version": "1.4.0", "version": "1.4.0",
@ -2687,14 +2692,6 @@
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true "dev": true
}, },
"shortid": {
"version": "2.2.15",
"resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.15.tgz",
"integrity": "sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw==",
"requires": {
"nanoid": "^2.1.0"
}
},
"sift": { "sift": {
"version": "7.0.1", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz",

@ -34,9 +34,10 @@
"koa-router": "^9.1.0", "koa-router": "^9.1.0",
"koa-static-cache": "^5.1.3", "koa-static-cache": "^5.1.3",
"koa-views": "^6.3.0", "koa-views": "^6.3.0",
"mongoose": "^5.9.25", "mongoose": "^5.9.26",
"pug": "^3.0.0", "nanoid": "^3.1.11",
"shortid": "^2.2.15" "nanoid-dictionary": "^3.0.0",
"pug": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^7.5.0", "eslint": "^7.5.0",

Loading…
Cancel
Save