@duvdu-v1/duvdu 1.0.7 → 1.0.8

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,3 +1,4 @@
1
+ /// <reference types="qs" />
1
2
  /// <reference types="mongoose/types/aggregate" />
2
3
  /// <reference types="mongoose/types/callback" />
3
4
  /// <reference types="mongoose/types/collection" />
@@ -23,6 +24,6 @@
23
24
  /// <reference types="mongoose/types/virtuals" />
24
25
  /// <reference types="mongoose/types/inferschematype" />
25
26
  import 'express-async-errors';
26
- import { Response, NextFunction, Request } from 'express';
27
+ import { RequestHandler } from 'express';
27
28
  import { Model } from 'mongoose';
28
- export declare const auth: (modelName: Model<any>) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
29
+ export declare const auth: (modelName: Model<any>) => RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
@@ -17,9 +17,9 @@ require("express-async-errors");
17
17
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
18
18
  const bad_request_error_1 = require("../errors/bad-request-error");
19
19
  const unauthenticated_error_1 = require("../errors/unauthenticated-error");
20
- const auth = (modelName) => (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
20
+ const auth = (modelName) => ((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  var _a, _b;
22
- const user = yield modelName.find({ token: (_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt });
22
+ const user = yield modelName.findOne({ token: (_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt });
23
23
  if (!((_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt) && !user) {
24
24
  throw new unauthenticated_error_1.UnauthenticatedError();
25
25
  }
@@ -31,5 +31,5 @@ const auth = (modelName) => (req, res, next) => __awaiter(void 0, void 0, void 0
31
31
  catch (error) {
32
32
  throw new bad_request_error_1.BadRequestError('invalid or expired token');
33
33
  }
34
- });
34
+ }));
35
35
  exports.auth = auth;
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "@duvdu-v1/duvdu",
3
- "version": "1.0.7",
4
- "main": "./build/index.js",
5
- "types": "./build/index.d.ts",
6
- "files": [
7
- "build/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rimraf ./build",
11
- "build": "npm run clean && tsc",
12
- "pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
13
- "lint": "eslint .",
14
- "lint:fix": "eslint --fix .",
15
- "format": "prettier --write ."
16
- },
17
- "keywords": [],
18
- "author": "motemed khaled",
19
- "license": "ISC",
20
- "dependencies": {
21
- "@duvdu-v1/duvdu": "^1.0.5",
22
- "@types/express": "^4.17.21",
23
- "@types/jsonwebtoken": "^9.0.5",
24
- "@types/multer": "^1.4.11",
25
- "@types/node": "^20.11.0",
26
- "@typescript-eslint/eslint-plugin": "^6.19.0",
27
- "@typescript-eslint/parser": "^6.19.0",
28
- "express": "^4.18.2",
29
- "express-async-errors": "^3.1.1",
30
- "express-validator": "^7.0.1",
31
- "jsonwebtoken": "^9.0.2",
32
- "mongoose": "^8.0.4",
33
- "multer": "^1.4.5-lts.1",
34
- "node-nats-streaming": "^0.3.2",
35
- "rimraf": "^5.0.5",
36
- "typescript": "^5.3.3"
37
- },
38
- "devDependencies": {
39
- "del-cli": "^5.1.0",
40
- "eslint": "^8.56.0",
41
- "eslint-config-prettier": "^9.1.0",
42
- "eslint-plugin-import": "^2.29.1",
43
- "eslint-plugin-prettier": "^5.1.3",
44
- "prettier": "^3.2.4"
45
- },
46
- "description": ""
47
- }
1
+ {
2
+ "name": "@duvdu-v1/duvdu",
3
+ "version": "1.0.8",
4
+ "main": "./build/index.js",
5
+ "types": "./build/index.d.ts",
6
+ "files": [
7
+ "build/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rimraf ./build",
11
+ "build": "npm run clean && tsc",
12
+ "pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
13
+ "lint": "eslint .",
14
+ "lint:fix": "eslint --fix .",
15
+ "format": "prettier --write ."
16
+ },
17
+ "keywords": [],
18
+ "author": "motemed khaled",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "@duvdu-v1/duvdu": "^1.0.5",
22
+ "@types/express": "^4.17.21",
23
+ "@types/jsonwebtoken": "^9.0.5",
24
+ "@types/multer": "^1.4.11",
25
+ "@types/node": "^20.11.0",
26
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
27
+ "@typescript-eslint/parser": "^6.19.0",
28
+ "express": "^4.18.2",
29
+ "express-async-errors": "^3.1.1",
30
+ "express-validator": "^7.0.1",
31
+ "jsonwebtoken": "^9.0.2",
32
+ "mongoose": "^8.0.4",
33
+ "multer": "^1.4.5-lts.1",
34
+ "node-nats-streaming": "^0.3.2",
35
+ "rimraf": "^5.0.5",
36
+ "typescript": "^5.3.3"
37
+ },
38
+ "devDependencies": {
39
+ "del-cli": "^5.1.0",
40
+ "eslint": "^8.56.0",
41
+ "eslint-config-prettier": "^9.1.0",
42
+ "eslint-plugin-import": "^2.29.1",
43
+ "eslint-plugin-prettier": "^5.1.3",
44
+ "prettier": "^3.2.4"
45
+ },
46
+ "description": ""
47
+ }