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
// Usually comes in `convectorController.ts` | |
// Example https://github.com/worldsibu/convector-example-drug-supply-chain/blob/6e512bec355e41a4f52dfaec9a731bbcceadd0f9/%40worldsibu/server/src/convectorUtils/convectorControllers.ts#L24 | |
await SelfGenContext.getClient(); | |
const adapter = new FabricControllerAdapter({ | |
txTimeout: 300000, | |
user: user, | |
// set it later to enable Mutual TLS | |
channel: process.env.CHANNEL, | |
chaincode: process.env.CHAINCODE, |
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
import { | |
Controller, | |
ConvectorController, | |
Invokable, | |
Param | |
} from '@worldsibu/convector-core'; | |
import * as yup from 'yup'; | |
import { Mybuggychaincode } from './mybuggychaincode.model'; | |
@Controller('mybuggychaincode') |
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
import * as yup from 'yup'; | |
import { | |
ConvectorModel, ReadOnly, Required, Validate | |
} from '@worldsibu/convector-core-model'; | |
export class ExampleModel extends ConvectorModel<ExampleModel> { | |
@ReadOnly() | |
@Validate(yup.string()) | |
public readonly type = 'io.worldsibu.examples.example-model'; |
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
import * as yup from 'yup'; | |
import { | |
ConvectorModel, | |
ReadOnly, | |
Required, | |
Validate, | |
Default, | |
FlatConvectorModel | |
} from '@worldsibu/convector-core-model'; | |
import { Report } from './report.model'; |
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
import * as yup from 'yup'; | |
import { | |
Controller, ConvectorController, Invokable, Param | |
} from '@worldsibu/convector-core-controller'; | |
@Controller('test-controller') | |
export class TestController extends ConvectorController { | |
@Invokable() | |
public async init( @Param(yup.string()) token: Token ) { | |
// code |
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
@Controller('token') | |
export class TokenController extends ConvectorController { | |
@Invokable() | |
public async transfer( | |
@Param(yup.string()) to: string, | |
@Param(yup.number()) amount: number | |
) { | |
const token = await Token.getOne('TKN'); | |
// Validation phase |
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
import * as yup from 'yup'; | |
import { | |
ConvectorModel, | |
ReadOnly, | |
Required, | |
Validate, | |
Default, | |
FlatConvectorModel | |
} from '@worldsibu/convector-core'; |
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
@Validate(yup.lazy(() => Report.schema())) | |
public report?: FlatConvectorModel<Report>; | |
@Validate(yup.lazy(() => yup.array(Report.schema()))) | |
public reports?: Array<FlatConvectorModel<Report>>; |
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
import * as yup from 'yup'; | |
import { | |
ConvectorModel, | |
ReadOnly, | |
Required, | |
Validate, | |
Default, | |
FlatConvectorModel | |
} from '@worldsibu/convector-core'; | |
export class Report extends ConvectorModel<Report> { |
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
// Get one of the models based on the ID | |
MyModel.getOne(id).then(onModelFound); | |
// Get all the elements based on the `type` field | |
MyModel.getAll('io.worldsibu.models.test').then(onModelsFound); | |
// Complex queries, depending on the `convector-storage` in use | |
MyModel.query({ amount: { $lte: 5 } }).then(onModelsFound); |
OlderNewer