@thisisagile/easy-test
Version:
Straightforward library for testing microservices built with @thisisagile/easy
28 lines (20 loc) • 549 B
text/typescript
import { Id, Json, JsonValue, Text } from './Types';
export class Req {
constructor(readonly state: any = {}) {}
get id(): Id {
return this.state.id ?? this.path.id;
}
get q(): JsonValue {
return this.state.q ?? this.query.q;
}
get path(): Json {
return this.state?.path ?? {};
}
get query(): Json {
return this.state?.query ?? {};
}
get body(): unknown {
return this.state.body;
}
get = (key: Text): any => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];
}