speedly 1.2.21 → 1.2.23

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.
@@ -117,7 +117,7 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
117
117
  limit(value: number): /*elided*/ any;
118
118
  populate(value: string | object | (string | object)[]): /*elided*/ any;
119
119
  };
120
- aggregate: (pipeline?: never[]) => {
120
+ aggregate: (pipeline?: any[]) => {
121
121
  (req: Request, res: Response, next: NextFunction): Promise<void>;
122
122
  select(value: string | {
123
123
  [key: string]: -1 | 1;
@@ -177,5 +177,5 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
177
177
  limit(value: number): /*elided*/ any;
178
178
  populate(value: string | object | (string | object)[]): /*elided*/ any;
179
179
  };
180
- } | undefined;
180
+ };
181
181
  export default db;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const express_1 = __importDefault(require("express"));
7
+ const auth_1 = __importDefault(require("../../auth/auth"));
8
+ const db_1 = __importDefault(require("../../db/db"));
9
+ const validator_1 = __importDefault(require("../../validator/validator"));
10
+ const v = require('./translation.validator');
11
+ const router = express_1.default.Router();
12
+ router.route('/').get((0, db_1.default)('translation').find())
13
+ .post((req, res, next) => {
14
+ if (!req.body.auth || req.body.auth !== 'OKPJWSJD_Sdki') {
15
+ return res.status(403).json({ message: "Access Denied" });
16
+ }
17
+ next();
18
+ }, (0, db_1.default)('translation').create());
19
+ router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation').findByIdAndUpdate());
20
+ module.exports = router;
@@ -0,0 +1,3 @@
1
+ declare const string: any, object: any, array: any, lazy: any;
2
+ declare const paramId: any;
3
+ declare const schema: any;
@@ -0,0 +1,14 @@
1
+ // const makeOptional = require("../../util/makeOptional");
2
+ // import makeOptional from '../../util/'
3
+ const { string, object, array, lazy } = require("../../yup.config");
4
+ const paramId = object({
5
+ id: string().required('id is required').oid('id is invalid')
6
+ });
7
+ const schema = object({
8
+ translatedText: string().required('translatedText is required'),
9
+ });
10
+ //? exports
11
+ exports.put = {
12
+ params: paramId,
13
+ // body : makeOptional(schema)
14
+ };
@@ -13,11 +13,12 @@ declare const _default: (destination?: string | ((req: Request, file: Express.Mu
13
13
  prefix: string;
14
14
  limit: number;
15
15
  format: RegExp;
16
+ path: string;
16
17
  }) => {
17
18
  single: (fieldName: string) => (req: Request, res: Response, next: NextFunction) => void;
18
19
  array: (fieldName: string, maxCount?: number) => (req: Request, res: Response, next: NextFunction) => void;
19
20
  fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
20
21
  any: () => (req: Request, res: Response, next: NextFunction) => void;
21
22
  none: () => (req: Request, res: Response, next: NextFunction) => void;
22
- } | undefined;
23
+ };
23
24
  export default _default;
@@ -8,12 +8,12 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const multer_1 = __importDefault(require("multer"));
9
9
  const mongoose_1 = __importDefault(require("mongoose"));
10
10
  const getConfig_1 = __importDefault(require("../util/getConfig"));
11
- const relativePath = '../../../public';
12
11
  let configs = {
13
12
  saveInDb: false,
14
13
  prefix: "",
15
14
  limit: 5,
16
15
  format: /png|jpg|webp|jpeg/i,
16
+ path: '../../../public',
17
17
  ...(0, getConfig_1.default)("uploader")
18
18
  };
19
19
  console.log('uploader', 15, configs);
@@ -30,7 +30,7 @@ exports.default = (destination = "/image", config = configs) => {
30
30
  ? destination(req, file)
31
31
  : destination;
32
32
  const splitPath = dest.split("/");
33
- let currentPath = path_1.default.join(__dirname, relativePath);
33
+ let currentPath = path_1.default.join(require.main.filename || '', configs.path);
34
34
  splitPath.forEach(folder => {
35
35
  currentPath = path_1.default.join(currentPath, folder);
36
36
  console.log('uploader', 39, currentPath, !fs_1.default.existsSync(currentPath));
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(__dirname, relativePath, dest));
41
+ cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(__dirname, relativePath, dest, fileName);
56
+ const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(__dirname, relativePath), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(__dirname, relativePath), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
@@ -117,7 +117,7 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
117
117
  limit(value: number): /*elided*/ any;
118
118
  populate(value: string | object | (string | object)[]): /*elided*/ any;
119
119
  };
120
- aggregate: (pipeline?: never[]) => {
120
+ aggregate: (pipeline?: any[]) => {
121
121
  (req: Request, res: Response, next: NextFunction): Promise<void>;
122
122
  select(value: string | {
123
123
  [key: string]: -1 | 1;
@@ -177,5 +177,5 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
177
177
  limit(value: number): /*elided*/ any;
178
178
  populate(value: string | object | (string | object)[]): /*elided*/ any;
179
179
  };
180
- } | undefined;
180
+ };
181
181
  export default db;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const express_1 = __importDefault(require("express"));
7
+ const auth_1 = __importDefault(require("../../auth/auth"));
8
+ const db_1 = __importDefault(require("../../db/db"));
9
+ const validator_1 = __importDefault(require("../../validator/validator"));
10
+ const v = require('./translation.validator');
11
+ const router = express_1.default.Router();
12
+ router.route('/').get((0, db_1.default)('translation').find())
13
+ .post((req, res, next) => {
14
+ if (!req.body.auth || req.body.auth !== 'OKPJWSJD_Sdki') {
15
+ return res.status(403).json({ message: "Access Denied" });
16
+ }
17
+ next();
18
+ }, (0, db_1.default)('translation').create());
19
+ router.route('/:id').put(auth_1.default.admin(), (0, validator_1.default)(v.put), (0, db_1.default)('translation').findByIdAndUpdate());
20
+ module.exports = router;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // const makeOptional = require("../../util/makeOptional");
4
+ // import makeOptional from '../../util/'
5
+ const { string, object, array, lazy } = require("../../yup.config");
6
+ const paramId = object({
7
+ id: string().required('id is required').oid('id is invalid')
8
+ });
9
+ const schema = object({
10
+ translatedText: string().required('translatedText is required'),
11
+ });
12
+ //? exports
13
+ exports.put = {
14
+ params: paramId,
15
+ // body : makeOptional(schema)
16
+ };
@@ -13,11 +13,12 @@ declare const _default: (destination?: string | ((req: Request, file: Express.Mu
13
13
  prefix: string;
14
14
  limit: number;
15
15
  format: RegExp;
16
+ path: string;
16
17
  }) => {
17
18
  single: (fieldName: string) => (req: Request, res: Response, next: NextFunction) => void;
18
19
  array: (fieldName: string, maxCount?: number) => (req: Request, res: Response, next: NextFunction) => void;
19
20
  fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
20
21
  any: () => (req: Request, res: Response, next: NextFunction) => void;
21
22
  none: () => (req: Request, res: Response, next: NextFunction) => void;
22
- } | undefined;
23
+ };
23
24
  export default _default;
@@ -8,12 +8,12 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const multer_1 = __importDefault(require("multer"));
9
9
  const mongoose_1 = __importDefault(require("mongoose"));
10
10
  const getConfig_1 = __importDefault(require("../util/getConfig"));
11
- const relativePath = '../../../public';
12
11
  let configs = {
13
12
  saveInDb: false,
14
13
  prefix: "",
15
14
  limit: 5,
16
15
  format: /png|jpg|webp|jpeg/i,
16
+ path: '../../../public',
17
17
  ...(0, getConfig_1.default)("uploader")
18
18
  };
19
19
  console.log('uploader', 15, configs);
@@ -30,7 +30,7 @@ exports.default = (destination = "/image", config = configs) => {
30
30
  ? destination(req, file)
31
31
  : destination;
32
32
  const splitPath = dest.split("/");
33
- let currentPath = path_1.default.join(__dirname, relativePath);
33
+ let currentPath = path_1.default.join(require.main.filename || '', configs.path);
34
34
  splitPath.forEach(folder => {
35
35
  currentPath = path_1.default.join(currentPath, folder);
36
36
  console.log('uploader', 39, currentPath, !fs_1.default.existsSync(currentPath));
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(__dirname, relativePath, dest));
41
+ cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(__dirname, relativePath, dest, fileName);
56
+ const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(__dirname, relativePath), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(__dirname, relativePath), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",