@jsfsi-core/ts-nodejs 1.1.12 → 1.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -15
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -384,10 +384,13 @@ expect(logger.logs).toContainEqual({ level: 'log', message: 'Hello world' });
|
|
|
384
384
|
Type-safe environment variable loading:
|
|
385
385
|
|
|
386
386
|
```typescript
|
|
387
|
-
import {
|
|
387
|
+
import { loadEnvConfig } from '@jsfsi-core/ts-nodejs';
|
|
388
388
|
|
|
389
|
-
// Load .env file
|
|
390
|
-
|
|
389
|
+
// Load .env file from configuration directory
|
|
390
|
+
loadEnvConfig({
|
|
391
|
+
configPath: './configuration',
|
|
392
|
+
env: 'development', // optional, defaults to no suffix
|
|
393
|
+
});
|
|
391
394
|
|
|
392
395
|
// Access environment variables
|
|
393
396
|
const port = process.env.PORT;
|
|
@@ -415,17 +418,18 @@ const dbUrl = process.env.DATABASE_URL;
|
|
|
415
418
|
|
|
416
419
|
### Testing Repositories
|
|
417
420
|
|
|
418
|
-
Use `
|
|
421
|
+
Use `buildTransactionalRepositoryMock` for testing:
|
|
419
422
|
|
|
420
423
|
```typescript
|
|
421
|
-
import {
|
|
424
|
+
import { buildTransactionalRepositoryMock } from '@jsfsi-core/ts-nodejs';
|
|
422
425
|
|
|
423
426
|
describe('UserRepository', () => {
|
|
424
427
|
let repository: UserRepository;
|
|
425
428
|
|
|
426
429
|
beforeEach(() => {
|
|
427
430
|
const mockDataSource = {} as DataSource;
|
|
428
|
-
|
|
431
|
+
const repositoryInstance = new UserRepository(mockDataSource);
|
|
432
|
+
repository = buildTransactionalRepositoryMock(repositoryInstance);
|
|
429
433
|
});
|
|
430
434
|
|
|
431
435
|
it('finds user by id', async () => {
|
|
@@ -451,7 +455,7 @@ describe('UserService', () => {
|
|
|
451
455
|
|
|
452
456
|
### Testing Logging
|
|
453
457
|
|
|
454
|
-
Use `MockLogger` for testing:
|
|
458
|
+
Use `MockLogger` for testing (it provides no-op implementations of all logging methods):
|
|
455
459
|
|
|
456
460
|
```typescript
|
|
457
461
|
import { MockLogger } from '@jsfsi-core/ts-nodejs';
|
|
@@ -465,14 +469,9 @@ describe('UserService', () => {
|
|
|
465
469
|
service = new UserService(logger);
|
|
466
470
|
});
|
|
467
471
|
|
|
468
|
-
it('
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
expect(logger.error).toHaveBeenCalled();
|
|
472
|
-
expect(logger.error).toHaveBeenCalledWith(
|
|
473
|
-
expect.stringContaining('Failed'),
|
|
474
|
-
expect.any(Object),
|
|
475
|
-
);
|
|
472
|
+
it('processes order without throwing', async () => {
|
|
473
|
+
// MockLogger silently absorbs all logs, making tests cleaner
|
|
474
|
+
await expect(service.processOrder('invalid-id')).resolves.not.toThrow();
|
|
476
475
|
});
|
|
477
476
|
});
|
|
478
477
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsfsi-core/ts-nodejs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"typeorm": "0.3.27"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@vitest/coverage-v8": "4.0.
|
|
39
|
-
"vite": "7.
|
|
38
|
+
"@vitest/coverage-v8": "4.0.10",
|
|
39
|
+
"vite": "7.2.2",
|
|
40
40
|
"vite-plugin-dts": "4.5.4",
|
|
41
|
-
"vitest": "4.0.
|
|
41
|
+
"vitest": "4.0.10"
|
|
42
42
|
}
|
|
43
43
|
}
|