@@ -7,12 +7,49 @@ import { withFiles } from './helpers/files';
77import { withMiddlewares } from './helpers/middlewares' ;
88import { runWith , configureHandler } from './helpers/fluent' ;
99import { currentDir } from './core/info' ;
10- import { KrasConfiguration , KrasServer , LogEntry , LogEntryType , LogLevel , KrasInjector , KrasServerMethods , KrasServerHandler , KrasHandlerConfiguration , KrasRunner , KrasMiddleware } from './types' ;
11- import { buildConfiguration , mergeConfiguration , readConfiguration , ConfigurationOptions } from './core/config' ;
12- export { KrasRequestHandler , KrasInjectorOptions , KrasInjectorOption , KrasInjectorConfig , KrasRequest , KrasResponse , KrasAnswer } from './types' ;
13- export { KrasInjector , KrasConfiguration , KrasServerMethods , KrasServerHandler , KrasHandlerConfiguration , KrasRunner } ;
10+ import {
11+ KrasConfiguration ,
12+ KrasServer ,
13+ LogEntry ,
14+ LogEntryType ,
15+ LogLevel ,
16+ KrasInjector ,
17+ KrasServerMethods ,
18+ KrasServerHandler ,
19+ KrasHandlerConfiguration ,
20+ KrasRunner ,
21+ KrasMiddleware
22+ } from './types' ;
23+ import {
24+ buildConfiguration ,
25+ mergeConfiguration ,
26+ readConfiguration ,
27+ ConfigurationOptions
28+ } from './core/config' ;
29+ export {
30+ KrasRequestHandler ,
31+ KrasInjectorOptions ,
32+ KrasInjectorOption ,
33+ KrasInjectorConfig ,
34+ KrasRequest ,
35+ KrasResponse ,
36+ KrasAnswer ,
37+ Dict ,
38+ Headers ,
39+ ScriptResponseBuilder ,
40+ ScriptResponseBuilderData
41+ } from './types' ;
42+ export {
43+ KrasInjector ,
44+ KrasConfiguration ,
45+ KrasServerMethods ,
46+ KrasServerHandler ,
47+ KrasHandlerConfiguration ,
48+ KrasRunner
49+ } ;
1450
15- export type KrasRuntimeConfiguration = Partial < KrasConfiguration > & KrasHandlerConfiguration ;
51+ export type KrasRuntimeConfiguration = Partial < KrasConfiguration > &
52+ KrasHandlerConfiguration ;
1653
1754export const krasrc = '.krasrc' ;
1855
@@ -32,7 +69,11 @@ export class MockServer extends MockServerCore implements KrasServer {
3269 super ( config ) ;
3370
3471 this . logLevel = config . logLevel || 'error' ;
35- this . on ( 'error' , ( e ) => this . log ( 'error' , e ) ) ;
72+ this . on ( 'error' , e => this . log ( 'error' , e ) ) ;
73+
74+ if ( config . api === false ) {
75+ this . recorder . disable ( ) ;
76+ }
3677
3778 withManagement ( this , config ) ;
3879 withInjectors ( this , config ) ;
@@ -41,15 +82,14 @@ export class MockServer extends MockServerCore implements KrasServer {
4182 }
4283
4384 stop ( ) {
44- return super . stop ( )
45- . then ( ( ) => this . injectors . forEach ( disposeInjector ) ) ;
85+ return super . stop ( ) . then ( ( ) => this . injectors . forEach ( disposeInjector ) ) ;
4686 }
4787
4888 private log ( type : LogEntryType , data : any ) {
4989 const item : LogEntry = {
5090 type,
5191 data,
52- time : new Date ( ) ,
92+ time : new Date ( )
5393 } ;
5494 this . logs . push ( item ) ;
5595 this . emit ( 'logged' , item ) ;
@@ -62,7 +102,7 @@ export function readKrasConfig(options?: ConfigurationOptions, file?: string) {
62102 options ,
63103 readConfiguration ( homedir ( ) , krasrc ) ,
64104 readConfiguration ( dir , krasrc ) ,
65- readConfiguration ( dir , file ) ,
105+ readConfiguration ( dir , file )
66106 ) ;
67107}
68108
0 commit comments