Skip to content

Commit

Permalink
Use privates
Browse files Browse the repository at this point in the history
  • Loading branch information
surol committed Sep 17, 2023
1 parent eb28fa1 commit d35fede
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
9 changes: 5 additions & 4 deletions src/http/request/form-decoding.capability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ class FormDecodingCapability<TInput extends HttpMeans, TBody>
extends RequestCapability<TInput, RequestBodyMeans<TBody>>
implements FormDecoding<TInput, TBody> {

constructor(
private readonly _transform: RequestValueTransformer<TInput, URLSearchParams, TBody>,
) {
readonly #transform: RequestValueTransformer<TInput, URLSearchParams, TBody>;

constructor(transform: RequestValueTransformer<TInput, URLSearchParams, TBody>) {
super();
this.#transform = transform;
}

for<TMeans extends TInput>(
Expand All @@ -79,7 +80,7 @@ class FormDecodingCapability<TInput extends HttpMeans, TBody>
return context.next(
handler,
requestExtension<TMeans, RequestBodyMeans<TBody>>({
requestBody: await this._transform(params, context as RequestContext<TInput>),
requestBody: await this.#transform(params, context as RequestContext<TInput>),
}),
);
};
Expand Down
7 changes: 5 additions & 2 deletions src/http/request/http-forwarding.capability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export interface HttpForwarding extends RequestCapability<HttpMeans> {
*/
class HttpForwardingCapability extends RequestCapability<HttpMeans> implements HttpForwarding {

constructor(private readonly _trust: HttpForwardTrust) {
readonly #trust: HttpForwardTrust;

constructor(trust: HttpForwardTrust) {
super();
this.#trust = trust;
}

for<TMeans extends HttpMeans>(handler: RequestHandler<TMeans & object>): RequestHandler<TMeans> {
return ({ request, next }) => {
const addresses = lazyValue(() => HttpAddressRep.by(request, this._trust));
const addresses = lazyValue(() => HttpAddressRep.by(request, this.#trust));

return next(
handler,
Expand Down
7 changes: 5 additions & 2 deletions src/http/request/json-parsing.capability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ class JsonParsingCapability<TInput extends HttpMeans, TBody>
extends RequestCapability<TInput, RequestBodyMeans<TBody>>
implements JsonParsing<TInput, TBody> {

constructor(private readonly _transform: RequestValueTransformer<TInput, any, TBody>) {
readonly #transform: RequestValueTransformer<TInput, any, TBody>;

constructor(transform: RequestValueTransformer<TInput, any, TBody>) {
super();
this.#transform = transform;
}

for<TMeans extends TInput>(
Expand All @@ -84,7 +87,7 @@ class JsonParsingCapability<TInput extends HttpMeans, TBody>
return next(
handler,
requestExtension<TMeans, RequestBodyMeans<TBody>>({
requestBody: await this._transform(json, context as RequestContext<TInput>),
requestBody: await this.#transform(json, context as RequestContext<TInput>),
}),
);
};
Expand Down
18 changes: 9 additions & 9 deletions src/testing/test-http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,35 @@ export class TestHttpServer {
* @returns A promise resolved to started server.
*/
static start(): Promise<TestHttpServer> {
return new TestHttpServer()._start();
return new TestHttpServer().#start();
}

/**
* @internal
*/
private _listener: RequestListener;
#listener: RequestListener;

/**
* @internal
*/
private _server!: Server;
#server!: Server;

private constructor() {
this._listener = noop;
this.#listener = noop;
}

/**
* HTTP server instance.
*/
get server(): Server {
return this._server;
return this.#server;
}

/**
* An address the service is bound to.
*/
get address(): AddressInfo {
return this._server.address() as AddressInfo;
return this.#server.address() as AddressInfo;
}

/**
Expand All @@ -63,7 +63,7 @@ export class TestHttpServer {
* @returns `this` instance.
*/
listenBy(listener: RequestListener): this {
this._listener = listener;
this.#listener = listener;

return this;
}
Expand Down Expand Up @@ -113,9 +113,9 @@ export class TestHttpServer {
/**
* @internal
*/
private _start(): Promise<TestHttpServer> {
#start(): Promise<TestHttpServer> {
return new Promise((resolve, reject) => {
const server = (this._server = createServer((request, response) => this._listener(request, response)));
const server = (this.#server = createServer((request, response) => this.#listener(request, response)));

server.on('error', reject);
server.on('listening', () => resolve(this));
Expand Down

0 comments on commit d35fede

Please sign in to comment.