Skip to main content

API

1. Annotation/Decorator#

/** * Decorate cell with meta data. */@Cell(cellMeta: CellMeta)

(For detail information about Cell decorator, you can read here).

/** * Mark class as service handler. */@Service(serviceMeta: ServiceMeta);

(For detail information about Service decorator, you can read here).

2. Virtual network-related APIs#

createNetWork(networkConfig: NetworkConfig): Promise<void>;
getResolvedCell(cellName: string): ResolvedCell | undefined;

3. Service-related APIs#

/** * @see https://cellularjs.com/docs/foundation/net/service/#41-service-proxy */addServiceProxies(service, proxies: ClassType<ServiceHandler>[]): void;
/** * @see https://cellularjs.com/docs/foundation/net/service#42-service-providers */addServiceProviders(service, providers: GenericProvider[]): void;

4. Transporter-related APIs#

/** * Send Internal Request and get Internal Response. */send(irq: IRQ, requestOpts?: RequestOptions): Promise<IRS>;
/** * This variable allow you to tweak request data through request life cycle * @see https://cellularjs.com/docs/foundation/net/transporter/#4-request-lifecyle */const transportListener: TransportListener;

5. Types#

5.1. NetworkConfig#

NetworkConfig = CellConfig[];

5.2. CellConfig#

NameTypeRequiredDefaultDescription
namestringTrueCell name or cell type, it must be unique.
spacestringFalseSpace is where your service placed, read more....
driver{ new() }; { [driverName: string]: { new() } }TrueDriver is a thing that handle request, read more....
customData{ [key: string]: any }FalseIn additional to reserved property defined by CellConfig, you can add more custom data with this property. You can get this data via getResolvedCell.

5.3. CellMeta#

NameTypeRequiredDefaultDescription
providers(GenericProvider, string)[]FalseDeclare providers for resolving dependency later. For more information, have a look at DI API.
importsImportableCnf[]FalseImport module into current cell.
listenstring, { [key: string]: ServiceHandler }TrueRegister services into cell, read more....

5.4. ServiceMeta#

NameTypeRequiredDefaultDescription
scope'publish', 'space', 'private'False'space'Service handler access scope:
- 'publish': accessible from anywhere.
- 'space': limit access to the cell with the same space only.
- 'private': limit access to the cell only.

5.5. RequestOptions#

NameTypeRequiredDefaultDescription
driverstringFalse'local'Driver to handle this request, read more....
throwOriginalErrorbooleanFalseundefined ~ falseBy default, all exception will be converted into IRS(error response). You can use this option for quick debugging, read more....