Skip to content

Commit 86e97ab

Browse files
committed
package updates & more typings
1 parent 853b7d9 commit 86e97ab

8 files changed

Lines changed: 5657 additions & 49 deletions

File tree

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@
2424
"license": "BSL 1.1",
2525
"dependencies": {
2626
"@aws-sdk/client-s3": "^3.x",
27-
"archiver": "^5.x",
27+
"archiver": "^7.x",
2828
"archiver-zip-encrypted": "^2.0.0",
2929
"axios": "^1.x",
30-
"cron": "^2.x",
31-
"dotenv": "^16.x",
32-
"express": "^4.x",
33-
"googleapis": "^118.x",
30+
"cron": "^4.x",
31+
"dotenv": "^17.x",
32+
"express": "^5.x",
33+
"googleapis": "^168.x",
3434
"mysql2": "^3.x",
35-
"uuid": "^9.x",
35+
"uuid": "^13.x",
3636
"winston": "^3.x"
3737
},
3838
"devDependencies": {
3939
"prettier": "3.5.3",
40-
"@types/archiver": "^5.x",
41-
"@types/cron": "^2.x",
40+
"@types/archiver": "^7.x",
41+
"@types/cron": "^4.x",
4242
"@types/express": "^4.x",
4343
"@types/jest": "^29.x",
4444
"@types/node": "^18.x",
45-
"@types/uuid": "^9.x",
45+
"@types/uuid": "^13.x",
4646
"@typescript-eslint/eslint-plugin": "^5.x",
4747
"@typescript-eslint/parser": "^5.x",
4848
"eslint": "^8.x",

src/core/scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class Scheduler {
4545
},
4646
null, // onComplete
4747
true, // start
48-
'UTC', // timeZone
48+
process?.env?.TZ || 'UTC', // timezone
4949
);
5050

5151
logger.info('Scheduler started');

src/db/connector.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { DatabaseConfig } from '../config';
2+
13
/**
24
* Database connector interface
35
* This interface defines the methods that all database connectors must implement
@@ -52,5 +54,5 @@ export interface DatabaseConnectorFactory {
5254
* @param config Database configuration
5355
* @returns Database connector instance
5456
*/
55-
createConnector(config: any): DatabaseConnector;
57+
createConnector(config: DatabaseConfig): DatabaseConnector;
5658
}

src/db/implementations/mariadb.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,14 @@ export class MariaDBConnector implements DatabaseConnector {
7676
await this.connect();
7777
}
7878

79-
const [rows] = await this.connection!.query('SHOW DATABASES');
79+
const [rows] = this.connection
80+
? await this.connection.query('SHOW DATABASES')
81+
: [[], []];
82+
83+
type SHOW_DB_ROWS = { Database: string };
8084

8185
// Filter out system databases
82-
const databases = (rows as any[])
86+
const databases = (rows as SHOW_DB_ROWS[])
8387
.map((row) => row.Database)
8488
.filter(
8589
(name) =>
@@ -113,9 +117,9 @@ export class MariaDBConnector implements DatabaseConnector {
113117
await this.connect();
114118
}
115119

116-
const [rows] = await this.connection!.query('SHOW DATABASES LIKE ?', [
117-
database,
118-
]);
120+
const [rows] = this.connection
121+
? await this.connection.query('SHOW DATABASES LIKE ?', [database])
122+
: [[], []];
119123

120124
return (rows as any[]).length > 0;
121125
} catch (error) {
@@ -180,9 +184,11 @@ export class MariaDBConnector implements DatabaseConnector {
180184

181185
if (!exists) {
182186
logger.info(`Creating database: ${database}`);
183-
await this.connection!.query(
184-
`CREATE DATABASE IF NOT EXISTS \`${database}\``,
185-
);
187+
if (this.connection) {
188+
await this.connection.query(
189+
`CREATE DATABASE IF NOT EXISTS \`${database}\``,
190+
);
191+
}
186192
}
187193

188194
// Use the mysql command to restore the database

src/storage/s3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export class S3StorageProvider implements StorageProvider {
361361

362362
return true;
363363
} catch (error: any) {
364-
if (error.name === 'NotFound') {
364+
if (error?.name === 'NotFound') {
365365
return false;
366366
}
367367
throw error;

tests/utils/compression.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import fs from "fs";
2-
import path from "path";
3-
import os from "os";
4-
import { compressFile, decompressFile } from "../../src/utils/compression";
1+
import fs from 'fs';
2+
import path from 'path';
3+
import os from 'os';
4+
import { compressFile, decompressFile } from '../../src/utils/compression';
55

6-
describe("Compression Utils", () => {
6+
describe('Compression Utils', () => {
77
let tempDir: string;
88
let testFile: string;
99
let compressedFile: string;
1010
let decompressedFile: string;
11-
const testContent = "This is a test file content for compression testing.";
11+
const testContent = 'This is a test file content for compression testing.';
1212

1313
beforeAll(async () => {
1414
// Create temporary directory for test files
1515
tempDir = path.join(os.tmpdir(), `compression-test-${Date.now()}`);
1616
fs.mkdirSync(tempDir, { recursive: true });
1717

1818
// Create test file
19-
testFile = path.join(tempDir, "test-file.txt");
19+
testFile = path.join(tempDir, 'test-file.txt');
2020
fs.writeFileSync(testFile, testContent);
2121

2222
// Define paths for compressed and decompressed files
23-
compressedFile = path.join(tempDir, "compressed-file.gz");
24-
decompressedFile = path.join(tempDir, "decompressed-file.txt");
23+
compressedFile = path.join(tempDir, 'compressed-file.gz');
24+
decompressedFile = path.join(tempDir, 'decompressed-file.txt');
2525
});
2626

2727
afterAll(() => {
@@ -34,7 +34,7 @@ describe("Compression Utils", () => {
3434
if (fs.existsSync(tempDir)) fs.rmdirSync(tempDir);
3535
});
3636

37-
it("should compress and decompress a file correctly", async () => {
37+
it('should compress and decompress a file correctly', async () => {
3838
// Compress the file
3939
await compressFile(testFile, compressedFile);
4040

@@ -48,18 +48,18 @@ describe("Compression Utils", () => {
4848
await decompressFile(compressedFile, decompressedFile);
4949

5050
// Verify decompressed content matches original
51-
const decompressedContent = fs.readFileSync(decompressedFile, "utf8");
51+
const decompressedContent = fs.readFileSync(decompressedFile, 'utf8');
5252
expect(decompressedContent).toEqual(testContent);
5353
});
5454

55-
it("should throw an error when decompressing an invalid file", async () => {
55+
it('should throw an error when decompressing an invalid file', async () => {
5656
// Create an invalid compressed file
57-
const invalidFile = path.join(tempDir, "invalid.gz");
58-
fs.writeFileSync(invalidFile, "This is not a valid gzip file");
57+
const invalidFile = path.join(tempDir, 'invalid.gz');
58+
fs.writeFileSync(invalidFile, 'This is not a valid gzip file');
5959

6060
// Attempt to decompress the invalid file
6161
await expect(
62-
decompressFile(invalidFile, decompressedFile)
62+
decompressFile(invalidFile, decompressedFile),
6363
).rejects.toThrow();
6464

6565
// Clean up

tests/utils/encryption.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import fs from "fs";
2-
import path from "path";
3-
import os from "os";
4-
import { encryptFile, decryptFile } from "../../src/utils/encryption";
1+
import fs from 'fs';
2+
import path from 'path';
3+
import os from 'os';
4+
import { encryptFile, decryptFile } from '../../src/utils/encryption';
55

6-
describe("Encryption Utils", () => {
6+
describe('Encryption Utils', () => {
77
let tempDir: string;
88
let testFile: string;
99
let encryptedFile: string;
1010
let decryptedFile: string;
11-
const testContent = "This is a test file content for encryption testing.";
12-
const password = "test-password-123";
11+
const testContent = 'This is a test file content for encryption testing.';
12+
const password = 'test-password-123';
1313

1414
beforeAll(async () => {
1515
// Create temporary directory for test files
1616
tempDir = path.join(os.tmpdir(), `encryption-test-${Date.now()}`);
1717
fs.mkdirSync(tempDir, { recursive: true });
1818

1919
// Create test file
20-
testFile = path.join(tempDir, "test-file.txt");
20+
testFile = path.join(tempDir, 'test-file.txt');
2121
fs.writeFileSync(testFile, testContent);
2222

2323
// Define paths for encrypted and decrypted files
24-
encryptedFile = path.join(tempDir, "encrypted-file.enc");
25-
decryptedFile = path.join(tempDir, "decrypted-file.txt");
24+
encryptedFile = path.join(tempDir, 'encrypted-file.enc');
25+
decryptedFile = path.join(tempDir, 'decrypted-file.txt');
2626
});
2727

2828
afterAll(() => {
@@ -35,7 +35,7 @@ describe("Encryption Utils", () => {
3535
if (fs.existsSync(tempDir)) fs.rmdirSync(tempDir);
3636
});
3737

38-
it("should encrypt and decrypt a file correctly", async () => {
38+
it('should encrypt and decrypt a file correctly', async () => {
3939
// Encrypt the file
4040
await encryptFile(testFile, encryptedFile, password);
4141

@@ -48,17 +48,17 @@ describe("Encryption Utils", () => {
4848
await decryptFile(encryptedFile, decryptedFile, password);
4949

5050
// Verify decrypted content matches original
51-
const decryptedContent = fs.readFileSync(decryptedFile, "utf8");
51+
const decryptedContent = fs.readFileSync(decryptedFile, 'utf8');
5252
expect(decryptedContent).toEqual(testContent);
5353
});
5454

55-
it("should throw an error when decrypting with wrong password", async () => {
55+
it('should throw an error when decrypting with wrong password', async () => {
5656
// Encrypt the file
5757
await encryptFile(testFile, encryptedFile, password);
5858

5959
// Attempt to decrypt with wrong password
6060
await expect(
61-
decryptFile(encryptedFile, decryptedFile, "wrong-password")
61+
decryptFile(encryptedFile, decryptedFile, 'wrong-password'),
6262
).rejects.toThrow();
6363
});
6464
});

0 commit comments

Comments
 (0)