Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Commit 31edd5e

Browse files
committed
Refactor WebAuthnController and related services for improved logging and error handling
- Reorganized imports in WebAuthnController for clarity. - Enhanced logging functionality in createLog method. - Updated registration and authentication options handling. - Improved error handling in registration and authentication processes. - Refactored webauthnService for better structure and readability. - Cleaned up middleware imports for consistency. - Adjusted repository imports to maintain a clean structure. - Standardized service imports across various service files. - Removed unnecessary comments and improved code formatting. - Ensured consistent use of optional chaining and nullish coalescing where applicable.
1 parent 1ee3a80 commit 31edd5e

File tree

180 files changed

+759
-838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+759
-838
lines changed

__tests__/index.test.js

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,13 @@
1-
/* eslint-disable @typescript-eslint/no-require-imports */
2-
/* eslint-disable no-undef */
3-
4-
/**
5-
* @file Jest test suite for the application.
6-
* @module __tests__/index.test
7-
*/
8-
9-
/**
10-
* Jest test suite for the application.
11-
*
12-
* @description
13-
* This test suite verifies the application's basic setup, including server definition,
14-
* port configuration, container initialization, and service bindings.
15-
*
16-
* Jest Methods Memo:
17-
* - `describe(name, fn)`: Creates a block that groups together several related tests.
18-
* - `it(name, fn)`: Defines a single test case with a descriptive name. Alias: `test(name, fn)`.
19-
* - `expect(value)`: Creates an assertion about a value.
20-
* - `toBe(value)`: Matches primitive values or checks referential identity.
21-
* - `toEqual(value)`: Matches when two objects have the same value. For deep equality, especially useful for objects and arrays.
22-
* - `toBeDefined()`: Asserts that a value is not `undefined`.
23-
* - `toBeUndefined()`: Asserts that a value is `undefined`.
24-
* - `toBeNull()`: Asserts that a value is `null`.
25-
* - `toBeTruthy()`: Asserts that a value is truthy.
26-
* - `toBeFalsy()`: Asserts that a value is falsy.
27-
* - `toBeGreaterThan(number)`: Asserts that a value is greater than a number.
28-
* - `toBeLessThan(number)`: Asserts that a value is less than a number.
29-
* - `toBeGreaterThanOrEqual(number)`: Asserts that a value is greater than or equal to a number.
30-
* - `toBeLessThanOrEqual(number)`: Asserts that a value is less than or equal to a number.
31-
* - `toContain(item)`: Asserts that an array or string contains a particular item.
32-
* - `toMatch(regexp)`: Asserts that a string matches a regular expression.
33-
* - `toThrow(error)`: Asserts that a function throws an error.
34-
* - `beforeEach(fn, timeout)`: Function to run before each test in the file.
35-
* - `afterEach(fn, timeout)`: Function to run after each test in the file.
36-
* - `beforeAll(fn, timeout)`: Function to run once before all tests in the file.
37-
* - `afterAll(fn, timeout)`: Function to run once after all tests in the file.
38-
* - `jest.fn()`: Creates a mock function.
39-
* - `jest.spyOn(object, methodName)`: Spies on a method of an object.
40-
* - `jest.mock(moduleName, factory, options)`: Mocks a module.
41-
*/
42-
43-
const app = require("../dist/app").app;
44-
// const container = require("../dist/container").default;
45-
// const request = require("supertest");
46-
1+
2+
3+
const app = require("../dist/app").app;
4+
475
test("Simple assertion", () => {
486
expect(true).toBe(true);
49-
});
50-
7+
});
8+
519
test("Server definition", () => {
5210
expect(app).toBeDefined();
53-
});
54-
55-
// test("Exemple request to /exemple", async () => {
56-
// const response = await request(app).get("/exemple");
57-
// const expected = container.get("ExempleService").getHelloWorld();
58-
// console.log("response", response);
59-
// expect(response.statusCode).toBe(200);
60-
// expect(response.text).toEqual(expected);
61-
// });
62-
11+
});
12+
6313

64-
// test("Exemple request to /exemple/user", async () => {
65-
// const response = await request(app).get("/exemple/user");
66-
// const expected = container.get("ExempleService").getHelloWorldWithName("user");
67-
// console.log("response", response);
68-
// expect(response.statusCode).toBe(200);
69-
// expect(response.text).toEqual(expected);
70-
// });

