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

GEWIS / sudosos-backend / 19907308868

03 Dec 2025 08:09PM UTC coverage: 89.583% (-0.2%) from 89.768%
19907308868

Pull #640

github

web-flow
Merge f3786a980 into fffd001d3
Pull Request #640: feat: notification abstraction

1528 of 1814 branches covered (84.23%)

Branch coverage included in aggregate %.

334 of 366 new or added lines in 22 files covered. (91.26%)

22 existing lines in 5 files now uncovered.

8009 of 8832 relevant lines covered (90.68%)

1051.65 hits per line

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

37.5
/src/controller/test-controller.ts
1
/**
2
 *  SudoSOS back-end API service.
3
 *  Copyright (C) 2024  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
import { NotificationChannels } from '../entity/notifications/user-notification-preference';
2✔
35

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

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

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

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

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