express-ext 0.5.15 → 0.5.17

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/lib/resources.js CHANGED
@@ -16,15 +16,24 @@ var resources = (function () {
16
16
  resources.sort = "sort"
17
17
  resources.fields = "fields"
18
18
  resources.partial = "partial"
19
+ resources.subPartial = "sub"
19
20
  resources.encoding = "utf-8"
20
21
  return resources
21
22
  })()
22
23
  exports.resources = resources
23
24
  function getView(req, view) {
24
25
  var partial = req.query[resources.partial]
25
- return partial == "true" ? resources.pages + "/" + view : view
26
+ return partial === "true" ? resources.pages + "/" + view : view
26
27
  }
27
28
  exports.getView = getView
29
+ function isPartial(req) {
30
+ return req.query[resources.partial] === "true"
31
+ }
32
+ exports.isPartial = isPartial
33
+ function isSubPartial(req) {
34
+ return req.query[resources.subPartial] === "true"
35
+ }
36
+ exports.isSubPartial = isSubPartial
28
37
  var TypeChecker = (function () {
29
38
  function TypeChecker(attributes, allowUndefined) {
30
39
  this.attributes = attributes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.5.15",
3
+ "version": "0.5.17",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/resources.ts CHANGED
@@ -20,22 +20,31 @@ export class resources {
20
20
  static sort = "sort"
21
21
  static fields = "fields"
22
22
  static partial = "partial"
23
+ static subPartial = "sub"
23
24
  static createValidator?: <T>(attributes: Attributes, allowUndefined?: boolean, max?: number) => Validator<T>
24
25
  static check: (obj: any, attributes: Attributes, allowUndefined?: boolean, patch?: boolean) => ErrorMessage[]
25
26
  static encoding?: BufferEncoding = "utf-8"
26
27
  }
27
28
  export function getView(req: Request, view: string): string {
28
29
  const partial = req.query[resources.partial]
29
- return partial == "true" ? resources.pages + "/" + view : view
30
+ return partial === "true" ? resources.pages + "/" + view : view
31
+ }
32
+ export function isPartial(req: Request): boolean {
33
+ return req.query[resources.partial] === "true"
34
+ }
35
+ export function isSubPartial(req: Request): boolean {
36
+ return req.query[resources.subPartial] === "true"
30
37
  }
31
-
32
38
  export interface Validator<T> {
33
39
  validate(obj: T, resource?: StringMap, patch?: boolean): Promise<ErrorMessage[]>
34
40
  }
35
41
 
36
42
  // tslint:disable-next-line:max-classes-per-file
37
43
  export class TypeChecker {
38
- constructor(public attributes: Attributes, public allowUndefined?: boolean) {
44
+ constructor(
45
+ public attributes: Attributes,
46
+ public allowUndefined?: boolean,
47
+ ) {
39
48
  this.check = this.check.bind(this)
40
49
  }
41
50
  check(req: Request, res: Response, next: NextFunction): void {