Skip to content

Commit 1988798

Browse files
authored
Merge branch 'main' into dev-container
2 parents 0e9ebef + b669448 commit 1988798

29 files changed

Lines changed: 423 additions & 229 deletions

File tree

.github/workflows/backend.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,3 @@ jobs:
2929
- uses: extractions/setup-just@v1
3030
- name: license checker
3131
run: 'cd backend && npx license-checker --onlyAllow="MIT;ISC;Python-2.0;Apache-2.0;BSD;MPL;CC;Custom: http://github.com/dscape/statsd-parser;" --excludePrivatePackages'
32-
lint:
33-
runs-on:
34-
labels: ubuntu-latest-4-cores
35-
steps:
36-
- uses: actions/checkout@v3
37-
- uses: extractions/setup-just@v1
38-
- uses: actions/setup-node@v3
39-
with:
40-
node-version: '18'
41-
- run: cd backend && yarn install
42-
- run: cd backend && yarn run lint

.github/workflows/code-quality.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Code quality
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
quality:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v5
15+
with:
16+
persist-credentials: false
17+
- name: Setup Biome
18+
uses: biomejs/setup-biome@v2
19+
with:
20+
version: latest
21+
- name: Run Biome
22+
run: biome ci --formatter-enabled=false --assist-enabled=false .

autoadmin-ws-server/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
import express, { Router, json } from 'express';
32
import axios from 'axios';
43
const app = express();

