Skip to content

Commit 46b3f46

Browse files
authored
Merge pull request #33 from rogelio-o/develop
Develop
2 parents 137133c + 8145663 commit 46b3f46

7 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/lib/App.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ export default class App implements IApp {
146146
}
147147

148148
private getProjectBasePath(): string {
149-
console.log(process.env.PWD);
150149
if (!process.env.PWD) {
151-
console.log(process.cwd());
152150
return process.cwd();
153151
} else {
154152
return process.env.PWD;

src/lib/http/HttpRequest.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ export default class HttpRequest implements IHttpRequest {
2424
public params: { [name: string]: string };
2525
public route: IHttpRoute;
2626

27+
private _app: IApp;
2728
private _event: IRawEvent;
2829
private _headers: { [name: string]: string };
2930
private _context: { [name: string]: any };
3031
private _cookies: { [name: string]: ICookie };
3132

3233
constructor(app: IApp, event: IRawEvent) {
3334
this.body = event.body; // Default body
35+
this._app = app;
3436
this._event = event;
3537
this._context = {};
3638
this.params = mergeParams(event);
@@ -45,6 +47,10 @@ export default class HttpRequest implements IHttpRequest {
4547
this._cookies = getCookiesFromHeader(this._headers.cookie, app.get(configuration.COOKIE_SECRET));
4648
}
4749

50+
get app(): IApp {
51+
return this._app;
52+
}
53+
4854
get headers(): { [name: string]: string } {
4955
return this._headers;
5056
}

src/lib/http/HttpResponse.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export default class HttpResponse implements IHttpResponse {
4343
this._cookies = {};
4444
}
4545

46+
get app(): IApp {
47+
return this._app;
48+
}
49+
4650
get statusCode(): number {
4751
return this._statusCode;
4852
}

src/lib/types/http/IHttpRequest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import IApp from "./../IApp";
12
import INext from "./../INext";
23
import ICookie from "./ICookie";
34
import IHttpResponse from "./IHttpResponse";
@@ -9,6 +10,8 @@ import IHttpUploadedFile from "./IHttpUploadedFile";
910
*/
1011
export default interface IHttpRequest {
1112

13+
readonly app: IApp;
14+
1215
/**
1316
* Base path of the handling router.
1417
*/

src/lib/types/http/IHttpResponse.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import IHttpError from "./../exceptions/IHttpError";
2+
import IApp from "./../IApp";
23
import INext from "./../INext";
34
import IRouter from "./../IRouter";
45
import ICookie from "./ICookie";
@@ -9,6 +10,8 @@ import IHttpHandler from "./IHttpHandler";
910
*/
1011
export default interface IHttpResponse {
1112

13+
readonly app: IApp;
14+
1215
/**
1316
* The current router.
1417
*/

test/http/HttpRequest.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ describe("HttpRequest", () => {
2424
done();
2525
});
2626

27+
describe("#app", () => {
28+
it("should return the app that receives the incoming request.", () => {
29+
Chai.expect(request.app).to.be.equal(app);
30+
});
31+
});
32+
2733
it("should have empty header if the headers of the event is undefined.", () => {
2834
delete event.headers;
2935

test/http/HttpResponse.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ describe("HttpResponse", () => {
4040
done();
4141
});
4242

43+
describe("#app", () => {
44+
it("should return the app owner of the response.", () => {
45+
Chai.expect(response.app).to.be.equal(app);
46+
});
47+
});
48+
4349
it("#status should set the outcoming response status code", () => {
4450
response.status(302);
4551
response.send("");

0 commit comments

Comments
 (0)