speedly 1.1.2 → 1.1.4
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/dist/cjs/auth/auth.d.ts +18 -1
- package/dist/cjs/auth/auth.js +1 -1
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +11 -41
- package/dist/cjs/uploader/uploader.d.ts +16 -1
- package/dist/cjs/uploader/uploader.js +3 -3
- package/dist/cjs/validator/validator.d.ts +2 -2
- package/dist/cjs/validator/validator.js +1 -2
- package/dist/esm/auth/auth.d.ts +18 -1
- package/dist/esm/auth/auth.js +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +11 -41
- package/dist/esm/uploader/uploader.d.ts +16 -1
- package/dist/esm/uploader/uploader.js +3 -3
- package/dist/esm/validator/validator.d.ts +2 -2
- package/dist/esm/validator/validator.js +1 -2
- package/package.json +1 -1
package/dist/cjs/auth/auth.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
type Handler = (req: Request, res: Response, next: (errorMessage?: string) => unknown) => unknown;
|
|
3
|
+
declare const auth: (config?: {
|
|
4
|
+
admin: {
|
|
5
|
+
role: string;
|
|
6
|
+
model: string;
|
|
7
|
+
};
|
|
8
|
+
jwtSecretEnv: string;
|
|
9
|
+
customValidator: (req: Request, key: string) => boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
(req: Request, res: Response, next: NextFunction): Promise<unknown>;
|
|
12
|
+
admin(...handlers: [{
|
|
13
|
+
permission: string;
|
|
14
|
+
}, ...Handler[]] | Handler[]): /*elided*/ any;
|
|
15
|
+
user(...handlers: Handler[]): /*elided*/ any;
|
|
16
|
+
any(...handlers: Handler[]): /*elided*/ any;
|
|
17
|
+
};
|
|
18
|
+
export default auth;
|
package/dist/cjs/auth/auth.js
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import auth from './auth/auth';
|
|
2
|
+
import db from './db/db';
|
|
3
|
+
import uploader from './uploader/uploader';
|
|
4
|
+
import validator from './validator/validator';
|
|
5
5
|
export { auth, db, uploader, validator };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.validator = exports.uploader = exports.db = exports.auth = void 0;
|
|
37
|
-
const
|
|
38
|
-
exports.auth =
|
|
39
|
-
const
|
|
40
|
-
exports.db =
|
|
41
|
-
const
|
|
42
|
-
exports.uploader =
|
|
43
|
-
const
|
|
44
|
-
exports.validator =
|
|
7
|
+
const auth_1 = __importDefault(require("./auth/auth"));
|
|
8
|
+
exports.auth = auth_1.default;
|
|
9
|
+
const db_1 = __importDefault(require("./db/db"));
|
|
10
|
+
exports.db = db_1.default;
|
|
11
|
+
const uploader_1 = __importDefault(require("./uploader/uploader"));
|
|
12
|
+
exports.uploader = uploader_1.default;
|
|
13
|
+
const validator_1 = __importDefault(require("./validator/validator"));
|
|
14
|
+
exports.validator = validator_1.default;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import multer from 'multer';
|
|
2
|
+
import { NextFunction, Request, Response } from "express";
|
|
1
3
|
declare global {
|
|
2
4
|
namespace Express {
|
|
3
5
|
interface Request {
|
|
@@ -5,4 +7,17 @@ declare global {
|
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
declare const _default: (destination?: string | ((req: Request, file: Express.Multer.File) => string), config?: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
saveInDb: boolean;
|
|
13
|
+
prefix: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
format: RegExp;
|
|
16
|
+
}) => {
|
|
17
|
+
single: (fieldName: string) => (req: Request, res: Response, next: NextFunction) => void;
|
|
18
|
+
array: (fieldName: string, maxCount?: number) => (req: Request, res: Response, next: NextFunction) => void;
|
|
19
|
+
fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
|
|
20
|
+
any: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
21
|
+
none: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export default _default;
|
|
@@ -7,17 +7,17 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const multer_1 = __importDefault(require("multer"));
|
|
9
9
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
10
|
-
const
|
|
10
|
+
const getConfig_1 = __importDefault(require("../util/getConfig"));
|
|
11
11
|
const relativePath = '../../../public';
|
|
12
12
|
let configs = {
|
|
13
13
|
saveInDb: false,
|
|
14
14
|
prefix: "",
|
|
15
15
|
limit: 5,
|
|
16
16
|
format: /png|jpg|webp|jpeg/i,
|
|
17
|
-
...
|
|
17
|
+
...(0, getConfig_1.default)("uploader")
|
|
18
18
|
};
|
|
19
19
|
console.log('uploader', 15, configs);
|
|
20
|
-
|
|
20
|
+
exports.default = (destination = "/image", config = configs) => {
|
|
21
21
|
let dest;
|
|
22
22
|
try {
|
|
23
23
|
Object.entries(config).forEach(([key, val]) => {
|
|
@@ -5,5 +5,5 @@ type ValidationSchema = {
|
|
|
5
5
|
params?: yup.AnyObjectSchema;
|
|
6
6
|
query?: yup.AnyObjectSchema;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
export
|
|
8
|
+
declare const validator: <T extends ValidationSchema>(schemas: T) => RequestHandler;
|
|
9
|
+
export default validator;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validator = void 0;
|
|
4
3
|
// این تابع validator generic هست
|
|
5
4
|
const validator = (schemas) => async (req, res, next) => {
|
|
6
5
|
try {
|
|
@@ -29,4 +28,4 @@ const validator = (schemas) => async (req, res, next) => {
|
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
|
-
exports.
|
|
31
|
+
exports.default = validator;
|
package/dist/esm/auth/auth.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
type Handler = (req: Request, res: Response, next: (errorMessage?: string) => unknown) => unknown;
|
|
3
|
+
declare const auth: (config?: {
|
|
4
|
+
admin: {
|
|
5
|
+
role: string;
|
|
6
|
+
model: string;
|
|
7
|
+
};
|
|
8
|
+
jwtSecretEnv: string;
|
|
9
|
+
customValidator: (req: Request, key: string) => boolean;
|
|
10
|
+
}) => {
|
|
11
|
+
(req: Request, res: Response, next: NextFunction): Promise<unknown>;
|
|
12
|
+
admin(...handlers: [{
|
|
13
|
+
permission: string;
|
|
14
|
+
}, ...Handler[]] | Handler[]): /*elided*/ any;
|
|
15
|
+
user(...handlers: Handler[]): /*elided*/ any;
|
|
16
|
+
any(...handlers: Handler[]): /*elided*/ any;
|
|
17
|
+
};
|
|
18
|
+
export default auth;
|
package/dist/esm/auth/auth.js
CHANGED
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import auth from './auth/auth';
|
|
2
|
+
import db from './db/db';
|
|
3
|
+
import uploader from './uploader/uploader';
|
|
4
|
+
import validator from './validator/validator';
|
|
5
5
|
export { auth, db, uploader, validator };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
35
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
6
|
exports.validator = exports.uploader = exports.db = exports.auth = void 0;
|
|
37
|
-
const
|
|
38
|
-
exports.auth =
|
|
39
|
-
const
|
|
40
|
-
exports.db =
|
|
41
|
-
const
|
|
42
|
-
exports.uploader =
|
|
43
|
-
const
|
|
44
|
-
exports.validator =
|
|
7
|
+
const auth_1 = __importDefault(require("./auth/auth"));
|
|
8
|
+
exports.auth = auth_1.default;
|
|
9
|
+
const db_1 = __importDefault(require("./db/db"));
|
|
10
|
+
exports.db = db_1.default;
|
|
11
|
+
const uploader_1 = __importDefault(require("./uploader/uploader"));
|
|
12
|
+
exports.uploader = uploader_1.default;
|
|
13
|
+
const validator_1 = __importDefault(require("./validator/validator"));
|
|
14
|
+
exports.validator = validator_1.default;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import multer from 'multer';
|
|
2
|
+
import { NextFunction, Request, Response } from "express";
|
|
1
3
|
declare global {
|
|
2
4
|
namespace Express {
|
|
3
5
|
interface Request {
|
|
@@ -5,4 +7,17 @@ declare global {
|
|
|
5
7
|
}
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
declare const _default: (destination?: string | ((req: Request, file: Express.Multer.File) => string), config?: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
saveInDb: boolean;
|
|
13
|
+
prefix: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
format: RegExp;
|
|
16
|
+
}) => {
|
|
17
|
+
single: (fieldName: string) => (req: Request, res: Response, next: NextFunction) => void;
|
|
18
|
+
array: (fieldName: string, maxCount?: number) => (req: Request, res: Response, next: NextFunction) => void;
|
|
19
|
+
fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
|
|
20
|
+
any: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
21
|
+
none: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export default _default;
|
|
@@ -7,17 +7,17 @@ const path_1 = __importDefault(require("path"));
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const multer_1 = __importDefault(require("multer"));
|
|
9
9
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
10
|
-
const
|
|
10
|
+
const getConfig_1 = __importDefault(require("../util/getConfig"));
|
|
11
11
|
const relativePath = '../../../public';
|
|
12
12
|
let configs = {
|
|
13
13
|
saveInDb: false,
|
|
14
14
|
prefix: "",
|
|
15
15
|
limit: 5,
|
|
16
16
|
format: /png|jpg|webp|jpeg/i,
|
|
17
|
-
...
|
|
17
|
+
...(0, getConfig_1.default)("uploader")
|
|
18
18
|
};
|
|
19
19
|
console.log('uploader', 15, configs);
|
|
20
|
-
|
|
20
|
+
exports.default = (destination = "/image", config = configs) => {
|
|
21
21
|
let dest;
|
|
22
22
|
try {
|
|
23
23
|
Object.entries(config).forEach(([key, val]) => {
|
|
@@ -5,5 +5,5 @@ type ValidationSchema = {
|
|
|
5
5
|
params?: yup.AnyObjectSchema;
|
|
6
6
|
query?: yup.AnyObjectSchema;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
export
|
|
8
|
+
declare const validator: <T extends ValidationSchema>(schemas: T) => RequestHandler;
|
|
9
|
+
export default validator;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validator = void 0;
|
|
4
3
|
// این تابع validator generic هست
|
|
5
4
|
const validator = (schemas) => async (req, res, next) => {
|
|
6
5
|
try {
|
|
@@ -29,4 +28,4 @@ const validator = (schemas) => async (req, res, next) => {
|
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
|
-
exports.
|
|
31
|
+
exports.default = validator;
|