Skip to content

Commit f8d1c42

Browse files
authored
Merge pull request #1474 from rocket-admin/backend_unused_code
Backend unused code
2 parents c75a7c1 + 123e51e commit f8d1c42

File tree

5 files changed

+3
-171
lines changed

5 files changed

+3
-171
lines changed

backend/package.json

Lines changed: 0 additions & 11 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",
@@ -80,7 +73,6 @@
8073
"knex": "3.1.0",
8174
"lru-cache": "^11.2.2",
8275
"nanoid": "5.1.6",
83-
"node-gyp": "^11.5.0",
8476
"nodemailer": "^7.0.10",
8577
"nunjucks": "^3.2.4",
8678
"openai": "^6.7.0",
@@ -100,9 +92,6 @@
10092
"validator": "^13.15.20",
10193
"winston": "3.18.3"
10294
},
103-
"optionalDependencies": {
104-
"ibm_db": "3.3.0"
105-
},
10695
"devDependencies": {
10796
"@ava/typescript": "6.0.0",
10897
"@nestjs/cli": "^11.0.10",
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: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

shared-code/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"packageExtensions": {
77
"ibm_db": {
88
"dependencies": {
9-
"node-gyp": "^10.2.0"
9+
"node-gyp": "^11.5.0"
1010
}
1111
}
1212
},
@@ -29,6 +29,7 @@
2929
"mongodb": "^6.20.0",
3030
"mysql2": "^3.15.3",
3131
"nanoid": "^5.1.6",
32+
"node-gyp": "^11.5.0",
3233
"oracledb": "^6.10.0",
3334
"p-queue": "^9.0.0",
3435
"pg": "^8.16.3",

yarn.lock

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,7 @@ __metadata:
30683068
mongodb: ^6.20.0
30693069
mysql2: ^3.15.3
30703070
nanoid: ^5.1.6
3071+
node-gyp: ^11.5.0
30713072
oracledb: ^6.10.0
30723073
p-queue: ^9.0.0
30733074
pg: ^8.16.3
@@ -5226,7 +5227,6 @@ __metadata:
52265227
fetch-blob: ^4.0.0
52275228
helmet: 8.1.0
52285229
i18n-iso-countries: ^7.14.0
5229-
ibm_db: 3.3.0
52305230
ip-range-check: 0.2.0
52315231
json2csv: ^5.0.7
52325232
jsonwebtoken: ^9.0.2
@@ -5235,7 +5235,6 @@ __metadata:
52355235
lru-cache: ^11.2.2
52365236
nanoid: 5.1.6
52375237
nock: ^14.0.10
5238-
node-gyp: ^11.5.0
52395238
nodemailer: ^7.0.10
52405239
nunjucks: ^3.2.4
52415240
openai: ^6.7.0
@@ -5260,9 +5259,6 @@ __metadata:
52605259
uuid: ^13.0.0
52615260
validator: ^13.15.20
52625261
winston: 3.18.3
5263-
dependenciesMeta:
5264-
ibm_db:
5265-
optional: true
52665262
languageName: unknown
52675263
linkType: soft
52685264

0 commit comments

Comments
 (0)