• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bpatrik / pigallery2 / 17685697493

12 Sep 2025 08:48PM UTC coverage: 65.828% (+1.7%) from 64.102%
17685697493

push

github

web-flow
Merge pull request #1030 from bpatrik/db-projection

Implement projected (scoped/filtered) gallery. Fixes #1015

1305 of 2243 branches covered (58.18%)

Branch coverage included in aggregate %.

706 of 873 new or added lines in 54 files covered. (80.87%)

16 existing lines in 10 files now uncovered.

4794 of 7022 relevant lines covered (68.27%)

4355.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.18
/src/backend/model/extension/ExpressRouterWrapper.ts
1
import * as express from 'express';
2
import {NextFunction, Request, Response} from 'express';
3
import {UserDTO, UserRoles} from '../../../common/entities/UserDTO';
4
import {AuthenticationMWs} from '../../middlewares/user/AuthenticationMWs';
1✔
5
import {RenderingMWs} from '../../middlewares/RenderingMWs';
1✔
6
import {ParamsDictionary} from 'express-serve-static-core';
7
import {IExtensionRESTApi, IExtensionRESTRoute} from './IExtension';
8
import {ILogger} from '../../Logger';
9
import {ExtensionManager} from './ExtensionManager';
1✔
10
import {Utils} from '../../../common/Utils';
1✔
11

12

13
export class ExpressRouterWrapper implements IExtensionRESTApi {
1✔
14

15
  constructor(private readonly router: express.Router,
×
16
              private readonly name: string,
×
17
              private readonly extLogger: ILogger) {
×
18
  }
19

20
  get use() {
21
    return new ExpressRouteWrapper(this.router, this.name, 'use', this.extLogger);
×
22
  }
23

24
  get get() {
25
    return new ExpressRouteWrapper(this.router, this.name, 'get', this.extLogger);
×
26
  }
27

28
  get put() {
29
    return new ExpressRouteWrapper(this.router, this.name, 'put', this.extLogger);
×
30
  }
31

32
  get post() {
33
    return new ExpressRouteWrapper(this.router, this.name, 'post', this.extLogger);
×
34
  }
35

36
  get delete() {
37
    return new ExpressRouteWrapper(this.router, this.name, 'delete', this.extLogger);
×
38
  }
39

40
}
41

42
export class ExpressRouteWrapper implements IExtensionRESTRoute {
1✔
43

44
  constructor(private readonly router: express.Router,
×
45
              private readonly name: string,
×
46
              private readonly func: 'get' | 'use' | 'put' | 'post' | 'delete',
×
47
              private readonly extLogger: ILogger) {
×
48
  }
49

50
  private getAuthMWs(minRole: UserRoles) {
51
    return minRole ? [AuthenticationMWs.authenticate,
×
52
      AuthenticationMWs.authorise(minRole)] : [];
53
  }
54

55
  public jsonResponse(paths: string[], minRole: UserRoles, cb: (params?: ParamsDictionary, body?: any, user?: UserDTO) => Promise<unknown> | unknown) {
56
    const fullPaths = paths.map(p => (Utils.concatUrls('/' + this.name + '/' + p)));
×
57
    this.router[this.func](fullPaths,
×
58
      ...(this.getAuthMWs(minRole).concat([
59
        async (req: Request, res: Response, next: NextFunction) => {
NEW
60
          req.resultPipe = await cb(req.params, req.body, req.session.context.user);
×
61
          next();
×
62
        },
63
        RenderingMWs.renderResult
64
      ])));
65
    const p = ExtensionManager.EXTENSION_API_PATH + fullPaths;
×
66
    this.extLogger.silly(`Listening on ${this.func} ${p}`);
×
67
    return p;
×
68
  }
69

70
  public rawMiddleware(paths: string[], minRole: UserRoles, mw: (req: Request, res: Response, next: NextFunction) => void | Promise<void>) {
71
    const fullPaths = paths.map(p => (Utils.concatUrls('/' + this.name + '/' + p)));
×
72
    this.router[this.func](fullPaths,
×
73
      ...this.getAuthMWs(minRole),
74
      mw);
75
    const p = ExtensionManager.EXTENSION_API_PATH + fullPaths;
×
76
    this.extLogger.silly(`Listening on ${this.func} ${p}`);
×
77
    return p;
×
78
  }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc