JSPM

  • Created
  • Published
  • Downloads 993
  • Score
    100M100P100Q105095F
  • License MIT

A Postgres persistence adapter for workflow storage in @node-ts/bus-workflow.

Package Exports

  • @node-ts/bus-postgres

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@node-ts/bus-postgres) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@node-ts/bus-postgres

Greenkeeper badge CircleCI

A Postgrres based persistence for workflow storage.

Installation

Install all packages and their dependencies

npm i reflect-metadata inversify @node-ts/bus-postgres @node-ts/bus-core @node-ts/bus-workflow

Once installed, load the BusPostgresModiule to your inversify container alongside the other modules it depends on:

import { Container } from 'inversify'
import { LoggerModule } from '@node-ts/logger-core'
import { BusModule } from '@node-ts/bus-core'
import { WorkflowModule } from '@node-ts/bus-workflow'
import { BUS_POSTGRES_SYMBOLS, BusPostgresModule } from '@node-ts/bus-postgres'

const container = new Container()
container.load(new LoggerModule())
container.load(new BusModule())
container.load(new BusPostgresModule())

const configuration: PostgresConfiguration = {
  connection: {
    connectionString: 'postgres://postgres:password@localhost:5432/postgres'
  },
  schemaName: 'workflows'
}
container.bind(BUS_POSTGRES_SYMBOLS.PostgresConfiguration).toConstantValue(configuration)

// Run the application
const application = async () => {
    workflows = container.get<WorkflowRegistry>(BUS_WORKFLOW_SYMBOLS.WorkflowRegistry)
    workflows.register(TestWorkflow, TestWorkflowData) // Register all workflows here
    await workflows.initializeWorkflows()

    bootstrap = container.get<ApplicationBootstrap>(BUS_SYMBOLS.ApplicationBootstrap)
    await bootstrap.initialize(container)
}
application
  .then(() => void)

Development

Local development can be done with the aid of docker to run the required infrastructure. To do so, run:

docker run --name bus-postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres