@@ -2,23 +2,23 @@ import type { NextFunction, Request, Response } from "express";
22import express from "express" ;
33import inject from "light-my-request" ;
44import morgan from "morgan" ;
5- import { http , HttpResponse } from "msw" ;
5+ import { HttpResponse , http } from "msw" ;
66import type { SetupServer , SetupServerApi } from "msw/node" ;
77import { setupServer } from "msw/node" ;
8- import type { Config } from "./config" ;
9- import { DEFAULT_API_HOSTNAME , DEFAULT_AUTH_HOSTNAME } from "./constants" ;
10- import { CommercetoolsError } from "./exceptions" ;
11- import { mapHeaderType } from "./helpers" ;
12- import { copyHeaders } from "./lib/proxy" ;
13- import { OAuth2Server } from "./oauth/server" ;
14- import { ProjectAPI } from "./projectAPI" ;
15- import type { RepositoryMap } from "./repositories" ;
16- import { createRepositories } from "./repositories" ;
17- import type { ProjectRepository } from "./repositories/project" ;
18- import { createServices } from "./services" ;
19- import { ProjectService } from "./services/project" ;
20- import type { AbstractStorage } from "./storage" ;
21- import { InMemoryStorage } from "./storage" ;
8+ import type { Config } from "./config.ts " ;
9+ import { DEFAULT_API_HOSTNAME , DEFAULT_AUTH_HOSTNAME } from "./constants.ts " ;
10+ import { CommercetoolsError } from "./exceptions.ts " ;
11+ import { mapHeaderType } from "./helpers.ts " ;
12+ import { copyHeaders } from "./lib/proxy.ts " ;
13+ import { OAuth2Server } from "./oauth/server.ts " ;
14+ import { ProjectAPI } from "./projectAPI.ts " ;
15+ import type { RepositoryMap } from "./repositories/index.ts " ;
16+ import { createRepositories } from "./repositories/index.ts " ;
17+ import type { ProjectRepository } from "./repositories/project.ts " ;
18+ import { createServices } from "./services/index.ts " ;
19+ import { ProjectService } from "./services/project.ts " ;
20+ import type { AbstractStorage } from "./storage/index.ts " ;
21+ import { InMemoryStorage } from "./storage/index.ts " ;
2222
2323export type CommercetoolsMockOptions = {
2424 validateCredentials : boolean ;
@@ -57,7 +57,7 @@ export class CommercetoolsMock {
5757
5858 private _repositories : RepositoryMap | null ;
5959
60- private _projectService ? : ProjectService ;
60+ private _projectService : ProjectService | undefined ;
6161
6262 constructor ( options : Partial < CommercetoolsMockOptions > = { } ) {
6363 this . options = { ...DEFAULT_OPTIONS , ...options } ;
@@ -123,9 +123,7 @@ export class CommercetoolsMock {
123123 }
124124
125125 runServer ( port = 3000 , options ?: AppOptions ) {
126- const server = this . app . listen ( port , ( ) => {
127- console . info ( `Mock server listening at http://localhost:${ port } ` ) ;
128- } ) ;
126+ const server = this . app . listen ( port , ( ) => { } ) ;
129127 server . keepAliveTimeout = 60 * 1000 ;
130128 }
131129
@@ -186,7 +184,6 @@ export class CommercetoolsMock {
186184 } ) ;
187185 return ;
188186 }
189- console . error ( err ) ;
190187 resp . status ( 500 ) . send ( {
191188 error : err . message ,
192189 } ) ;
@@ -312,7 +309,10 @@ export class CommercetoolsMock {
312309 throw new Error ( "Server already started" ) ;
313310 }
314311 process . emitWarning ( "Server wasn't stopped properly, clearing" ) ;
315- _globalListeners . forEach ( ( listener ) => listener . close ( ) ) ;
312+ for ( const listener of _globalListeners ) {
313+ listener . close ( ) ;
314+ }
315+ _globalListeners . length = 0 ;
316316 }
317317
318318 const server = setupServer ( ) ;
0 commit comments