-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,682 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
packages/nestjs-cache/src/__fixtures__/factories/user-cache.factory.fixture.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
export const CACHE_MODULE_SETTINGS_TOKEN = 'CACHE_MODULE_SETTINGS_TOKEN'; | ||
|
||
export const CACHE_MODULE_REPOSITORIES_TOKEN = | ||
'CACHE_MODULE_REPOSITORIES_TOKEN'; | ||
|
||
export const CACHE_MODULE_CRUD_SERVICES_TOKEN = | ||
'CACHE_MODULE_CRUD_SERVICES_TOKEN'; | ||
|
||
export const CACHE_MODULE_DEFAULT_SETTINGS_TOKEN = | ||
'CACHE_MODULE_DEFAULT_SETTINGS_TOKEN'; | ||
|
||
export const CACHE_MODULE_CACHE_ENTITY_KEY = 'cache'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/nestjs-cache/src/exceptions/cache-assignment-not-found.exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 13 additions & 10 deletions
23
packages/nestjs-cache/src/exceptions/cache-assignment-not-found.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...ptions/entity-not-found.exception.spec.ts → .../cache-entity-not-found.exception.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { EntityNotFoundException } from './entity-not-found.exception'; | ||
import { CacheEntityNotFoundException } from './cache-entity-not-found.exception'; | ||
|
||
describe(EntityNotFoundException.name, () => { | ||
describe(CacheEntityNotFoundException.name, () => { | ||
it('should create an instance of EntityNotFoundException', () => { | ||
const exception = new EntityNotFoundException('TestEntity'); | ||
expect(exception).toBeInstanceOf(EntityNotFoundException); | ||
const exception = new CacheEntityNotFoundException('TestEntity'); | ||
expect(exception).toBeInstanceOf(CacheEntityNotFoundException); | ||
}); | ||
|
||
it('should have the correct error message', () => { | ||
const exception = new EntityNotFoundException('TestEntity'); | ||
const exception = new CacheEntityNotFoundException('TestEntity'); | ||
expect(exception.message).toBe( | ||
'Entity TestEntity was not registered to be used.', | ||
); | ||
}); | ||
|
||
it('should have the correct context', () => { | ||
const exception = new EntityNotFoundException('TestEntity'); | ||
const exception = new CacheEntityNotFoundException('TestEntity'); | ||
expect(exception.context).toEqual({ entityName: 'TestEntity' }); | ||
}); | ||
|
||
it('should have the correct error code', () => { | ||
const exception = new EntityNotFoundException('TestEntity'); | ||
const exception = new CacheEntityNotFoundException('TestEntity'); | ||
expect(exception.errorCode).toBe('CACHE_ENTITY_NOT_FOUND_ERROR'); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/nestjs-cache/src/exceptions/cache-entity-not-found.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RuntimeException } from '@concepta/nestjs-exception'; | ||
|
||
export class CacheEntityNotFoundException extends RuntimeException { | ||
context: RuntimeException['context'] & { | ||
entityName: string; | ||
}; | ||
|
||
constructor( | ||
entityName: string, | ||
message = 'Entity %s was not registered to be used.', | ||
) { | ||
super({ | ||
message, | ||
messageParams: [entityName], | ||
}); | ||
|
||
this.errorCode = 'CACHE_ENTITY_NOT_FOUND_ERROR'; | ||
|
||
this.context = { | ||
...super.context, | ||
entityName, | ||
}; | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
packages/nestjs-cache/src/exceptions/cache-type-not-defined.exception.spec.ts
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
packages/nestjs-cache/src/exceptions/cache-type-not-defined.exception.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.