/** * @fileoverview * This file is a part of an "auth" example router, which was taken from an existing integration. * It is to be used only as a reference for how an API router for a web service should be structured. * In a real-live implementation all files related to `/auth` route example should be removed * by new set of files implementing the new API. */ import { Request, Response, NextFunction } from 'express'; import { AppLocals } from "../../src/types/AppLocals"; interface IMockHttpParams { sessionID?: number sessionGUID?: string table_id?: string clientIp?: string free_play: 0 | 1 } interface IMockHttpContext { clientIpAddress?:string reqPath?:string headersSent?:boolean writableEnded?:boolean method?:string params?: IMockHttpParams } export const defaultMockParams:IMockHttpParams = { sessionID: 123, sessionGUID: '016e6812-b915-4e5e-94fe-193582239b96', table_id: 'mock-table-id', clientIp: '192.168.1.10', free_play: 0 } export const mockHttpContext = ({reqPath="/", headersSent=false, writableEnded=false, method="GET", params=defaultMockParams}:IMockHttpContext|undefined = {}) => { const req = { path:reqPath, method, url:`https://localhost${reqPath}`, params, } as unknown as Request; const res = { end: jest.fn(), status: jest.fn(), setHeader: jest.fn(), params, locals: { stopPrometheusTimer: jest.fn(), } as unknown as AppLocals, headersSent, writableEnded, } as unknown as Response; const next:NextFunction = jest.fn(); return({req,res,next}) }