@furystack/http-api
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -11,2 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@furystack/core"); | ||
exports.Authenticate = () => (constructor) => { | ||
@@ -27,2 +28,9 @@ return class extends constructor { | ||
serverResponse.end(); | ||
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/@Authenticate()", | ||
message: `A Visitor user has been tried to access to action '${incomingMessage.url}' without authentication.`, | ||
data: { | ||
url: incomingMessage.url, | ||
}, | ||
}); | ||
return; | ||
@@ -29,0 +37,0 @@ } |
@@ -11,2 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@furystack/core"); | ||
exports.Authorize = (...roles) => (constructor) => { | ||
@@ -25,2 +26,11 @@ return class extends constructor { | ||
serverResponse.end(); | ||
const currentUser = yield getContext().getCurrentUser(); | ||
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/@Authorize()", | ||
message: `User '${currentUser.Username}' has been tried to access to action '${incomingMessage.url}' without the required roles.`, | ||
data: { | ||
user: currentUser, | ||
roles, | ||
}, | ||
}); | ||
return; | ||
@@ -27,0 +37,0 @@ } |
@@ -7,5 +7,5 @@ /// <reference types="node" /> | ||
exec(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext): Promise<void>; | ||
returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, _getContext: () => IContext, error: any): Promise<void>; | ||
returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext, error: any): Promise<void>; | ||
segmentName: string; | ||
constructor(); | ||
} |
@@ -11,2 +11,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const core_1 = require("@furystack/core"); | ||
const RequestAction_1 = require("./RequestAction"); | ||
@@ -21,3 +22,3 @@ class ErrorAction extends RequestAction_1.RequestAction { | ||
} | ||
returnError(incomingMessage, serverResponse, _getContext, error) { | ||
returnError(incomingMessage, serverResponse, getContext, error) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -27,2 +28,9 @@ serverResponse.writeHead(500, "Server error", { "Content-Type": "application/json" }); | ||
serverResponse.end(); | ||
getContext().getInjector().GetInstance(core_1.LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/ErrorAction", | ||
message: `An action returned 500 from '${incomingMessage.url}'.`, | ||
data: { | ||
error, | ||
}, | ||
}); | ||
}); | ||
@@ -29,0 +37,0 @@ } |
{ | ||
"name": "@furystack/http-api", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "HTTP Api FuryStack package", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,2 @@ | ||
import { Constructable, IContext } from "@furystack/core"; | ||
import { Constructable, IContext, LoggerCollection } from "@furystack/core"; | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
@@ -18,2 +18,9 @@ import { IRequestAction } from "../Models/IRequestAction"; | ||
serverResponse.end(); | ||
getContext().getInjector().GetInstance(LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/@Authenticate()", | ||
message: `A Visitor user has been tried to access to action '${incomingMessage.url}' without authentication.`, | ||
data: { | ||
url: incomingMessage.url, | ||
}, | ||
}); | ||
return; | ||
@@ -20,0 +27,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Constructable, IContext, IRole } from "@furystack/core"; | ||
import { Constructable, IContext, IRole, LoggerCollection } from "@furystack/core"; | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
@@ -14,2 +14,11 @@ import { IRequestAction } from "../Models/IRequestAction"; | ||
serverResponse.end(); | ||
const currentUser = await getContext().getCurrentUser(); | ||
getContext().getInjector().GetInstance(LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/@Authorize()", | ||
message: `User '${currentUser.Username}' has been tried to access to action '${incomingMessage.url}' without the required roles.`, | ||
data: { | ||
user: currentUser, | ||
roles, | ||
}, | ||
}); | ||
return; | ||
@@ -16,0 +25,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { IContext } from "@furystack/core"; | ||
import { IContext, LoggerCollection } from "@furystack/core"; | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
@@ -10,3 +10,3 @@ import { Authorize } from "./ActionDecorators/Authorize"; | ||
} | ||
public async returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, _getContext: () => IContext, error: any): Promise<void> { | ||
public async returnError(incomingMessage: IncomingMessage, serverResponse: ServerResponse, getContext: () => IContext, error: any): Promise<void> { | ||
serverResponse.writeHead(500, "Server error", | ||
@@ -17,2 +17,9 @@ { "Content-Type": "application/json" }, | ||
serverResponse.end(); | ||
getContext().getInjector().GetInstance(LoggerCollection).Warning({ | ||
scope: "@furystack/http-api/ErrorAction", | ||
message: `An action returned 500 from '${incomingMessage.url}'.`, | ||
data: { | ||
error, | ||
}, | ||
}); | ||
} | ||
@@ -19,0 +26,0 @@ public segmentName: string = ""; |
import { IContext } from "@furystack/core"; | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
import { Authorize } from "./ActionDecorators/Authorize"; | ||
import { IRequestAction } from "./Models/IRequestAction"; | ||
@@ -5,0 +4,0 @@ import { RequestAction } from "./RequestAction"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124427
1773