Skip to content

Latest commit

 

History

History
88 lines (66 loc) · 4.1 KB

CONTRIBUTING.md

File metadata and controls

88 lines (66 loc) · 4.1 KB

Please, feel free to create PRs with suggestion & improvements of that document.

Information

This file describes everything you need to know for writing code in a way we do it. Morever, here you'll find all basic answers how to start & develop.

We have special issue for those who want to join. We (and world) need you :)

To write the code

Follow style guidelines & folder structure; stay passionate and code,

  • You can contribute straight away, no need to wait - create your PR,
  • Contact any collaborator for adding your to contributors list.

Style guidelines

TODO: split this in sections

  • Typescript means types whenever possible,
  • prefer arrow functions,
  • prefer functional type of coding,
  • try to avoid side effects,
  • no camel case,

Folder structure

  1. `*/src/bots/[messangerPlatform]`

Only contains platform related logic (e.g. .env file; sending messages; platform related interface adaption).

Take a look into server/bots/telegram/* for an example.

  1. `*/src/models/*`

Contains models used in application (regardless of a platform it's running (Telegram, Viber ... ))

  1. `*/src/routes/*`

Leave for now.

  1. `*/src/services/*`

    - `/api`. Only responsible for API calls, - `/domain`. Has all domain-specific logic (data mapping, resolving), - `/utils`. Service helpers. - todo? `/`
  2. `*/src/models/utils*`

    - `*/messages` User message representation (should not be dependent on any platform), - `utils.ts` Infrastructure helpers, - `[helperFunction].ts` Have project wide helpers (e.g. _deepCopy_, _isEqual_ etc.). If you want to create new helper function - create file `[helperFunctionName].ts` for that.

All inner folder's structure preferebly should follow structure above (fine-grained approach).

Running for development

Prerequirements

Checked, that the application works with

  • Node version v10.16.0
  • npm version 6.9.0

on Windows 10, x64 machine

Telegram
  • Open BotFather,
  • Create your development version of the bot (for your local testing purpose) via /newbot command
  • Receive from BotFather Key & Copy it,
  • Create .env in /server/src/bots/telegram file and add received key there (more about it in README, example file),
  • Add to the project,
  • run npm i
  • run npm run start:watch, npm run start:inspect for debugging (Useful link)
Viber

Follow the official doc

  • After bot creation add API key to the .env. Take a look in example file for more information
  • run npm i
  • run npm run start:watch, npm run start:inspect for debugging (Useful link)

Hints

  • If you're running locally, you can run ngrok http 3000 copy https url paste to APP_URL env variable and reloading will be faster and cheaper for CPU
If any questions and/or issues,

Restrictions and Limitations

For running the application we need to have secure connection (as some all known messengers do not support running via http) thus we are using ngrok library for that, currently. It creates public domain with secured connection with we are using for redirecting all messages to our local machines.