@webex/test-helper-server 2.59.2 → 2.59.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -6
- package/README.md +31 -31
- package/babel.config.js +3 -3
- package/dist/cookies.js +2 -2
- package/dist/cookies.js.map +1 -1
- package/dist/files.js +2 -2
- package/dist/files.js.map +1 -1
- package/dist/form.js +2 -2
- package/dist/form.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/json.js +2 -2
- package/dist/json.js.map +1 -1
- package/dist/reflect.js +6 -6
- package/dist/reflect.js.map +1 -1
- package/jest.config.js +3 -3
- package/package.json +13 -12
- package/process +1 -1
- package/src/.eslintrc.yml +24 -24
- package/src/cookies.js +28 -28
- package/src/files.js +79 -79
- package/src/form.js +21 -21
- package/src/index.js +283 -283
- package/src/json.js +27 -27
- package/src/redirect.html +18 -18
- package/src/reflect.js +15 -15
- package/static/index.html +6 -6
- package/static/sample-text-one.txt +1 -1
- package/static/sample-text-two.txt +1 -1
package/src/files.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const bodyParser = require(`body-parser`);
|
|
6
|
-
const express = require(`express`);
|
|
7
|
-
const fs = require(`fs`);
|
|
8
|
-
const mkdirp = require(`mkdirp`);
|
|
9
|
-
const multer = require(`multer`);
|
|
10
|
-
const path = require(`path`);
|
|
11
|
-
const reflect = require(`./reflect`);
|
|
12
|
-
const uuid = require(`uuid`);
|
|
13
|
-
|
|
14
|
-
/* eslint new-cap: [0] */
|
|
15
|
-
const router = express.Router();
|
|
16
|
-
|
|
17
|
-
// Configure Image processing
|
|
18
|
-
// -------------------------
|
|
19
|
-
|
|
20
|
-
router.use(bodyParser.raw(`image/*`));
|
|
21
|
-
|
|
22
|
-
router.patch(`/reflect`, reflect);
|
|
23
|
-
router.post(`/reflect`, reflect);
|
|
24
|
-
router.put(`/reflect`, reflect);
|
|
25
|
-
|
|
26
|
-
const uploadPath = process.env.PACKAGE ? `.tmp/${process.env.PACKAGE}/files` : `.tmp/files`;
|
|
27
|
-
|
|
28
|
-
router.post(`/upload`, (req, res, next) => {
|
|
29
|
-
mkdirp(uploadPath, (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
return next(err);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const id = uuid.v4();
|
|
35
|
-
const storeAt = path.join(uploadPath, id);
|
|
36
|
-
const getFrom = `/files/download/${id}`;
|
|
37
|
-
|
|
38
|
-
/* eslint max-nested-callbacks: [0] */
|
|
39
|
-
return fs.writeFile(storeAt, req.body, (err2) => {
|
|
40
|
-
if (err2) {
|
|
41
|
-
return next(err2);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return res
|
|
45
|
-
.status(201)
|
|
46
|
-
.json({
|
|
47
|
-
loc: getFrom,
|
|
48
|
-
})
|
|
49
|
-
.end();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
router.get(`/download/:id`, (req, res, next) => {
|
|
55
|
-
if (!req.params.id) {
|
|
56
|
-
return next(new Error(`id param is required`));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return fs.readFile(path.join(uploadPath, req.params.id), (err, data) => {
|
|
60
|
-
if (err) {
|
|
61
|
-
return next(err);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return res.status(200).send(data).end();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const storage = multer.memoryStorage();
|
|
69
|
-
const upload = multer({storage});
|
|
70
|
-
|
|
71
|
-
[`put`, `patch`, `post`].forEach((methodName) => {
|
|
72
|
-
router[methodName](`/metadata`, upload.array(`files`), (req, res) => {
|
|
73
|
-
res.status(200).json(req.files).end();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
router.use(`/get`, express.static(path.join(__dirname, `static`)));
|
|
78
|
-
|
|
79
|
-
module.exports = router;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const bodyParser = require(`body-parser`);
|
|
6
|
+
const express = require(`express`);
|
|
7
|
+
const fs = require(`fs`);
|
|
8
|
+
const mkdirp = require(`mkdirp`);
|
|
9
|
+
const multer = require(`multer`);
|
|
10
|
+
const path = require(`path`);
|
|
11
|
+
const reflect = require(`./reflect`);
|
|
12
|
+
const uuid = require(`uuid`);
|
|
13
|
+
|
|
14
|
+
/* eslint new-cap: [0] */
|
|
15
|
+
const router = express.Router();
|
|
16
|
+
|
|
17
|
+
// Configure Image processing
|
|
18
|
+
// -------------------------
|
|
19
|
+
|
|
20
|
+
router.use(bodyParser.raw(`image/*`));
|
|
21
|
+
|
|
22
|
+
router.patch(`/reflect`, reflect);
|
|
23
|
+
router.post(`/reflect`, reflect);
|
|
24
|
+
router.put(`/reflect`, reflect);
|
|
25
|
+
|
|
26
|
+
const uploadPath = process.env.PACKAGE ? `.tmp/${process.env.PACKAGE}/files` : `.tmp/files`;
|
|
27
|
+
|
|
28
|
+
router.post(`/upload`, (req, res, next) => {
|
|
29
|
+
mkdirp(uploadPath, (err) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
return next(err);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const id = uuid.v4();
|
|
35
|
+
const storeAt = path.join(uploadPath, id);
|
|
36
|
+
const getFrom = `/files/download/${id}`;
|
|
37
|
+
|
|
38
|
+
/* eslint max-nested-callbacks: [0] */
|
|
39
|
+
return fs.writeFile(storeAt, req.body, (err2) => {
|
|
40
|
+
if (err2) {
|
|
41
|
+
return next(err2);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return res
|
|
45
|
+
.status(201)
|
|
46
|
+
.json({
|
|
47
|
+
loc: getFrom,
|
|
48
|
+
})
|
|
49
|
+
.end();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
router.get(`/download/:id`, (req, res, next) => {
|
|
55
|
+
if (!req.params.id) {
|
|
56
|
+
return next(new Error(`id param is required`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return fs.readFile(path.join(uploadPath, req.params.id), (err, data) => {
|
|
60
|
+
if (err) {
|
|
61
|
+
return next(err);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return res.status(200).send(data).end();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const storage = multer.memoryStorage();
|
|
69
|
+
const upload = multer({storage});
|
|
70
|
+
|
|
71
|
+
[`put`, `patch`, `post`].forEach((methodName) => {
|
|
72
|
+
router[methodName](`/metadata`, upload.array(`files`), (req, res) => {
|
|
73
|
+
res.status(200).json(req.files).end();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
router.use(`/get`, express.static(path.join(__dirname, `static`)));
|
|
78
|
+
|
|
79
|
+
module.exports = router;
|
package/src/form.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const bodyParser = require(`body-parser`);
|
|
6
|
-
const express = require(`express`);
|
|
7
|
-
const reflect = require(`./reflect`);
|
|
8
|
-
|
|
9
|
-
/* eslint new-cap: [0] */
|
|
10
|
-
const router = express.Router();
|
|
11
|
-
|
|
12
|
-
// Configure Image processing
|
|
13
|
-
// -------------------------
|
|
14
|
-
|
|
15
|
-
router.use(bodyParser.urlencoded({extended: true}));
|
|
16
|
-
|
|
17
|
-
router.patch(`/reflect`, reflect);
|
|
18
|
-
router.put(`/reflect`, reflect);
|
|
19
|
-
router.post(`/reflect`, reflect);
|
|
20
|
-
|
|
21
|
-
module.exports = router;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const bodyParser = require(`body-parser`);
|
|
6
|
+
const express = require(`express`);
|
|
7
|
+
const reflect = require(`./reflect`);
|
|
8
|
+
|
|
9
|
+
/* eslint new-cap: [0] */
|
|
10
|
+
const router = express.Router();
|
|
11
|
+
|
|
12
|
+
// Configure Image processing
|
|
13
|
+
// -------------------------
|
|
14
|
+
|
|
15
|
+
router.use(bodyParser.urlencoded({extended: true}));
|
|
16
|
+
|
|
17
|
+
router.patch(`/reflect`, reflect);
|
|
18
|
+
router.put(`/reflect`, reflect);
|
|
19
|
+
router.post(`/reflect`, reflect);
|
|
20
|
+
|
|
21
|
+
module.exports = router;
|