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

GEWIS / sudosos-backend / 20690997091

04 Jan 2026 09:40AM UTC coverage: 89.701% (-0.1%) from 89.81%
20690997091

Pull #640

github

web-flow
Merge 3f181cd77 into b62eef7ad
Pull Request #640: feat: notification abstraction

1596 of 1909 branches covered (83.6%)

Branch coverage included in aggregate %.

334 of 364 new or added lines in 22 files covered. (91.76%)

16 existing lines in 4 files now uncovered.

8289 of 9111 relevant lines covered (90.98%)

1036.73 hits per line

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

33.33
/src/controller/test-controller.ts
1
/**
2
 *  SudoSOS back-end API service.
3
 *  Copyright (C) 2026 Study association GEWIS
4
 *
5
 *  This program is free software: you can redistribute it and/or modify
6
 *  it under the terms of the GNU Affero General Public License as published
7
 *  by the Free Software Foundation, either version 3 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU Affero General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Affero General Public License
16
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
 *
18
 *  @license
19
 */
20

21
/**
22
 * This is the module page of the test-controller.
23
 *
24
 * @module internal/controllers
25
 */
26

27
import { Response } from 'express';
28
import log4js, { Logger } from 'log4js';
2✔
29
import BaseController, { BaseControllerOptions } from './base-controller';
2✔
30
import Policy from './policy';
31
import { RequestWithToken } from '../middleware/token-middleware';
32
import Notifier, { HelloWorldOptions } from '../notifications';
2✔
33
import { NotificationTypes } from '../notifications/notification-types';
2✔
34

35
export default class TestController extends BaseController {
2✔
36
  /**
37
   * Reference to the logger instance.
38
   */
39
  private logger: Logger = log4js.getLogger('TestController');
×
40

41
  /**
42
   * Creates a new test controller instance.
43
   * @param options - The options passed to the base controller.
44
   */
45
  public constructor(options: BaseControllerOptions) {
46
    super(options);
×
47
    this.logger.level = process.env.LOG_LEVEL;
×
48
  }
49

50
  /**
51
   * @inheritDoc
52
   */
53
  public getPolicy(): Policy {
54
    return {
×
55
      '/helloworld': {
56
        POST: {
57
          policy: async () => Promise.resolve(true),
×
58
          handler: this.helloWorld.bind(this),
59
        },
60
      },
61
    };
62
  }
63

64
  /**
65
   * POST /test/helloworld
66
   * @summary Get a beautiful Hello World email to your inbox
67
   * @operationId helloworld
68
   * @tags test- Operations of the test controller
69
   * @security JWT
70
   * @return 204 - Success
71
   * @return {string} 500 - Internal server error
72
   */
73
  public async helloWorld(req: RequestWithToken, res: Response): Promise<void> {
74
    this.logger.trace('Hello world email by', req.token.user.id);
×
75

76
    try {
×
NEW
77
      await Notifier.getInstance().notify({
×
78
        type: NotificationTypes.HelloWorld,
79
        userId: req.token.user.id,
80
        params: new HelloWorldOptions(req.token.user.firstName),
81
      });
UNCOV
82
      res.status(204).send();
×
83
    } catch (e) {
84
      res.status(500).json('Internal server error.');
×
85
    }
86
  }
87
}
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