diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-03-31 15:11:22 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-03-31 15:11:22 +0200 |
| commit | 6feecf8d38944067963435be1524f1b532bec38c (patch) | |
| tree | 80311945debe1cc280496bd88b0471d7c28f39be /lib | |
| parent | ad6fff63c69a529096b5ea9d1fc81bd9e95bb54d (diff) | |
| parent | 19d8a1315cfaa51cb342570cd31df525e56e0513 (diff) | |
Merge branch 'master' of ghghgh.us:luckyplop
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/db/index.js | 4 | ||||
| -rw-r--r-- | lib/index.js | 21 | ||||
| -rw-r--r-- | lib/upload.js | 4 |
3 files changed, 14 insertions, 15 deletions
diff --git a/lib/db/index.js b/lib/db/index.js index ffd8c27..6e36602 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -31,14 +31,14 @@ db.getRandom = function () { } db.getRandomAscii = function () { return ShaderImage.query(function(qb){ - qb.where("tag", "=", "ascii").orderBy(knex.raw('RAND()')).limit(1) + qb.where("tag", "ascii").orderBy(knex.raw('RAND()')).limit(1) }).fetch() } db.getIndex = function(limit, offset) { return Image.query(function(qb){ qb.orderBy("id", "desc").limit(limit) if (offset) qb.offset(offset) - }).fetch() + }).fetchAll() } db.createImage = function(url){ return new Image({ url: url }).save() diff --git a/lib/index.js b/lib/index.js index a9db423..781ac04 100644 --- a/lib/index.js +++ b/lib/index.js @@ -30,11 +30,6 @@ site.init = function(){ console.log('plop listening at http://5.k:%s', server.address().port) }) - app.get("/p/get/random", function(req, res){ - db.getRandom().then(function(img){ - res.json(img) - }) - }) app.get("/p/list/", function(req, res){ limit = parseInt(req.params.limit) if (isNaN(limit)) limit = 20 @@ -45,6 +40,16 @@ site.init = function(){ res.json(img) }) }) + app.get("/p/get/random", function(req, res){ + db.getRandom().then(function(img){ + res.json(img) + }) + }) + app.get("/p/get/randomascii", function(req, res){ + db.getRandomAscii().then(function(img){ + res.json(img) + }) + }) app.get("/p/get/", function(req, res){ db.getLatest().then(function(img){ res.json(img) @@ -78,12 +83,6 @@ site.init = function(){ }) }) - app.get("/p/get/randomascii", function(req, res){ - db.getRandomAscii().then(function(img){ - res.json(img) - }) - }) - /* shaderblaster / asciiblaster apis */ app.post("/cgi-bin/im/shader/upload", multer_upload.single('qqfile'), function(req, res){ var now = Math.floor(Date.now() / 1000) diff --git a/lib/upload.js b/lib/upload.js index 82ea9b5..385e626 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -37,8 +37,8 @@ module.exports.put = function (key, file, opt) { else if (file.size < 10) { err = "File too small" } - else if (file.size > 2097152) { // 2mb limit - err = "File too large. Uploads can be a maximum of 2 mb." + else if (file.size > 1024*1024*3) { // 3mb limit + err = "File too large. Uploads can be a maximum of 3 mb." } if (err) { |
