0.0.82 • Published 5 months ago

@alien-worlds/alienworlds-api-common v0.0.82

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

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)

NameTypeLayerDescription
AssetEntitydomain
AssetRepositoryRepository abstractiondomain
AssetMongoSourceData sourcedatamongodb data source used in the repository
AssetMapperMapperdataconverts dto to entity and vice versa
AssetSmartContractDataEntitydomain
AssetSmartContractRepositoryRepository abstractiondomain
AssetSmartContractRepositoryImplRepository implementationdata
bindAssetRepositoryIOC configbind helper - requires MongoSource instance
bindAssetSmartContractRepositoryIOC configbind helper - requires EosRpcSource instance and code string

AtomicTransfers (MongoDB collection)

NameTypeLayerDescription
AtomicTransferEntitydomain
AtomicTransferRepositoryRepository abstractiondomain
AtomicTransferMongoSourceData sourcedatamongodb data source used in the repository
AtomicTransferMapperMapperdataconverts dto to entity and vice versa
bindAtomicTransferRepositoryIOC configbind helper - requires MongoSource instance

Mines (MongoDB collection)

NameTypeLayerDescription
MineEntitydomain
MineRepositoryRepository abstractiondomain
MineMongoSourceData sourcedatamongodb data source used in the repository
MineMapperMapperdataconverts dto to entity and vice versa
bindMineRepositoryIOC configbind helper - requires MongoSource instance

NFTs (MongoDB collection)

NameTypeLayerDescription
NftEntitydomain
NftRepositoryRepository abstractiondomain
NftMongoSourceData sourcedatamongodb data source used in the repository
NftMapperMapperdataconverts dto to entity and vice versa
bindNftRepositoryIOC configbind helper - requires MongoSource instance

Schemas (Smart contract table row)

NameTypeLayerDescription
SchemaSmartContractDataEntitydomain
SchemaSmartContractRepositoryRepository abstractiondomain
SchemaSmartContractRepositoryImplRepository implementationdata
bindSchemaSmartContractRepositoryIOC configbind helper - requires EosRpcSource instance and code string

Templates (Smart contract table row)

NameTypeLayerDescription
TemplateSmartContractDataEntitydomain
TemplateSmartContractRepositoryRepository abstractiondomain
TemplateSmartContractRepositoryImplRepository implementationdata
bindTemplateSmartContractRepositoryIOC configbind 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