# All files / server-old/src/modern validate.js

100% Statements 15/15
100% Branches 12/12
100% Functions 2/2
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    2627x

    27x
    1464x
    2x

    1462x
    4x

    1458x
    1x

    27x
    1457x
    1x

    1456x
    2x

    1454x
    1x

     const ModernError = require('./errors');

    exports.middleware = middle => {
      if (!middle) {
        throw new ModernError('missingmiddleware');
      }
      if (!(middle instanceof Function)) {
        throw new ModernError('invalidmiddleware', { type: typeof middle });
      }
      if (middle.length === 4) {
        throw new ModernError('errormiddleware');
      }
    };

    exports.context = ctx => {
      if (!ctx) {
        throw new ModernError('missingcontext');
      }
      if (!ctx.req) {
        throw new ModernError('malformedcontext', { item: 'res' });
      }
      if (!ctx.res) {
        throw new ModernError('malformedcontext', { item: 'res' });
      }
    };