Giter Site home page Giter Site logo

tom-example's Introduction

tom-example

backoffice microservice example powered by tom-microservice

Getting started

You need to install the project dependencies with npm install

Then you are ready to run tom ๐Ÿถ

Configuration

Defining basic configuration

Your configuration project live at tom.config.js.

Under the hood we are using config for differenciate between development and production credentials.

Using Event System

Notes that every time an action was called, it will be emit an event. You can use this event for connect the service with your specific code:

  tom.on('payment:create', data => {
    console.log('payment:create', data)
  })

  tom.on('payment:update', data => {
    console.log('payment:update', data)
  })

  tom.on('notification', data => {
    console.log('notification', data)
    return {foo: 'bar'}
  })

  tom.on('notification:email', data => {
    console.log('notification:email', data)
    return {hello: 'bar'}
  })

  tom.on('*', (data) => {
    console.log('global notification', data)
    return {kiko: 'bar'}
  })

The payload that you return in each event will be print by the command execution, for example:

$ tom --command=notification.email --templateId=summary [email protected] --username=Leo

will be print the following log:

notification:email [email protected] [email protected] subject='[hyperping.io] Weekly Report' [email protected] preview=https://ethereal.email/message/W1ZFkRVUhwyoi4LGW1bVFavoFgz2lN8AAAAAev9pdp8u5UhfRuVObjtoDPU kiko=bar foo=bar hello=bar

Launch

from CLI

Just run npx tom passing the flags for execute a certain command, for example:

npx tom --command=notification.email --templateId=summary [email protected] --username=Leo

You can use tom --help or see scripts to see it in action.

from HTTP microservice

Running npm run dev start a development HTTP server in your machine.

Execute for started a HTTP server in your machine. The server has hot reloading.

Production Ready

You can deploy tom ๐Ÿถ to production after attach the following information at config/production.yaml

After that, just run your service with npm start ๐ŸŽ‰

Check Environment Variables section in the doc in case you want to associate a port or and API key for protect your microservice for external requests.

tom-example's People

Contributors

kikobeats avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.