# Registry Class private
Module | import { Registry } from "@tsed/core" |
---|---|
Source | /packages/core/src/class/Registry.ts |
# Overview
class Registry<T, O> extends Map<RegistryKey, T> {
/**
*
* @param <span class="token punctuation">{</span><a href="/api/core/interfaces/Type.html"><span class="token">Type</span></a><T><span class="token punctuation">}</span> _class
* @param <span class="token punctuation">{</span><a href="/api/core/class/RegistryHook.html"><span class="token">RegistryHook</span></a><T><span class="token punctuation">}</span> options
*/
<span class="token keyword">constructor</span><span class="token punctuation">(</span>_class<span class="token punctuation">:</span> <a href="/api/core/interfaces/Type.html"><span class="token">Type</span></a><T><span class="token punctuation">,</span> options?<span class="token punctuation">:</span> <a href="/api/core/class/RegistryHook.html"><span class="token">RegistryHook</span></a><T><span class="token punctuation">)</span><span class="token punctuation">;</span>
/**
* The <span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span> method returns a specified element <span class="token keyword">from</span> a Map object.
* @param key <a href="/api/common/mvc/decorators/Required.html"><span class="token">Required</span></a>. The key of the element to return <span class="token keyword">from</span> the Map object.
* @returns <span class="token punctuation">{</span>T<span class="token punctuation">}</span> <a href="/api/common/mvc/decorators/method/Returns.html"><span class="token">Returns</span></a> the element associated with the specified key or undefined if the key can't be found in the Map object.
*/
<span class="token function">get</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> T | undefined<span class="token punctuation">;</span>
/**
*
* @param key
*/
<span class="token function">createIfNotExists</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> T<span class="token punctuation">;</span>
/**
* The <span class="token function">has</span><span class="token punctuation">(</span><span class="token punctuation">)</span> method returns a <span class="token keyword">boolean</span> indicating whether an element with the specified key exists or not.
* @param key
* @returns <span class="token punctuation">{</span><span class="token keyword">boolean</span><span class="token punctuation">}</span>
*/
<span class="token function">has</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>
/**
* The <span class="token function">set</span><span class="token punctuation">(</span><span class="token punctuation">)</span> method adds or updates an element with a specified key and value to a Map object.
* @param key <a href="/api/common/mvc/decorators/Required.html"><span class="token">Required</span></a>. The key of the element to add to the Map object.
* @param metadata <a href="/api/common/mvc/decorators/Required.html"><span class="token">Required</span></a>. The value of the element to add to the Map object.
* @returns <span class="token punctuation">{</span>Registry<span class="token punctuation">}</span>
*/
<span class="token function">set</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">,</span> metadata<span class="token punctuation">:</span> T<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
/**
*
* @param target
* @param options
*/
<span class="token function">merge</span><span class="token punctuation">(</span>target<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">,</span> options<span class="token punctuation">:</span> Partial<O><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>
/**
* The <span class="token function">delete</span><span class="token punctuation">(</span><span class="token punctuation">)</span> method removes the specified element <span class="token keyword">from</span> a Map object.
* @param key <a href="/api/common/mvc/decorators/Required.html"><span class="token">Required</span></a>. The key of the element to remove <span class="token keyword">from</span> the Map object.
* @returns <span class="token punctuation">{</span><span class="token keyword">boolean</span><span class="token punctuation">}</span> <a href="/api/common/mvc/decorators/method/Returns.html"><span class="token">Returns</span></a> true if an element in the Map object existed and has been removed<span class="token punctuation">,</span> or false if the element does not exist.
*/
<span class="token function">delete</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>
}
# Members
get(key: RegistryKey): T | undefined;
Param | Type | Description |
---|---|---|
key | <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a> | Required. The key of the element to return from the Map object. |
The get() method returns a specified element from a Map object.
createIfNotExists(key: RegistryKey): T;
has(key: RegistryKey): boolean;
The has() method returns a boolean indicating whether an element with the specified key exists or not.
set(key: RegistryKey, metadata: T): this;
Param | Type | Description |
---|---|---|
key | <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a> | Required. The key of the element to add to the Map object. metadata |
The set() method adds or updates an element with a specified key and value to a Map object.
merge(target: RegistryKey, options: Partial<O>): void;
delete(key: RegistryKey): boolean;
Param | Type | Description |
---|---|---|
key | <a href="/api/core/class/RegistryKey.html"><span class="token">RegistryKey</span></a> | Required. The key of the element to remove from the Map object. |
The delete() method removes the specified element from a Map object.
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing