All files / realm/blong-gateway/gateway/meterprobe.dev meterprobeRate.ts

100% Statements 30/30
100% Branches 2/2
100% Functions 1/1
100% Lines 30/30

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 26 27 28 29 30 311x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import {validation} from '@feasibleone/blong';
 
/**
 * Dev-only metered fixture route: `meterprobe.rate` — metered by the
 * 'Meter Probe Rate' bundle.
 *
 * The `bundle`/`creditCost` fields are threaded into the Fastify route config
 * by Gateway.ts, where the ApiGateway plugin reads them to meter the request.
 * The bundle is merged in-test with a low rate limit so the real HTTP test can
 * trigger a plugin-only 429 (rate).
 */
export default validation(
    async ({lib: {type}}) =>
        function meterprobeRate() {
            return {
                params: type.Object({
                    probe: type.Optional(type.String()),
                }),
                result: type.Object(
                    {
                        success: type.Boolean(),
                        probe: type.String(),
                    },
                    {additionalProperties: true},
                ),
                bundle: 'Meter Probe Rate',
                creditCost: 1,
            };
        },
);