1.0.3 • Published 2 years ago

tarant-sync-router-express v1.0.3

Weekly downloads
61
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.2.96

2 years ago

0.2.95

2 years ago

0.2.94

2 years ago

0.2.93

2 years ago

0.2.92

2 years ago

0.2.91

2 years ago

0.2.90

2 years ago

0.2.99

2 years ago

0.2.98

2 years ago

0.2.97

2 years ago

0.2.89

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.100

2 years ago

0.2.85

3 years ago

0.2.84

3 years ago

0.2.83

3 years ago

0.2.82

3 years ago

0.2.81

3 years ago

0.2.80

3 years ago

0.2.88

3 years ago

0.2.87

3 years ago

0.2.86

3 years ago

0.2.79

3 years ago

0.2.78

3 years ago

0.2.77

3 years ago

0.2.76

3 years ago

0.2.75

3 years ago

0.2.69

3 years ago

0.2.74

3 years ago

0.2.73

3 years ago

0.2.72

3 years ago

0.2.71

3 years ago

0.2.70

3 years ago

0.2.68

3 years ago

0.2.67

3 years ago

0.2.66

3 years ago

0.2.65

3 years ago

0.2.64

3 years ago

0.2.63

4 years ago

0.2.62

4 years ago

0.2.61

4 years ago

0.2.60

4 years ago

0.2.59

4 years ago

0.2.58

5 years ago

0.2.57

5 years ago

0.2.56

5 years ago

0.2.55

5 years ago

0.2.54

5 years ago

0.2.53

5 years ago

0.2.52

5 years ago

0.2.51

5 years ago

0.2.50

5 years ago

0.2.49

5 years ago

0.2.48

5 years ago

0.2.47

5 years ago

0.2.46

5 years ago

0.2.45

5 years ago

0.2.44

5 years ago

0.2.43

5 years ago

0.2.42

5 years ago

0.2.41

5 years ago

0.2.40

5 years ago

0.2.39

5 years ago

0.2.38

5 years ago

0.2.37

5 years ago

0.2.36

5 years ago

0.2.35

5 years ago

0.2.34

5 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.30

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

0.2.27

5 years ago

0.2.26

5 years ago

0.2.25

5 years ago

0.2.24

5 years ago

0.2.23

5 years ago

0.2.22

5 years ago

0.2.21

5 years ago

0.2.20

5 years ago

0.2.19

5 years ago

0.2.18

5 years ago

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.9

5 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.1

6 years ago

0.2.2

6 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago