All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.mocks.handlers.ts.ftl Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
/**
* Generated by unionj-generator.
*/
// @ts-nocheck
import { rest } from 'msw'

const baseUrl = '${baseUrl}'

export const handlers = [
<#list apis as api>
    rest.${api.method}(baseUrl + '${api.endpoint}', (req, res, ctx) => {
    <#if api.pathParams??>
        const {
        <#list api.pathParams as pathParam>
            ${pathParam},
        
        } = req.params
    
    <#if api.bodyParams??>
        const {
        <#list api.bodyParams as bodyParam>
            ${bodyParam},
        
        } = req.body
    
<#if api.queryParams??>
    <#list api.queryParams as queryParam>
        const ${queryParam} = req.url.searchParams.get('${queryParam}')
    

    <#if api.headerParams??>
        const {
        <#list api.headerParams as headerParam>
            ${headerParam},
        
        } = req.headers
    
        return res(
            ctx.status(200),
            ctx.set('Content-Type', 'application/json'),
        <#if api.responseStr??>
            ctx.body(${api.responseStr}),
        
        )
    }),


]




© 2015 - 2025 Weber Informatics LLC | Privacy Policy