@forklaunch/core 0.2.37 → 0.3.0
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/lib/{src/database/mikro/models/entities/base.entity.d.ts → base.entity-DNfmMOgd.d.mts} +3 -2
- package/lib/base.entity-DNfmMOgd.d.ts +27 -0
- package/lib/{src/cache/redisTtlCache.d.ts → cache/index.d.mts} +67 -4
- package/lib/cache/index.d.ts +130 -0
- package/lib/cache/index.js +133 -0
- package/lib/cache/index.mjs +105 -0
- package/lib/controllers/index.d.mts +5 -0
- package/lib/controllers/index.d.ts +5 -0
- package/lib/controllers/index.js +18 -0
- package/lib/controllers/index.mjs +0 -0
- package/lib/database/index.d.mts +37 -0
- package/lib/{src/database/mikro/models/entities/mongo.base.entity.d.ts → database/index.d.ts} +5 -2
- package/lib/database/index.js +78 -0
- package/lib/database/index.mjs +53 -0
- package/lib/dtoMapper/index.d.mts +215 -0
- package/lib/dtoMapper/index.d.ts +215 -0
- package/lib/dtoMapper/index.js +230 -0
- package/lib/dtoMapper/index.mjs +202 -0
- package/lib/http/index.d.mts +910 -0
- package/lib/http/index.d.ts +910 -0
- package/lib/http/index.js +2181 -0
- package/lib/http/index.mjs +2122 -0
- package/lib/services/index.d.mts +64 -0
- package/lib/services/index.d.ts +64 -0
- package/lib/services/index.js +159 -0
- package/lib/services/index.mjs +131 -0
- package/package.json +39 -26
- package/lib/src/cache/index.d.ts +0 -5
- package/lib/src/cache/index.d.ts.map +0 -1
- package/lib/src/cache/index.js +0 -4
- package/lib/src/cache/interfaces/ttlCache.interface.d.ts +0 -48
- package/lib/src/cache/interfaces/ttlCache.interface.d.ts.map +0 -1
- package/lib/src/cache/interfaces/ttlCache.interface.js +0 -1
- package/lib/src/cache/redisTtlCache.d.ts.map +0 -1
- package/lib/src/cache/redisTtlCache.js +0 -98
- package/lib/src/cache/types/ttlCacheRecord.types.d.ts +0 -14
- package/lib/src/cache/types/ttlCacheRecord.types.d.ts.map +0 -1
- package/lib/src/cache/types/ttlCacheRecord.types.js +0 -1
- package/lib/src/cache/utils/cacheKey.d.ts +0 -2
- package/lib/src/cache/utils/cacheKey.d.ts.map +0 -1
- package/lib/src/cache/utils/cacheKey.js +0 -3
- package/lib/src/controllers/index.d.ts +0 -2
- package/lib/src/controllers/index.d.ts.map +0 -1
- package/lib/src/controllers/index.js +0 -1
- package/lib/src/controllers/interfaces/controller.interface.d.ts +0 -4
- package/lib/src/controllers/interfaces/controller.interface.d.ts.map +0 -1
- package/lib/src/controllers/interfaces/controller.interface.js +0 -1
- package/lib/src/database/index.d.ts +0 -3
- package/lib/src/database/index.d.ts.map +0 -1
- package/lib/src/database/index.js +0 -2
- package/lib/src/database/mikro/models/entities/base.entity.d.ts.map +0 -1
- package/lib/src/database/mikro/models/entities/base.entity.js +0 -42
- package/lib/src/database/mikro/models/entities/mongo.base.entity.d.ts.map +0 -1
- package/lib/src/database/mikro/models/entities/mongo.base.entity.js +0 -51
- package/lib/src/dtoMapper/index.d.ts +0 -3
- package/lib/src/dtoMapper/index.d.ts.map +0 -1
- package/lib/src/dtoMapper/index.js +0 -2
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts +0 -18
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.d.ts.map +0 -1
- package/lib/src/dtoMapper/interfaces/dtoMapper.interface.js +0 -1
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts +0 -72
- package/lib/src/dtoMapper/models/baseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/baseDtoMapper.model.js +0 -76
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts +0 -68
- package/lib/src/dtoMapper/models/requestDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/requestDtoMapper.model.js +0 -71
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts +0 -67
- package/lib/src/dtoMapper/models/responseDtoMapper.model.d.ts.map +0 -1
- package/lib/src/dtoMapper/models/responseDtoMapper.model.js +0 -68
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts +0 -9
- package/lib/src/dtoMapper/types/dtoMapper.types.d.ts.map +0 -1
- package/lib/src/dtoMapper/types/dtoMapper.types.js +0 -1
- package/lib/src/http/application/expressLikeApplication.d.ts +0 -21
- package/lib/src/http/application/expressLikeApplication.d.ts.map +0 -1
- package/lib/src/http/application/expressLikeApplication.js +0 -21
- package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts +0 -4
- package/lib/src/http/guards/isConstrainedForklaunchRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isConstrainedForklaunchRouter.js +0 -5
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts +0 -5
- package/lib/src/http/guards/isExpressLikeSchemaHandler.d.ts.map +0 -1
- package/lib/src/http/guards/isExpressLikeSchemaHandler.js +0 -6
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts +0 -5
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isForklaunchExpressLikeRouter.js +0 -6
- package/lib/src/http/guards/isForklaunchRouter.d.ts +0 -4
- package/lib/src/http/guards/isForklaunchRouter.d.ts.map +0 -1
- package/lib/src/http/guards/isForklaunchRouter.js +0 -7
- package/lib/src/http/guards/isHttpContractDetails.d.ts +0 -7
- package/lib/src/http/guards/isHttpContractDetails.d.ts.map +0 -1
- package/lib/src/http/guards/isHttpContractDetails.js +0 -9
- package/lib/src/http/guards/isPathParamContractDetails.d.ts +0 -4
- package/lib/src/http/guards/isPathParamContractDetails.d.ts.map +0 -1
- package/lib/src/http/guards/isPathParamContractDetails.js +0 -10
- package/lib/src/http/guards/isResponseShape.d.ts +0 -3
- package/lib/src/http/guards/isResponseShape.d.ts.map +0 -1
- package/lib/src/http/guards/isResponseShape.js +0 -7
- package/lib/src/http/guards/isTypedHandler.d.ts +0 -5
- package/lib/src/http/guards/isTypedHandler.d.ts.map +0 -1
- package/lib/src/http/guards/isTypedHandler.js +0 -6
- package/lib/src/http/handlers/delete.d.ts +0 -9
- package/lib/src/http/handlers/delete.d.ts.map +0 -1
- package/lib/src/http/handlers/delete.js +0 -4
- package/lib/src/http/handlers/get.d.ts +0 -9
- package/lib/src/http/handlers/get.d.ts.map +0 -1
- package/lib/src/http/handlers/get.js +0 -4
- package/lib/src/http/handlers/head.d.ts +0 -9
- package/lib/src/http/handlers/head.d.ts.map +0 -1
- package/lib/src/http/handlers/head.js +0 -4
- package/lib/src/http/handlers/middleware.d.ts +0 -9
- package/lib/src/http/handlers/middleware.d.ts.map +0 -1
- package/lib/src/http/handlers/middleware.js +0 -4
- package/lib/src/http/handlers/options.d.ts +0 -9
- package/lib/src/http/handlers/options.d.ts.map +0 -1
- package/lib/src/http/handlers/options.js +0 -4
- package/lib/src/http/handlers/patch.d.ts +0 -9
- package/lib/src/http/handlers/patch.d.ts.map +0 -1
- package/lib/src/http/handlers/patch.js +0 -4
- package/lib/src/http/handlers/post.d.ts +0 -9
- package/lib/src/http/handlers/post.d.ts.map +0 -1
- package/lib/src/http/handlers/post.js +0 -4
- package/lib/src/http/handlers/put.d.ts +0 -9
- package/lib/src/http/handlers/put.d.ts.map +0 -1
- package/lib/src/http/handlers/put.js +0 -4
- package/lib/src/http/handlers/trace.d.ts +0 -9
- package/lib/src/http/handlers/trace.d.ts.map +0 -1
- package/lib/src/http/handlers/trace.js +0 -4
- package/lib/src/http/handlers/typedAuthHandler.d.ts +0 -5
- package/lib/src/http/handlers/typedAuthHandler.d.ts.map +0 -1
- package/lib/src/http/handlers/typedAuthHandler.js +0 -3
- package/lib/src/http/handlers/typedHandler.d.ts +0 -21
- package/lib/src/http/handlers/typedHandler.d.ts.map +0 -1
- package/lib/src/http/handlers/typedHandler.js +0 -30
- package/lib/src/http/index.d.ts +0 -23
- package/lib/src/http/index.d.ts.map +0 -1
- package/lib/src/http/index.js +0 -22
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts +0 -24
- package/lib/src/http/interfaces/expressLikeRouter.interface.d.ts.map +0 -1
- package/lib/src/http/interfaces/expressLikeRouter.interface.js +0 -1
- package/lib/src/http/middleware/request/auth.middleware.d.ts +0 -16
- package/lib/src/http/middleware/request/auth.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/auth.middleware.js +0 -143
- package/lib/src/http/middleware/request/cors.middleware.d.ts +0 -13
- package/lib/src/http/middleware/request/cors.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/cors.middleware.js +0 -15
- package/lib/src/http/middleware/request/createContext.middleware.d.ts +0 -15
- package/lib/src/http/middleware/request/createContext.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/createContext.middleware.js +0 -26
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts +0 -15
- package/lib/src/http/middleware/request/enrichDetails.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/enrichDetails.middleware.js +0 -19
- package/lib/src/http/middleware/request/parse.middleware.d.ts +0 -17
- package/lib/src/http/middleware/request/parse.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/request/parse.middleware.js +0 -43
- package/lib/src/http/middleware/response/parse.middleware.d.ts +0 -31
- package/lib/src/http/middleware/response/parse.middleware.d.ts.map +0 -1
- package/lib/src/http/middleware/response/parse.middleware.js +0 -52
- package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts +0 -14
- package/lib/src/http/openApiV3Generator/openApiV3Generator.d.ts.map +0 -1
- package/lib/src/http/openApiV3Generator/openApiV3Generator.js +0 -169
- package/lib/src/http/router/expressLikeRouter.d.ts +0 -138
- package/lib/src/http/router/expressLikeRouter.d.ts.map +0 -1
- package/lib/src/http/router/expressLikeRouter.js +0 -483
- package/lib/src/http/types/apiDefinition.types.d.ts +0 -260
- package/lib/src/http/types/apiDefinition.types.d.ts.map +0 -1
- package/lib/src/http/types/apiDefinition.types.js +0 -1
- package/lib/src/http/types/contractDetails.types.d.ts +0 -211
- package/lib/src/http/types/contractDetails.types.d.ts.map +0 -1
- package/lib/src/http/types/contractDetails.types.js +0 -1
- package/lib/src/http/types/expressLikeRouter.types.d.ts +0 -51
- package/lib/src/http/types/expressLikeRouter.types.d.ts.map +0 -1
- package/lib/src/http/types/expressLikeRouter.types.js +0 -1
- package/lib/src/http/types/router.types.d.ts +0 -32
- package/lib/src/http/types/router.types.d.ts.map +0 -1
- package/lib/src/http/types/router.types.js +0 -1
- package/lib/src/http/types/typedHandler.types.d.ts +0 -10
- package/lib/src/http/types/typedHandler.types.d.ts.map +0 -1
- package/lib/src/http/types/typedHandler.types.js +0 -1
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts +0 -32
- package/lib/src/http/utils/enrichExpressLikeSend.d.ts.map +0 -1
- package/lib/src/http/utils/enrichExpressLikeSend.js +0 -50
- package/lib/src/http/utils/httpStatusCodes.d.ts +0 -75
- package/lib/src/http/utils/httpStatusCodes.d.ts.map +0 -1
- package/lib/src/http/utils/httpStatusCodes.js +0 -1039
- package/lib/src/services/configInjector.d.ts +0 -21
- package/lib/src/services/configInjector.d.ts.map +0 -1
- package/lib/src/services/configInjector.js +0 -90
- package/lib/src/services/index.d.ts +0 -5
- package/lib/src/services/index.d.ts.map +0 -1
- package/lib/src/services/index.js +0 -4
- package/lib/src/services/interfaces/baseService.d.ts +0 -15
- package/lib/src/services/interfaces/baseService.d.ts.map +0 -1
- package/lib/src/services/interfaces/baseService.js +0 -1
- package/lib/src/services/types/configInjector.types.d.ts +0 -25
- package/lib/src/services/types/configInjector.types.d.ts.map +0 -1
- package/lib/src/services/types/configInjector.types.js +0 -6
- package/lib/src/services/types/entityManager.types.d.ts +0 -4
- package/lib/src/services/types/entityManager.types.d.ts.map +0 -1
- package/lib/src/services/types/entityManager.types.js +0 -1
- package/lib/tests/configInjector.test.d.ts +0 -2
- package/lib/tests/configInjector.test.d.ts.map +0 -1
- package/lib/tests/configInjector.test.js +0 -105
- package/lib/tests/dtoMapper.test.d.ts +0 -2
- package/lib/tests/dtoMapper.test.d.ts.map +0 -1
- package/lib/tests/dtoMapper.test.js +0 -170
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts +0 -2
- package/lib/tests/expressLikeRouterInstantiation.test.d.ts.map +0 -1
- package/lib/tests/expressLikeRouterInstantiation.test.js +0 -118
- package/lib/tests/http.middleware.test.d.ts +0 -2
- package/lib/tests/http.middleware.test.d.ts.map +0 -1
- package/lib/tests/http.middleware.test.js +0 -102
- package/lib/tests/openApiV3Generator.test.d.ts +0 -2
- package/lib/tests/openApiV3Generator.test.d.ts.map +0 -1
- package/lib/tests/openApiV3Generator.test.js +0 -66
- package/lib/tests/redisTtlCache.test.d.ts +0 -2
- package/lib/tests/redisTtlCache.test.d.ts.map +0 -1
- package/lib/tests/redisTtlCache.test.js +0 -49
- package/lib/tests/typedHandler.test.d.ts +0 -2
- package/lib/tests/typedHandler.test.d.ts.map +0 -1
- package/lib/tests/typedHandler.test.js +0 -3
- package/lib/vitest.config.d.ts +0 -3
- package/lib/vitest.config.d.ts.map +0 -1
- package/lib/vitest.config.js +0 -7
@@ -1,102 +0,0 @@
|
|
1
|
-
import { literal, mockSchemaValidator, optional, union } from '@forklaunch/validator/tests/mockSchemaValidator';
|
2
|
-
import { cors } from '../src/http/middleware/request/cors.middleware';
|
3
|
-
import { createContext } from '../src/http/middleware/request/createContext.middleware';
|
4
|
-
import { enrichDetails } from '../src/http/middleware/request/enrichDetails.middleware';
|
5
|
-
import { parse as parseRequest } from '../src/http/middleware/request/parse.middleware';
|
6
|
-
import { parse as parseResponse } from '../src/http/middleware/response/parse.middleware';
|
7
|
-
describe('http middleware tests', () => {
|
8
|
-
let contractDetails;
|
9
|
-
let req;
|
10
|
-
let res;
|
11
|
-
const nextFunction = (err) => {
|
12
|
-
expect(err).toBeFalsy();
|
13
|
-
};
|
14
|
-
const testSchema = {
|
15
|
-
test: union(['a', optional(literal('test'))])
|
16
|
-
};
|
17
|
-
beforeEach(() => {
|
18
|
-
contractDetails = {
|
19
|
-
name: 'Test Contract',
|
20
|
-
summary: 'Test Contract Summary',
|
21
|
-
body: testSchema,
|
22
|
-
params: testSchema,
|
23
|
-
requestHeaders: testSchema,
|
24
|
-
query: testSchema,
|
25
|
-
responses: {
|
26
|
-
200: testSchema
|
27
|
-
}
|
28
|
-
};
|
29
|
-
req = {
|
30
|
-
method: 'POST',
|
31
|
-
context: {},
|
32
|
-
contractDetails: {},
|
33
|
-
schemaValidator: {},
|
34
|
-
params: testSchema,
|
35
|
-
headers: testSchema,
|
36
|
-
body: testSchema,
|
37
|
-
query: testSchema,
|
38
|
-
requestSchema: {
|
39
|
-
params: testSchema,
|
40
|
-
query: testSchema,
|
41
|
-
headers: testSchema,
|
42
|
-
body: testSchema
|
43
|
-
}
|
44
|
-
};
|
45
|
-
res = {
|
46
|
-
bodyData: testSchema,
|
47
|
-
statusCode: 200,
|
48
|
-
getHeaders: () => ({ 'x-correlation-id': '123' }),
|
49
|
-
setHeader: () => { },
|
50
|
-
status: () => ({
|
51
|
-
json: () => true,
|
52
|
-
jsonp: () => true,
|
53
|
-
send: () => { }
|
54
|
-
}),
|
55
|
-
end: () => { },
|
56
|
-
headersSent: false,
|
57
|
-
locals: {},
|
58
|
-
cors: true,
|
59
|
-
responseSchemas: {
|
60
|
-
headers: {
|
61
|
-
'x-correlation-id': '123'
|
62
|
-
},
|
63
|
-
responses: {
|
64
|
-
200: testSchema
|
65
|
-
}
|
66
|
-
}
|
67
|
-
};
|
68
|
-
});
|
69
|
-
test('cors middleware', async () => {
|
70
|
-
cors(req, res, nextFunction);
|
71
|
-
expect(res.cors).toBe(true);
|
72
|
-
});
|
73
|
-
test('create request context', async () => {
|
74
|
-
req.context = {};
|
75
|
-
req.schemaValidator = {};
|
76
|
-
createContext(mockSchemaValidator)(req, res, nextFunction);
|
77
|
-
expect(req.context.correlationId).not.toBe('123');
|
78
|
-
expect(req.schemaValidator).toBe(mockSchemaValidator);
|
79
|
-
});
|
80
|
-
test('request enrich details', async () => {
|
81
|
-
req.contractDetails = {};
|
82
|
-
enrichDetails(contractDetails, testSchema, {
|
83
|
-
headers: { 'x-correlation-id': '123' },
|
84
|
-
responses: {
|
85
|
-
200: testSchema
|
86
|
-
}
|
87
|
-
})(req, res, nextFunction);
|
88
|
-
expect(req.contractDetails).toEqual(contractDetails);
|
89
|
-
});
|
90
|
-
test('parse request', async () => {
|
91
|
-
createContext(mockSchemaValidator)(req, res, nextFunction);
|
92
|
-
parseRequest(req, res, nextFunction);
|
93
|
-
});
|
94
|
-
test('parse response', async () => {
|
95
|
-
createContext(mockSchemaValidator)(req, res, nextFunction);
|
96
|
-
parseResponse(req, res, nextFunction);
|
97
|
-
});
|
98
|
-
// TODO: enrich transmission response test
|
99
|
-
// Not supported yet
|
100
|
-
// test('Validate Auth', async () => {
|
101
|
-
// });
|
102
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"openApiV3Generator.test.d.ts","sourceRoot":"","sources":["../../tests/openApiV3Generator.test.ts"],"names":[],"mappings":""}
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import { literal, mockSchemaValidator, optional, union } from '@forklaunch/validator/tests/mockSchemaValidator';
|
2
|
-
import { generateSwaggerDocument } from '../src/http/openApiV3Generator/openApiV3Generator';
|
3
|
-
describe('openApiV3Generator tests', () => {
|
4
|
-
const testSchema = {
|
5
|
-
test: union(['a', optional(literal('test'))])
|
6
|
-
};
|
7
|
-
test('generate openApiV3', async () => {
|
8
|
-
const generatedOpenApiSpec = generateSwaggerDocument(mockSchemaValidator, 8000, [
|
9
|
-
{
|
10
|
-
basePath: '/api',
|
11
|
-
routes: [
|
12
|
-
{
|
13
|
-
basePath: '/test',
|
14
|
-
path: '/',
|
15
|
-
method: 'get',
|
16
|
-
contractDetails: {
|
17
|
-
name: 'Test Contract',
|
18
|
-
summary: 'Test Contract Summary',
|
19
|
-
body: testSchema,
|
20
|
-
params: testSchema,
|
21
|
-
requestHeaders: testSchema,
|
22
|
-
query: testSchema,
|
23
|
-
responses: {
|
24
|
-
200: testSchema
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
]
|
29
|
-
}
|
30
|
-
]);
|
31
|
-
expect(generatedOpenApiSpec).toEqual({
|
32
|
-
openapi: '3.1.0',
|
33
|
-
info: { title: '', version: '1.0.0' },
|
34
|
-
components: {
|
35
|
-
securitySchemes: {
|
36
|
-
bearer: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }
|
37
|
-
}
|
38
|
-
},
|
39
|
-
tags: [{ name: 'Api', description: 'Api Operations' }],
|
40
|
-
servers: [{ url: 'http://localhost:8000' }],
|
41
|
-
paths: {
|
42
|
-
'/api': {
|
43
|
-
get: {
|
44
|
-
tags: ['Api'],
|
45
|
-
summary: 'Test Contract: Test Contract Summary',
|
46
|
-
parameters: [
|
47
|
-
{ name: 'test', in: 'path' },
|
48
|
-
{ name: 'test', in: 'header' },
|
49
|
-
{ name: 'test', in: 'query' }
|
50
|
-
],
|
51
|
-
responses: {
|
52
|
-
'200': {
|
53
|
-
description: 'OK',
|
54
|
-
content: { 'application/json': { schema: {} } }
|
55
|
-
}
|
56
|
-
},
|
57
|
-
requestBody: {
|
58
|
-
required: true,
|
59
|
-
content: { 'application/json': { schema: {} } }
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
});
|
65
|
-
});
|
66
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"redisTtlCache.test.d.ts","sourceRoot":"","sources":["../../tests/redisTtlCache.test.ts"],"names":[],"mappings":""}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { GenericContainer } from 'testcontainers';
|
2
|
-
import { RedisTtlCache } from '../src/cache/redisTtlCache';
|
3
|
-
describe('redisTtlCache', () => {
|
4
|
-
let container;
|
5
|
-
let cache;
|
6
|
-
let key;
|
7
|
-
let value;
|
8
|
-
let ttlMilliseconds;
|
9
|
-
beforeAll(async () => {
|
10
|
-
container = await new GenericContainer('redis')
|
11
|
-
.withExposedPorts(6379)
|
12
|
-
.start();
|
13
|
-
cache = new RedisTtlCache(5000, {
|
14
|
-
url: `redis://${container.getHost()}:${container.getMappedPort(6379)}`
|
15
|
-
});
|
16
|
-
key = 'testKey';
|
17
|
-
value = { data: 'testValue' };
|
18
|
-
ttlMilliseconds = 1000;
|
19
|
-
}, 30000);
|
20
|
-
afterAll(async () => {
|
21
|
-
await cache.disconnect();
|
22
|
-
await container.stop();
|
23
|
-
});
|
24
|
-
it('put', async () => {
|
25
|
-
await cache.putRecord({ key, value, ttlMilliseconds });
|
26
|
-
});
|
27
|
-
test('read', async () => {
|
28
|
-
const storedValue = await cache.readRecord(key);
|
29
|
-
expect(storedValue).toEqual({
|
30
|
-
key,
|
31
|
-
ttlMilliseconds,
|
32
|
-
value
|
33
|
-
});
|
34
|
-
});
|
35
|
-
test('peek', async () => {
|
36
|
-
const exists = await cache.peekRecord(key);
|
37
|
-
expect(exists).toBeTruthy();
|
38
|
-
});
|
39
|
-
test('delete', async () => {
|
40
|
-
await cache.deleteRecord(key);
|
41
|
-
const existsAfterDelete = await cache.peekRecord(key);
|
42
|
-
expect(existsAfterDelete).toBeFalsy();
|
43
|
-
});
|
44
|
-
test('check no record after ttl', async () => {
|
45
|
-
await Promise.resolve(setTimeout(async () => { }, ttlMilliseconds));
|
46
|
-
const existsAfterTtl = await cache.peekRecord(key);
|
47
|
-
expect(existsAfterTtl).toBeFalsy();
|
48
|
-
});
|
49
|
-
});
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"typedHandler.test.d.ts","sourceRoot":"","sources":["../../tests/typedHandler.test.ts"],"names":[],"mappings":""}
|
package/lib/vitest.config.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAEA,wBAKG"}
|