speedly 1.1.3 → 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.
@@ -1 +1,18 @@
1
- export {};
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;
@@ -83,4 +83,4 @@ const auth = (config = gConfig) => {
83
83
  };
84
84
  return useAuth;
85
85
  };
86
- module.exports = auth;
86
+ exports.default = auth;
@@ -1,5 +1,5 @@
1
- import * as auth from './auth/auth';
2
- import * as db from './db/db';
3
- import * as uploader from './uploader/uploader';
4
- import * as validator from './validator/validator';
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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 auth = __importStar(require("./auth/auth"));
38
- exports.auth = auth;
39
- const db = __importStar(require("./db/db"));
40
- exports.db = db;
41
- const uploader = __importStar(require("./uploader/uploader"));
42
- exports.uploader = uploader;
43
- const validator = __importStar(require("./validator/validator"));
44
- exports.validator = 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
- export {};
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;
@@ -17,7 +17,7 @@ let configs = {
17
17
  ...(0, getConfig_1.default)("uploader")
18
18
  };
19
19
  console.log('uploader', 15, configs);
20
- module.exports = (destination = "/image", config = configs) => {
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
- export declare const validator: <T extends ValidationSchema>(schemas: T) => RequestHandler;
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.validator = validator;
31
+ exports.default = validator;
@@ -1 +1,18 @@
1
- export {};
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;
@@ -83,4 +83,4 @@ const auth = (config = gConfig) => {
83
83
  };
84
84
  return useAuth;
85
85
  };
86
- module.exports = auth;
86
+ exports.default = auth;
@@ -1,5 +1,5 @@
1
- import * as auth from './auth/auth';
2
- import * as db from './db/db';
3
- import * as uploader from './uploader/uploader';
4
- import * as validator from './validator/validator';
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
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 auth = __importStar(require("./auth/auth"));
38
- exports.auth = auth;
39
- const db = __importStar(require("./db/db"));
40
- exports.db = db;
41
- const uploader = __importStar(require("./uploader/uploader"));
42
- exports.uploader = uploader;
43
- const validator = __importStar(require("./validator/validator"));
44
- exports.validator = 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
- export {};
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;
@@ -17,7 +17,7 @@ let configs = {
17
17
  ...(0, getConfig_1.default)("uploader")
18
18
  };
19
19
  console.log('uploader', 15, configs);
20
- module.exports = (destination = "/image", config = configs) => {
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
- export declare const validator: <T extends ValidationSchema>(schemas: T) => RequestHandler;
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.validator = validator;
31
+ exports.default = validator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",