dist/app.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import "reflect-metadata";
21
import express from "express";
2+
import "reflect-metadata";
3+
import "./controllers/AuthenticatorController";
4+
import "./controllers/BuyOrderController";
35
import "./controllers/DescribeController";
46
import "./controllers/GameController";
7+
import "./controllers/GameGiftController";
58
import "./controllers/InventoryController";
69
import "./controllers/ItemController";
710
import "./controllers/LobbyController";
8-
import "./controllers/TradeController";
9-
import "./controllers/UserController";
11+
import "./controllers/MarketListingController";
1012
import "./controllers/OAuth2Controller";
11-
import "./controllers/StudioController";
1213
import "./controllers/SearchController";
1314
import "./controllers/StripeController";
15+
import "./controllers/StudioController";
16+
import "./controllers/TradeController";
17+
import "./controllers/UserController";
1418
import "./controllers/WebAuthnController";
15-
import "./controllers/AuthenticatorController";
16-
import "./controllers/GameGiftController";
17-
import "./controllers/MarketListingController";
18-
import "./controllers/BuyOrderController";
1919
export declare const app: express.Application;

dist/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ server.setConfig((app) => {
5959
app.use((0, cors_1.default)());
6060
app.use(express_1.default.static(path.join(__dirname, "public")));
6161
});
62-
// 404 handler
62+
6363
server.setErrorConfig((app) => {
6464
app.use((req, res) => {
6565
res.status(404).json({ message: "Not Found" });
6666
});
6767
});
6868
exports.app = server.build();
69+

dist/container.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ container.bind("GameGiftService").to(GameGiftService_1.GameGiftService).inSingle
3333
container.bind("MarketListingService").to(MarketListingService_1.MarketListingService).inSingletonScope();
3434
container.bind("BuyOrderService").to(BuyOrderService_1.BuyOrderService).inSingletonScope();
3535
exports.default = container;
36+

dist/controllers/AuthenticatorController.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response } from "express";
22
import { AuthenticatedRequest } from "../middlewares/LoggedCheck";
3-
import { IUserService } from "../services/UserService";
43
import { ILogService } from "../services/LogService";
4+
import { IUserService } from "../services/UserService";
55
export declare class Authenticator {
66
private userService;
77
private logService;

dist/controllers/AuthenticatorController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const qrcode = __importStar(require("qrcode"));
4343
const time2fa_1 = require("time2fa");
4444
const GenKey_1 = require("../utils/GenKey");
4545
const Jwt_1 = require("../utils/Jwt");
46-
// --- UTILS ---
46+
4747
function handleError(res, error, message, status = 500) {
4848
const msg = error instanceof Error ? error.message : String(error);
4949
res.status(status).send({ message, error: msg });
@@ -186,3 +186,4 @@ exports.Authenticator = Authenticator = __decorate([
186186
__param(1, (0, inversify_1.inject)("LogService")),
187187
__metadata("design:paramtypes", [Object, Object])
188188
], Authenticator);
189+

dist/controllers/BuyOrderController.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Response } from "express";
2+
import { AuthenticatedRequest } from "../middlewares/LoggedCheck";
23
import { IBuyOrderService } from "../services/BuyOrderService";
34
import { IItemService } from "../services/ItemService";
4-
import { AuthenticatedRequest } from "../middlewares/LoggedCheck";
55
import { ILogService } from "../services/LogService";
66
export declare class BuyOrderController {
77
private buyOrderService;
@@ -14,3 +14,4 @@ export declare class BuyOrderController {
1414
getBuyOrdersByUser(req: AuthenticatedRequest, res: Response): Promise<Response<any, Record<string, any>> | undefined>;
1515
getActiveBuyOrdersForItem(req: AuthenticatedRequest, res: Response): Promise<void>;
1616
}
17+

dist/controllers/BuyOrderController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports.BuyOrderController = void 0;
1616
const inversify_1 = require("inversify");
1717
const inversify_express_utils_1 = require("inversify-express-utils");
1818
const LoggedCheck_1 = require("../middlewares/LoggedCheck");
19-
// --- UTILS ---
19+
2020
function handleError(res, error, message, status = 500) {
2121
const msg = error instanceof Error ? error.message : String(error);
2222
res.status(status).send({ message, error: msg });
@@ -143,3 +143,4 @@ exports.BuyOrderController = BuyOrderController = __decorate([
143143
__param(2, (0, inversify_1.inject)("LogService")),
144144
__metadata("design:paramtypes", [Object, Object, Object])
145145
], BuyOrderController);
146+

dist/controllers/DescribeController.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ __decorate([
2727
exports.DescribeController = DescribeController = __decorate([
2828
(0, inversify_express_utils_1.controller)("/describe")
2929
], DescribeController);
30+

dist/controllers/GameController.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request, Response } from "express";
2+
import { AuthenticatedRequest } from "../middlewares/LoggedCheck";
23
import { IGameService } from "../services/GameService";
34
import { ILogService } from "../services/LogService";
4-
import { AuthenticatedRequest } from "../middlewares/LoggedCheck";
55
import { IUserService } from "../services/UserService";
66
export declare class Games {
77
private gameService;

0 commit comments

Comments
 (0)