All files / realm/blong-gateway/gateway/customer.dev customerGet.ts

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

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 281x 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';
 
/**
 * Demo metered route: `customer.get` — metered by the 'Customer API' 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.
 */
export default validation(
    async ({lib: {type}}) =>
        function customerGet() {
            return {
                params: type.Object({
                    customerId: type.Optional(type.String()),
                }),
                result: type.Object(
                    {
                        success: type.Boolean(),
                        customer: type.String(),
                    },
                    {additionalProperties: true},
                ),
                bundle: 'Customer API',
                creditCost: 1,
            };
        },
);