1.0.3 • Published 11 months ago

tarant-sync-router-express v1.0.3

Weekly downloads
61
License
MIT
Repository
github
Last release
11 months ago

logomakr_0zeodi

npm Build Status Coverage Status PRs Welcome issues Welcome npm GitHub issues GitHub pull requests Downloads

Motivation

remote-sync server for bindings clients using routers or tarant-sync-router-express

Installation

add it to your project using npm install tarant-sync-router-express --save or yarn add tarant-sync-router-express

Usage

initialize your controllers/routers by calling the SyncController with the actor system and the wanted configuration. Adding them to your express app.

import SyncController from "tarant-sync-router-express"
import { ActorSystem, ActorSystemConfigurationBuilder } from 'tarant'
import AppActor from '../AppActor'

const app: express.Application = express()
const port: number = 3002
const config : any  = {
      paths: {
          pull: "/pull", 
          push: "/push", 
      },
      actorTypes: { AppActor }
}

const system : any = ActorSystem.for(ActorSystemConfigurationBuilder.define().done())  

app.use(SyncController(system, config))

app.listen(port, () => {
    console.log(`Listening at http://localhost:${port}/`)
})

your actors will require to implement IUpdatable (UpdateFrom) and IExportable (toJson)

import { Actor } from "tarant";
import { IUpdatable, IExportable } from "tarant-sync-router-express"

export default class AppActor extends Actor implements IUpdatable, IExportable {

  constructor(name: string) {
      super(name)
  }

  addOne() {
      this.counter++
  }

  toJson(){
        return {
            id: this.id,
            type:"AppActor",
            counter: this.counter
        }
    }

    updateFrom({ counter }: any): void {
        this.counter = counter
    }

    private counter = 1; 
}

confiuration options

  1. paths.pull: path to endpoint for pulling data from the backend
  2. paths.push: path to endpoint for pushing data to the backend
  3. ActorTypes: objects registering the type of actors that should be sync with the backend
Created my free logo at LogoMakr.com
1.0.3

11 months ago

0.2.96

1 year ago

0.2.95

1 year ago

0.2.94

1 year ago

0.2.93

1 year ago

0.2.92

1 year ago

0.2.91

1 year ago

0.2.90

1 year ago

0.2.99

1 year ago

0.2.98

1 year ago

0.2.97

1 year ago

0.2.89

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.100

1 year ago

0.2.85

1 year ago

0.2.84

1 year ago

0.2.83

1 year ago

0.2.82

1 year ago

0.2.81

1 year ago

0.2.80

1 year ago

0.2.88

1 year ago

0.2.87

1 year ago

0.2.86

1 year ago

0.2.79

2 years ago

0.2.78

2 years ago

0.2.77

2 years ago

0.2.76

2 years ago

0.2.75

2 years ago

0.2.69

2 years ago

0.2.74

2 years ago

0.2.73

2 years ago

0.2.72

2 years ago

0.2.71

2 years ago

0.2.70

2 years ago

0.2.68

2 years ago

0.2.67

2 years ago

0.2.66

2 years ago

0.2.65

2 years ago

0.2.64

2 years ago

0.2.63

3 years ago

0.2.62

3 years ago

0.2.61

3 years ago

0.2.60

3 years ago

0.2.59

3 years ago

0.2.58

3 years ago

0.2.57

3 years ago

0.2.56

3 years ago

0.2.55

3 years ago

0.2.54

3 years ago

0.2.53

3 years ago

0.2.52

3 years ago

0.2.51

3 years ago

0.2.50

3 years ago

0.2.49

4 years ago

0.2.48

4 years ago

0.2.47

4 years ago

0.2.46

4 years ago

0.2.45

4 years ago

0.2.44

4 years ago

0.2.43

4 years ago

0.2.42

4 years ago

0.2.41

4 years ago

0.2.40

4 years ago

0.2.39

4 years ago

0.2.38

4 years ago

0.2.37

4 years ago

0.2.36

4 years ago

0.2.35

4 years ago

0.2.34

4 years ago

0.2.33

4 years ago

0.2.32

4 years ago

0.2.31

4 years ago

0.2.30

4 years ago

0.2.29

4 years ago

0.2.28

4 years ago

0.2.27

4 years ago

0.2.26

4 years ago

0.2.25

4 years ago

0.2.24

4 years ago

0.2.23

4 years ago

0.2.22

4 years ago

0.2.21

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago