@alien-worlds/alienworlds-api-common
v0.0.82
Published
Components used in both the Alien Worlds API and history tools. Package contains repositories, services and entities for various mongodb collections and smart contract tables rows. The binding functions are used to simplify the injection of these componen
Downloads
5
Keywords
Readme
alienworlds-api-common
Components used in both the Alien Worlds API and history tools. Package contains repositories, services and entities for various mongodb collections and smart contract tables rows. The binding functions are used to simplify the injection of these components in your code.
Content
Assets (MongoDB collection and Smart contract table row)
| Name | Type | Layer | Description |
| :--------------------------------- | :------------------------------ | :------: | ---------------------------------------------------------------- |
| Asset
| Entity | domain | |
| AssetRepository
| Repository abstraction | domain | |
| AssetMongoSource
| Data source | data | mongodb data source used in the repository |
| AssetMapper
| Mapper | data | converts dto
to entity
and vice versa |
| AssetSmartContractData
| Entity | domain | |
| AssetSmartContractRepository
| Repository abstraction | domain | |
| AssetSmartContractRepositoryImpl
| Repository implementation | data | |
| bindAssetRepository
| IOC config | | bind helper - requires MongoSource
instance |
| bindAssetSmartContractRepository
| IOC config | | bind helper - requires EosRpcSource
instance and code
string |
AtomicTransfers (MongoDB collection)
| Name | Type | Layer | Description |
| :----------------------------- | :--------------------------- | :------: | --------------------------------------------- |
| AtomicTransfer
| Entity | domain | |
| AtomicTransferRepository
| Repository abstraction | domain | |
| AtomicTransferMongoSource
| Data source | data | mongodb data source used in the repository |
| AtomicTransferMapper
| Mapper | data | converts dto
to entity
and vice versa |
| bindAtomicTransferRepository
| IOC config | | bind helper - requires MongoSource
instance |
Mines (MongoDB collection)
| Name | Type | Layer | Description |
| :------------------- | :--------------------------- | :------: | --------------------------------------------- |
| Mine
| Entity | domain | |
| MineRepository
| Repository abstraction | domain | |
| MineMongoSource
| Data source | data | mongodb data source used in the repository |
| MineMapper
| Mapper | data | converts dto
to entity
and vice versa |
| bindMineRepository
| IOC config | | bind helper - requires MongoSource
instance |
NFTs (MongoDB collection)
| Name | Type | Layer | Description |
| :------------------ | :--------------------------- | :------: | --------------------------------------------- |
| Nft
| Entity | domain | |
| NftRepository
| Repository abstraction | domain | |
| NftMongoSource
| Data source | data | mongodb data source used in the repository |
| NftMapper
| Mapper | data | converts dto
to entity
and vice versa |
| bindNftRepository
| IOC config | | bind helper - requires MongoSource
instance |
Schemas (Smart contract table row)
| Name | Type | Layer | Description |
| :---------------------------------- | :------------------------------ | :------: | ---------------------------------------------------------------- |
| SchemaSmartContractData
| Entity | domain | |
| SchemaSmartContractRepository
| Repository abstraction | domain | |
| SchemaSmartContractRepositoryImpl
| Repository implementation | data | |
| bindSchemaSmartContractRepository
| IOC config | | bind helper - requires EosRpcSource
instance and code
string |
Templates (Smart contract table row)
| Name | Type | Layer | Description |
| :------------------------------------ | :------------------------------ | :------: | ---------------------------------------------------------------- |
| TemplateSmartContractData
| Entity | domain | |
| TemplateSmartContractRepository
| Repository abstraction | domain | |
| TemplateSmartContractRepositoryImpl
| Repository implementation | data | |
| bindTemplateSmartContractRepository
| IOC config | | bind helper - requires EosRpcSource
instance and code
string |
Usage
To use these components in your code, add this package as a dependency using your Node package manager
yarn add @alien-worlds/alienworlds-api-common
You can inject the code with the binding functions or by yourself. In the ioc.config
file in your project, add the component of interest to you, remembering to initialize all the source needs in advance, e.g. MongoDB or JsonRpc Api
// with binding functions
import { bindStateRepository } from '@alien-worlds/alienworlds-api-common';
// ...
await client.connect();
const db = client.db(dbName);
const mongoSource = new MongoSource(db);
bindStateRepository(container, mongoSource);
// or without
import {
StateRepositoryImpl,
StateRepository,
StateMongoSource,
StateMapper,
} from '@alien-worlds/alienworlds-api-common';
// ...
await client.connect();
const db = client.db(dbName);
const mongoSource = new MongoSource(db);
const stateRepositoryImpl = new StateRepositoryImpl(
new StateMongoSource(mongoSource),
new StateMapper()
);
container
.bind<StateRepository>(StateRepository.Token)
.toConstantValue(stateRepositoryImpl);
Deployment
If you want to release a new version of this package, just run deploy.sh
from the main project folder.
# patches version by default
sh scripts/deploy.sh
# Optionally, you can specify the version or what kind of update is (major|minor|patch)
# e.g.
sh scripts/deploy.sh 1.2.3
# or
sh scripts/deploy.sh major
This script will:
- start the typeScript compiler
- pull latest changes from the repository
- bump the version in the
package.json
file - create a commit and push it to the repository
- publish the new version to the registry (if all the previous steps have been completed successfully)
Before running the script, be sure that you have a clean situation and the latest changes from the repository so that there are no conflicts