backend/package.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66
"private": true,
77
"license": "UNLICENSED",
88
"type": "module",
9-
"packageExtensions": {
10-
"ibm_db": {
11-
"dependencies": {
12-
"node-gyp": "^11.5.0"
13-
}
14-
}
15-
},
169
"scripts": {
1710
"prebuild": "rimraf dist",
1811
"build": "nest build",
@@ -21,7 +14,6 @@
2114
"start:dev": "nest start --watch --preserveWatchOutput",
2215
"start:debug": "nest start --debug --watch",
2316
"start:prod": "node dist/main",
24-
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
2517
"test": "ava test/ava-tests/non-saas-tests/* --serial",
2618
"test-all": "ava --timeout=5m",
2719
"test-saas": "ava test/ava-tests/saas-tests/* ",
@@ -80,7 +72,6 @@
8072
"knex": "3.1.0",
8173
"lru-cache": "^11.2.2",
8274
"nanoid": "5.1.6",
83-
"node-gyp": "^11.5.0",
8475
"nodemailer": "^7.0.10",
8576
"nunjucks": "^3.2.4",
8677
"openai": "^6.7.0",
@@ -100,9 +91,6 @@
10091
"validator": "^13.15.20",
10192
"winston": "3.18.3"
10293
},
103-
"optionalDependencies": {
104-
"ibm_db": "3.3.0"
105-
},
10694
"devDependencies": {
10795
"@ava/typescript": "6.0.0",
10896
"@nestjs/cli": "^11.0.10",

backend/src/exceptions/custom-exceptions/validation-exception.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ export class ValidationException extends HttpException {
1515
).join(', ')}`;
1616
})
1717
.join('.\n');
18-
} else {
19-
originalMessage = originalMessage;
2018
}
2119
super(originalMessage, HttpStatus.BAD_REQUEST);
2220
this.internalCode = ExceptionsInternalCodes.VALIDATOR_EXCEPTION;
Lines changed: 0 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import { ForeignKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/foreign-key.ds.js';
2-
import { PrimaryKeyDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/primary-key.ds.js';
3-
import { TableStructureDS } from '@rocketadmin/shared-code/dist/src/data-access-layer/shared/data-structures/table-structure.ds.js';
4-
import { Knex } from 'knex';
51
import { LRUCache } from 'lru-cache';
6-
import { ConnectionEntity } from '../../entities/connection/connection.entity.js';
72
import { isSaaS } from '../app/is-saas.js';
83
import { Constants } from '../constants/constants.js';
94

10-
const knexCache = new LRUCache(Constants.DEFAULT_CONNECTION_CACHE_OPTIONS);
11-
const tunnelCache = new LRUCache(Constants.DEFAULT_TUNNEL_CACHE_OPTIONS);
12-
const driverCache = new LRUCache(Constants.DEFAULT_DRIVER_CACHE_OPTIONS);
135
const invitationCache = new LRUCache(Constants.DEFAULT_INVITATION_CACHE_OPTIONS);
14-
const tableStructureCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
15-
const tableForeignKeysCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
16-
const tablePrimaryKeysCache = new LRUCache(Constants.DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS);
176
const tableReadPermissionCache = new LRUCache(Constants.DEFAULT_TABLE_PERMISSIONS_CACHE_OPTIONS);
187

198
export class Cacher {
@@ -76,129 +65,8 @@ export class Cacher {
7665
return userInvitations <= 10 && groupInvitations <= 10;
7766
}
7867

79-
public static getCachedKnex(connectionConfig): Knex {
80-
const cachedKnex = knexCache.get(JSON.stringify(connectionConfig)) as Knex;
81-
return cachedKnex ? cachedKnex : null;
82-
}
83-
84-
public static setKnexCache(connectionConfig, newKnex: Knex): void {
85-
knexCache.set(JSON.stringify(connectionConfig), newKnex);
86-
}
87-
88-
public static getTunnelCache(connection: ConnectionEntity): any {
89-
const cachedTnl = tunnelCache.get(JSON.stringify(connection));
90-
return cachedTnl ? cachedTnl : null;
91-
}
92-
93-
public static setTunnelCache(connection: ConnectionEntity, tnlObj): void {
94-
tunnelCache.set(JSON.stringify(connection), tnlObj);
95-
}
96-
97-
public static delTunnelCache(connection: ConnectionEntity): void {
98-
tunnelCache.delete(JSON.stringify(connection));
99-
}
100-
101-
public static getDriverCache(connection: ConnectionEntity): any {
102-
const cachedDriver = driverCache.get(JSON.stringify(connection));
103-
return cachedDriver ? cachedDriver : null;
104-
}
105-
106-
public static setDriverCache(connection: ConnectionEntity, newDriver): void {
107-
driverCache.set(JSON.stringify(connection), newDriver);
108-
}
109-
110-
public static delDriverCache(connection: ConnectionEntity): void {
111-
driverCache.delete(JSON.stringify(connection));
112-
}
113-
114-
public static setTableStructureCache(
115-
connection: ConnectionEntity,
116-
tableName: string,
117-
structure: Array<TableStructureDS>,
118-
): void {
119-
const connectionCopy = {
120-
...connection,
121-
};
122-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
123-
tableStructureCache.set(cacheObj, structure);
124-
}
125-
126-
public static getTableStructureCache(connection: ConnectionEntity, tableName: string): Array<TableStructureDS> {
127-
const connectionCopy = {
128-
...connection,
129-
};
130-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
131-
const foundStructure = tableStructureCache.get(cacheObj) as Array<TableStructureDS>;
132-
return foundStructure ? foundStructure : null;
133-
}
134-
135-
public static setTablePrimaryKeysCache(
136-
connection: ConnectionEntity,
137-
tableName: string,
138-
primaryKeys: Array<PrimaryKeyDS>,
139-
): void {
140-
const connectionCopy = {
141-
...connection,
142-
};
143-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
144-
tablePrimaryKeysCache.set(cacheObj, primaryKeys);
145-
}
146-
147-
public static getTablePrimaryKeysCache(connection: ConnectionEntity, tableName: string): Array<PrimaryKeyDS> {
148-
const connectionCopy = {
149-
...connection,
150-
};
151-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
152-
const foundKeys = tablePrimaryKeysCache.get(cacheObj) as Array<PrimaryKeyDS>;
153-
return foundKeys ? foundKeys : null;
154-
}
155-
156-
public static setTableForeignKeysCache(
157-
connection: ConnectionEntity,
158-
tableName: string,
159-
foreignKeys: Array<ForeignKeyDS>,
160-
): void {
161-
const connectionCopy = {
162-
...connection,
163-
};
164-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
165-
tableForeignKeysCache.set(cacheObj, foreignKeys);
166-
}
167-
168-
public static getTableForeignKeysCache(connection: ConnectionEntity, tableName: string): Array<ForeignKeyDS> {
169-
const connectionCopy = {
170-
...connection,
171-
};
172-
const cacheObj = JSON.stringify({ connectionCopy, tableName });
173-
const foundKeys = tableForeignKeysCache.get(cacheObj) as Array<ForeignKeyDS>;
174-
return foundKeys ? foundKeys : null;
175-
}
176-
17768
public static async clearAllCache(): Promise<void> {
178-
const elements = [];
179-
knexCache.forEach((value, key) => {
180-
elements.push({ key, value });
181-
});
182-
for (const element of elements) {
183-
await element.value.destroy();
184-
knexCache.delete(element.key);
185-
}
186-
knexCache.clear();
187-
188-
const tunnelElements = [];
189-
tunnelCache.forEach((value, key) => {
190-
tunnelElements.push({ key, value });
191-
});
192-
for (const element of tunnelElements) {
193-
await element.value.close();
194-
tunnelCache.delete(element.key);
195-
}
196-
tunnelCache.clear();
197-
await driverCache.clear();
19869
await invitationCache.clear();
199-
await tableStructureCache.clear();
200-
await tableForeignKeysCache.clear();
201-
await tablePrimaryKeysCache.clear();
20270
await tableReadPermissionCache.clear();
20371
}
20472
}

backend/src/helpers/constants/constants.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const Constants = {
9292
},
9393

9494
ONE_DAY_AGO: (): Date => {
95-
return new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
95+
return new Date(Date.now() - 24 * 60 * 60 * 1000);
9696
},
9797

9898
CRON_SHEDULE: '30 5 13 * * *',
@@ -118,33 +118,11 @@ export const Constants = {
118118
},
119119
},
120120

121-
DEFAULT_TUNNEL_CACHE_OPTIONS: {
122-
max: 100,
123-
ttl: 1000 * 60 * 60,
124-
dispose: async (tnl: any) => {
125-
try {
126-
await tnl.close();
127-
} catch (e) {
128-
console.error('Tunnel closing error: ' + e);
129-
}
130-
},
131-
},
132-
133-
DEFAULT_DRIVER_CACHE_OPTIONS: {
134-
max: 50,
135-
ttl: 1000 * 60 * 60,
136-
},
137-
138121
DEFAULT_INVITATION_CACHE_OPTIONS: {
139122
max: 200,
140123
ttl: 1000 * 60 * 60,
141124
},
142125

143-
DEFAULT_TABLE_STRUCTURE_ELEMENTS_CACHE_OPTIONS: {
144-
max: 1000,
145-
ttl: 1000 * 60,
146-
},
147-
148126
DEFAULT_TABLE_PERMISSIONS_CACHE_OPTIONS: {
149127
max: 1000,
150128
ttl: 1000 * 10,
@@ -296,6 +274,7 @@ export const Constants = {
296274
// break;
297275
case type.toLowerCase().includes('dynamodb'):
298276
connection = parseTestDynamoDBConnectionString(connection_string) as CreateConnectionDto;
277+
break;
299278
default:
300279
break;
301280
}

backend/src/helpers/encryption/encryptor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,17 @@ export class Encryptor {
140140
hash = CryptoJS.SHA384(data);
141141
return hash.toString(CryptoJS.enc.Hex);
142142

143-
case EncryptionAlgorithmEnum.pbkdf2:
143+
case EncryptionAlgorithmEnum.pbkdf2: {
144144
const salt = CryptoJS.lib.WordArray.random(128 / 8);
145145
return CryptoJS.PBKDF2(data, salt, {
146146
keySize: 256 / 32,
147147
}).toString();
148+
}
148149

149-
case EncryptionAlgorithmEnum.bcrypt:
150+
case EncryptionAlgorithmEnum.bcrypt: {
150151
const bSalt = await bcrypt.genSalt();
151152
return await bcrypt.hash(data, bSalt);
153+
}
152154

153155
case EncryptionAlgorithmEnum.argon2:
154156
return await argon2.hash(data);

backend/src/helpers/validators/validation-helper.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ export class ValidationHelper {
5656
return countries.isValid(countryCode);
5757
}
5858

59-
public isValidUrl(url: string): boolean {
60-
return validator.isURL(url);
61-
}
62-
6359
public static validateOrThrowHttpExceptionEmail(email: string): boolean {
6460
const isEmailValid = ValidationHelper.isValidEmail(email);
6561
if (isEmailValid) {

backend/test/mock.factory.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,11 @@ export class MockFactory {
335335
return this.generateConnectionToSchemaOracleDBInDocker();
336336
case 'mssql':
337337
return this.generateConnectionToTestMsSQlDBInDocker();
338-
case 'mysql':
338+
case 'mysql': {
339339
const config = this.generateConnectionToTestMySQLDBInDocker();
340340
config.type = 'mysql2';
341341
return config;
342+
}
342343
}
343344
}
344345

0 commit comments

Comments
 (0)