Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
DanneelsSophie committed Jan 17, 2025
1 parent 7349bf8 commit 9ea35f9
Show file tree
Hide file tree
Showing 61 changed files with 10,534 additions and 20,328 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Node
uses: actions/setup-node@v3
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: '18'
node-version-file: 'server/.nvmrc'
- name: Install dependencies
run: npm ci
- name: Build
Expand Down
19 changes: 0 additions & 19 deletions renovate.json

This file was deleted.

15 changes: 15 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
$schema: "https://docs.renovatebot.com/renovate-schema.json",
extends: [
"config:best-practices",
":semanticCommitTypeAll(ci)",
"docker:enableMajor",
":enableVulnerabilityAlertsWithLabel(security)",
":maintainLockFilesWeekly",
":automergeMinor",
":automergeDigest",
"customManagers:biomeVersions"
],
ignorePaths: ["clients/**"],
labels: ["dependencies"]
}
2 changes: 1 addition & 1 deletion server/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
22
41 changes: 0 additions & 41 deletions server/apps/backend/.eslintrc

This file was deleted.

10 changes: 0 additions & 10 deletions server/apps/backend/jest.config.js

This file was deleted.

72 changes: 30 additions & 42 deletions server/apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,43 @@
"scripts": {
"clean": "rimraf dist",
"dev": "tsup src/main.ts --watch --onSuccess \"node dist/main.js\"",
"build": "tsup src/main.ts",
"start": "node dist/main.js",
"test": "jest",
"format:check": "prettier --check src",
"format:fix": "prettier --write src",
"lint:check": "eslint src",
"lint:fix": "eslint src --fix"
"build": "tsc && tsup src/main.ts",
"start": "tscnode dist/main.js",
"test": "vitest --run",
"format:check": "biome format src",
"format:fix": "biome format --write src",
"lint:check": "biome lint src",
"lint:fix": "biome lint --write src"
},
"dependencies": {
"@types/big.js": "6.1.6",
"@types/body-parser": "1.19.2",
"@types/express": "4.17.17",
"@types/http-status-codes": "1.2.0",
"@types/lodash": "4.14.191",
"argon2": "0.30.3",
"big.js": "6.2.1",
"body-parser": "1.20.1",
"@types/big.js": "6.2.2",
"@types/body-parser": "1.19.5",
"@types/express": "5.0.0",
"@types/lodash": "4.17.14",
"argon2": "0.41.1",
"big.js": "6.2.2",
"body-parser": "1.20.3",
"colors": "1.4.0",
"cross-env": "7.0.3",
"dotenv": "16.0.3",
"express": "4.18.2",
"http-status-codes": "2.2.0",
"joi": "17.7.1",
"dotenv": "16.4.7",
"express": "4.21.2",
"http-status-codes": "2.3.0",
"joi": "17.13.3",
"lodash": "4.17.21",
"sqlite": "4.1.2",
"sqlite3": "5.1.4",
"winston": "3.8.2"
"sqlite": "5.1.1",
"sqlite3": "5.1.7",
"winston": "3.17.0"
},
"devDependencies": {
"@swc/core": "1.3.35",
"@swc/jest": "0.2.24",
"@tsconfig/node16": "1.0.3",
"@types/jest": "29.4.0",
"@types/jest-when": "3.5.2",
"@types/node": "18.13.0",
"@types/supertest": "2.0.12",
"@typescript-eslint/eslint-plugin": "5.51.0",
"@typescript-eslint/parser": "5.51.0",
"@swc/core": "1.10.7",
"@tsconfig/node20": "20.1.4",
"@types/node": "22.10.7",
"@types/supertest": "6.0.2",
"bower": "1.8.14",
"eslint": "8.34.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-import": "2.27.5",
"jest": "29.4.2",
"jest-when": "3.5.2",
"node-mocks-http": "1.12.1",
"supertest": "6.3.3",
"tsup": "6.6.2",
"typescript": "4.9.5"
"node-mocks-http": "1.16.2",
"supertest": "7.0.0",
"tsup": "8.3.5",
"typescript": "5.7.3",
"vitest": "3.0.2"
}
}
45 changes: 22 additions & 23 deletions server/apps/backend/src/SellerController.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Request, Response } from 'express-serve-static-core';
import type { Request, Response } from 'express-serve-static-core';
import { StatusCodes } from 'http-status-codes';
import { when } from 'jest-when';
import httpMocks, { MockRequest, MockResponse } from 'node-mocks-http';
import httpMocks, {
type MockRequest,
type MockResponse,
} from 'node-mocks-http';
import Configuration from './config';
import {
cashHistory,
Expand All @@ -13,7 +15,7 @@ import {
} from './fixtures';
import { Sellers } from './repositories';
import {
MaybeRegisterSellerRequest,
type MaybeRegisterSellerRequest,
listSellers,
registerSeller,
sellersHistory,
Expand All @@ -33,7 +35,7 @@ describe('Seller Controller', () => {
const request = httpMocks.createRequest({});
const response = httpMocks.createResponse();

jest.spyOn(sellerService, 'allSellers').mockResolvedValue(sellers);
vi.spyOn(sellerService, 'allSellers').mockResolvedValue(sellers);

await listSellers(sellerService)(request, response);

Expand Down Expand Up @@ -61,9 +63,9 @@ describe('Seller Controller', () => {
},
});
const response = httpMocks.createResponse();
when(jest.spyOn(sellerService, 'getCashHistory'))
.calledWith(42)
.mockResolvedValue(cashHistory);
vi.spyOn(sellerService, 'getCashHistory').mockResolvedValue(
cashHistory,
);

await sellersHistory(sellerService)(request, response);

Expand All @@ -79,9 +81,9 @@ describe('Seller Controller', () => {
},
});
const response = httpMocks.createResponse();
when(jest.spyOn(sellerService, 'getCashHistory'))
.calledWith(10)
.mockResolvedValue(cashHistory);
vi.spyOn(sellerService, 'getCashHistory').mockResolvedValue(
cashHistory,
);

await sellersHistory(sellerService)(request, response);

Expand All @@ -95,9 +97,9 @@ describe('Seller Controller', () => {
query: {},
});
const response = httpMocks.createResponse();
when(jest.spyOn(sellerService, 'getCashHistory'))
.calledWith(10)
.mockResolvedValue(cashHistory);
vi.spyOn(sellerService, 'getCashHistory').mockResolvedValue(
cashHistory,
);

await sellersHistory(sellerService)(request, response);

Expand All @@ -110,11 +112,11 @@ describe('Seller Controller', () => {
let body: MaybeRegisterSellerRequest;
let request: MockRequest<Request>;
let response: MockResponse<Response>;
const registerMock = jest.fn();
const registerMock = vi.fn();

beforeEach(() => {
response = httpMocks.createResponse();
jest.spyOn(sellerService, 'register').mockImplementation(registerMock);
vi.spyOn(sellerService, 'register').mockImplementation(registerMock);
});

describe('when invalid input body', () => {
Expand Down Expand Up @@ -194,6 +196,7 @@ describe('Seller Controller', () => {
['http', 'http://localhost'],
['https', 'https://localhost'],
])('when body has all required fields and valid url (%s)', (_, url) => {
// biome-ignore lint/suspicious/noDuplicateTestHooks: false positive due to describe.each
beforeEach(() => {
body = validSellerRequestWithUrl(url);
request = httpMocks.createRequest({
Expand All @@ -203,9 +206,7 @@ describe('Seller Controller', () => {

describe('when seller is not authorized', () => {
beforeEach(() => {
when(jest.spyOn(sellerService, 'isAuthorized'))
.calledWith(body.name!, body.password!)
.mockResolvedValue(false);
vi.spyOn(sellerService, 'isAuthorized').mockResolvedValue(false);
});

it('should return a unauthorized', async () => {
Expand All @@ -218,9 +219,7 @@ describe('Seller Controller', () => {

describe('when seller is authorized', () => {
beforeEach(() => {
when(jest.spyOn(sellerService, 'isAuthorized'))
.calledWith(body.name!, body.password!)
.mockResolvedValue(true);
vi.spyOn(sellerService, 'isAuthorized').mockResolvedValue(true);
});

it('should return a success', async () => {
Expand All @@ -229,7 +228,7 @@ describe('Seller Controller', () => {
expect(registerMock).toHaveBeenCalledWith(
body.url,
body.name,
body.password
body.password,
);
expect(response.statusCode).toBe(StatusCodes.OK);
});
Expand Down
8 changes: 4 additions & 4 deletions server/apps/backend/src/SellerController.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Request, Response } from 'express-serve-static-core';
import type { Request, Response } from 'express-serve-static-core';
import { StatusCodes } from 'http-status-codes';
import Joi from 'joi';
import { messageFromValidationError } from './error-utils';
import { SellerService } from './services';
import type { SellerService } from './services';
import { isValidUrl } from './utils';

export const listSellers =
Expand All @@ -21,7 +21,7 @@ export const sellersHistory =
(sellerService: SellerService) =>
async (request: Request, response: Response) => {
const { error, value } = sellersHistoryValidator.validate(
request.query.chunk
request.query.chunk,
);
const chunk = !error ? value : 10;
const cashHistory = await sellerService.getCashHistory(chunk);
Expand Down Expand Up @@ -58,7 +58,7 @@ export const registerSeller =
const { name: sellerName, url: sellerUrl, password: sellerPwd } = value;
const isAuthorized = await sellerService.isAuthorized(
sellerName,
sellerPwd
sellerPwd,
);
if (!isAuthorized) {
response
Expand Down
2 changes: 1 addition & 1 deletion server/apps/backend/src/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argon2 from 'argon2';
import bodyParser from 'body-parser';
import express, { Express } from 'express';
import express, { type Express } from 'express';
import request from 'supertest';
import Configuration from './config';
import { buildWithDefaults } from './fixtures';
Expand Down
2 changes: 1 addition & 1 deletion server/apps/backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const startGame = (dispatcher: Dispatcher) => {

export const setup = async () => {
const configuration = new Configuration(
path.join(__dirname, '..', process.env.CONFIGURATION_FILE ?? '')
path.join(__dirname, '..', process.env.CONFIGURATION_FILE ?? ''),
);
const sellers = await Sellers.create();
const sellerService = new SellerService(sellers, configuration);
Expand Down
Loading

0 comments on commit 9ea35f9

Please sign in to comment.