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

silvermine / lambda-express / 9602089925

20 Jun 2024 05:51PM UTC coverage: 98.669% (-0.7%) from 99.398%
9602089925

Pull #90

github

onebytegone
refactor: switch to ALB types provided by @types/aws-lambda
Pull Request #90: build: bump @types/aws-lambda

207 of 212 branches covered (97.64%)

Branch coverage included in aggregate %.

4 of 6 new or added lines in 1 file covered. (66.67%)

460 of 464 relevant lines covered (99.14%)

1989.34 hits per line

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

100.0
/src/chains/ProcessorChain.ts
1
import _ from 'underscore';
4✔
2
import { ErrorHandlingRequestProcessor, NextCallback } from '../interfaces';
3
import { Request, Response } from '..';
4

5
export interface IProcessorChain {
6
   run(err: unknown, req: Request, resp: Response, done: NextCallback): void;
7
}
8

9
export interface IRequestMatchingProcessorChain extends IProcessorChain {
10
   matches(req: Request): boolean;
11
}
12

13
export default class ProcessorChain implements IProcessorChain {
4✔
14

15
   private readonly _subprocessors: ErrorHandlingRequestProcessor[];
16

17
   public constructor(subprocessors: ErrorHandlingRequestProcessor[]) {
18
      this._subprocessors = subprocessors;
980✔
19
   }
20

21
   public run(originalErr: unknown, req: Request, resp: Response, done: NextCallback): void {
22
      let subRequest: Request;
23

24
      try {
844✔
25
         subRequest = this._makeSubRequest(req);
844✔
26
      } catch(newErr) {
27
         return done(newErr);
16✔
28
      }
29

30
      const run = _.reduce(this._subprocessors.slice().reverse(), (next: NextCallback, rp: ErrorHandlingRequestProcessor): NextCallback => {
828✔
31
         return (err) => {
1,176✔
32
            if (err === 'route') {
1,172✔
33
               return done();
4✔
34
            }
35
            try {
1,168✔
36
               rp(err, subRequest, resp, next);
1,168✔
37
            } catch(newErr) {
38
               return next(newErr);
40✔
39
            }
40
         };
41
      }, done);
42

43
      run(originalErr);
828✔
44
   }
45

46
   /**
47
    * Extension point for subclasses to override aspects of the request like baseUrl and
48
    * params.
49
    */
50
   protected _makeSubRequest(req: Request): Request {
51
      return req;
196✔
52
   }
53

54
}
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