@ewb/mongoose-query-express 1.1.1 → 1.1.2

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/README.md CHANGED
@@ -1,24 +1,24 @@
1
- ## Mongoose Query Express
2
-
3
- ### Info
4
- Library to for Express to create simple reusable queries and logic for mongoose.\
5
- Never write the simple get, post, patch and delete function over and over again.\
6
-
7
- Used in combination with [mongoose-query](https://github.com/EmilsWebbod/mongoose-query) to create the model logic.\
8
-
9
- ### Usage
10
- ```
11
- import { QueryExpress, QueryModel, QueryOptions } from 'mongoose-query-express';
12
-
13
- const options = new QueryOptions({ .... });
14
- const userQueryModel = new QueryModel<User>(User, options);
15
- const userQuery = new QueryExpress('user', userQueryModel, {...});
16
-
17
- const user = express();
18
-
19
- user.param('id', userQuery.param);
20
- user.get('/', userQuery.get);
21
- user.post('/', userQuery.post);
22
- user.patch('/:id', userQuery.patch);
23
- user.delete('/:id', userQuery.delete); // Can also use userQuery.archive if archive option set.
24
- ```
1
+ ## Mongoose Query Express
2
+
3
+ ### Info
4
+ Library to for Express to create simple reusable queries and logic for mongoose.\
5
+ Never write the simple get, post, patch and delete function over and over again.\
6
+
7
+ Used in combination with [mongoose-query](https://github.com/EmilsWebbod/mongoose-query) to create the model logic.\
8
+
9
+ ### Usage
10
+ ```
11
+ import { QueryExpress, QueryModel, QueryOptions } from 'mongoose-query-express';
12
+
13
+ const options = new QueryOptions({ .... });
14
+ const userQueryModel = new QueryModel<User>(User, options);
15
+ const userQuery = new QueryExpress('user', userQueryModel, {...});
16
+
17
+ const user = express();
18
+
19
+ user.param('id', userQuery.param);
20
+ user.get('/', userQuery.get);
21
+ user.post('/', userQuery.post);
22
+ user.patch('/:id', userQuery.patch);
23
+ user.delete('/:id', userQuery.delete); // Can also use userQuery.archive if archive option set.
24
+ ```
@@ -51,7 +51,7 @@ export declare class QueryExpress<R extends Request, T extends mongoose.Document
51
51
  readonly options: IQueryExpressHandlerOptions<R, T>;
52
52
  constructor(param: keyof R, handler: QueryModel<T>, options?: IQueryExpressHandlerOptions<R, T>);
53
53
  post(req: R, res: Response, next: NextFunction): Promise<void>;
54
- findOne(req: R, _res: Response, next: NextFunction): Promise<void>;
54
+ findOne(req: R, res: Response, next: NextFunction): Promise<void>;
55
55
  search(req: R, res: Response, next: NextFunction): Promise<void | Response<any, Record<string, any>>>;
56
56
  searchNext(req: R, res: Response, next: NextFunction): Promise<void>;
57
57
  private _search;
@@ -46,7 +46,7 @@ export class QueryExpress {
46
46
  next(QueryError.catch(e));
47
47
  }
48
48
  }
49
- async findOne(req, _res, next) {
49
+ async findOne(req, res, next) {
50
50
  try {
51
51
  if (this.skipHandlerAction(req, 'findOne')) {
52
52
  req.ewb.queryOptions.skipHandlerAction = undefined;
@@ -375,7 +375,7 @@ export class QueryExpress {
375
375
  }
376
376
  validateReq(req) {
377
377
  if (!req[this.param]) {
378
- throw new QueryError(httpStatus.BAD_REQUEST, String(this.param), {
378
+ throw new QueryError(httpStatus.NOT_FOUND, String(this.param), {
379
379
  detail: 'Param is not valid',
380
380
  });
381
381
  }
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "@ewb/mongoose-query-express",
3
- "version": "1.1.1",
4
- "type": "module",
5
- "description": "Routes and controllers for express to handle mongoose queries",
6
- "main": "./lib/index.js",
7
- "types": "./lib/index.d.ts",
8
- "scripts": {
9
- "dev": "yarn build:watch",
10
- "build": "tsc",
11
- "build:watch": "tsc --watch --incremental",
12
- "lint": "tslint --project \"./tsconfig.json\"",
13
- "test": "vitest run",
14
- "test:ui": "vitest --ui",
15
- "postversion": "git push && git push --tags",
16
- "prepublish": "yarn test && yarn build",
17
- "preversion": "yarn build"
18
- },
19
- "dependencies": {
20
- "http-status": "^1.6.2"
21
- },
22
- "devDependencies": {
23
- "@ewb/mongoose-query": "*",
24
- "@types/express": "^4.17.17",
25
- "@vitest/ui": "^0.31.1",
26
- "express": "^4.18.2",
27
- "husky": "^8.0.3",
28
- "lint-staged": "^13.2.2",
29
- "mongoose": "^8.4.1",
30
- "prettier": "^2.8.8",
31
- "tslint": "^6.1.3",
32
- "typescript": "^5.4.5",
33
- "vitest": "^0.31.1"
34
- },
35
- "peerDependencies": {
36
- "@ewb/mongoose-query": "*"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/emilswebbod/mongoose-query-express.git"
41
- },
42
- "keywords": [
43
- "typescript",
44
- "npm",
45
- "translate"
46
- ],
47
- "author": "Emils Webbod",
48
- "license": "MIT",
49
- "bugs": {
50
- "url": "https://github.com/emilswebbod/mongoose-query-express/issues"
51
- },
52
- "homepage": "https://github.com/emilswebbod/mongoose-query-express#readme",
53
- "files": [
54
- "lib"
55
- ],
56
- "husky": {
57
- "hooks": {
58
- "pre-commit": "pretty-quick --staged"
59
- }
60
- },
61
- "resolutions": {},
62
- "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
63
- }
1
+ {
2
+ "name": "@ewb/mongoose-query-express",
3
+ "version": "1.1.2",
4
+ "type": "module",
5
+ "description": "Routes and controllers for express to handle mongoose queries",
6
+ "main": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "scripts": {
9
+ "dev": "yarn build:watch",
10
+ "build": "tsc",
11
+ "build:watch": "tsc --watch --incremental",
12
+ "lint": "tslint --project \"./tsconfig.json\"",
13
+ "test": "vitest run",
14
+ "test:ui": "vitest --ui",
15
+ "postversion": "git push && git push --tags",
16
+ "prepublish": "yarn test && yarn build",
17
+ "preversion": "yarn build"
18
+ },
19
+ "dependencies": {
20
+ "http-status": "^1.6.2"
21
+ },
22
+ "devDependencies": {
23
+ "@ewb/mongoose-query": "*",
24
+ "@types/express": "^4.17.17",
25
+ "@vitest/ui": "^0.31.1",
26
+ "express": "^4.18.2",
27
+ "husky": "^8.0.3",
28
+ "lint-staged": "^13.2.2",
29
+ "mongoose": "^8.4.1",
30
+ "prettier": "^2.8.8",
31
+ "tslint": "^6.1.3",
32
+ "typescript": "^5.4.5",
33
+ "vitest": "^0.31.1"
34
+ },
35
+ "peerDependencies": {
36
+ "@ewb/mongoose-query": "*"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/emilswebbod/mongoose-query-express.git"
41
+ },
42
+ "keywords": [
43
+ "typescript",
44
+ "npm",
45
+ "translate"
46
+ ],
47
+ "author": "Emils Webbod",
48
+ "license": "MIT",
49
+ "bugs": {
50
+ "url": "https://github.com/emilswebbod/mongoose-query-express/issues"
51
+ },
52
+ "homepage": "https://github.com/emilswebbod/mongoose-query-express#readme",
53
+ "files": [
54
+ "lib"
55
+ ],
56
+ "husky": {
57
+ "hooks": {
58
+ "pre-commit": "pretty-quick --staged"
59
+ }
60
+ },
61
+ "resolutions": {},
62
+ "packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
63
+ }