From c890511d77902008a2c4b34c5f50896f606de962 Mon Sep 17 00:00:00 2001 From: srgooglo Date: Mon, 10 Jan 2022 11:59:02 +0100 Subject: [PATCH] remove example --- example/controllers/filecontroller/index.js | 48 --------------------- example/endpoints.json | 14 ------ example/package.json | 10 ----- 3 files changed, 72 deletions(-) delete mode 100755 example/controllers/filecontroller/index.js delete mode 100755 example/endpoints.json delete mode 100755 example/package.json diff --git a/example/controllers/filecontroller/index.js b/example/controllers/filecontroller/index.js deleted file mode 100755 index 5ba97da..0000000 --- a/example/controllers/filecontroller/index.js +++ /dev/null @@ -1,48 +0,0 @@ -const { Storage } = require('@ragestudio/cloudlink/dist/classes') -const path = require('path') -const { performance } = require('perf_hooks') - -// TODO: Access token, permission object type - -const handler = new Storage({ driver: "fs", root: path.resolve(process.cwd(), "uploads") }) - -module.exports = { - set: (req, res, next) => { - const { files } = req - if (typeof files.file !== "undefined") { - let file = files.file - - file.name = `${file.md5}_${file.name}` - - const timeBefore = performance.now() - handler.setSync(file, undefined) - .then((stat) => { - const tooks = (performance.now() - timeBefore).toFixed(2) - return res.json({ - tooks: `~${tooks}ms`, - filename: file.name, - mimetype: file.mimetype, - encoding: file.encoding, - size: stat.size - }) - }) - } - }, - get: (req, res, next) => { - const { query } = req - if (typeof query.file === "undefined") { - res.status(404) - return res.json({ error: "Not provided filename" }) - } - - handler.getSync(query.file) - .then((data) => { - res.write(data.buffer, 'binary') - res.end(null, 'binary') - }) - .catch((error) => { - res.status(404) - res.json({ error: error.message }) - }) - } -} \ No newline at end of file diff --git a/example/endpoints.json b/example/endpoints.json deleted file mode 100755 index 283bd54..0000000 --- a/example/endpoints.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "method": "PUT", - "route": "/upload", - "controller": "filecontroller", - "fn": "set" - }, - { - "method": "GET", - "route": "/resources", - "controller": "filecontroller", - "fn": "get" - } -] \ No newline at end of file diff --git a/example/package.json b/example/package.json deleted file mode 100755 index 75ae857..0000000 --- a/example/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "uploadServer", - "version": "0.1.0", - "scripts": { - "start": "linebridge" - }, - "dependencies": { - "linebridge": "^0.7.0" - } -} \ No newline at end of file