Code Monkey home page Code Monkey logo

ta-vivo-api's Introduction

Ta vivo - Check if your service is down before your customers

Ta-vivo Is a tool designed to monitor APIs or web services based on a configurable time interval and sent notifications if the service is down or not responding.

demo

Netlify Status license: MIT Tweet

Features

We have very cool features at this moment;

  • Easy Setup, put a link and select your time invertal
  • Link multiple notifications methods to your checks
  • Timezone configuration for each check
  • Get notifications with Discord, Email, Slack, Telegram and WhatsApp
  • Log history of your checks

Get started

Start checking your service now! ๐Ÿ‘‰ here

Also you can contribute to this project in a different parts;

You can check more on the full documentation

Give a Star! โญ

If you like this project or plan to use it in the future, please give it a star. Thanks ๐Ÿ™

Bugs and Feedback

For bugs, questions, and discussions, please use the Github Issues we have cool templates for you.

Contributing

For contributing, please see the following links:

We're glad to be supported by respected companies and individuals from several industries. See our Github Sponsors learn more.

Sponsors

Become a Github Sponsor


Authors

License

Copyright (C) 2022 by Ta-vivo. MIT License (see LICENSE for details).

ta-vivo-api's People

Contributors

bernestdev avatar dependabot[bot] avatar itsalb3rt avatar jadhielv avatar preetraj2002 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ta-vivo-api's Issues

Telegram integration acts as if it is mandatory

Describe the bug
The app would throw many polling_error when trying to run the API without the TELEGRAM_BOT_TOKEN variable defined. The error does not block the API from running but quickly fills the console with error logs making it hard to debug other issues.

To Reproduce
Steps to reproduce the behavior:

  1. Delete the variable (or leave empty) TELEGRAM_BOT_TOKEN from your .env file.
  2. Run the app with yarn dev and check the polling_error being constantly logged on the console.

Expected behavior
The API should run with not errors when no Telegram integration is defined as integrations should be optional.

Screenshots
Error being thrown in the console
image

Suggested solution
Make sure to check if the env variable TELEGRAM_BOT_TOKEN exists before trying to initialize the service. Check screenshot below

Before fix:
image

After fix:
image

This works for both cases:

  1. The variable is not defined at all
  2. The variable is defined on the .env file but is empty

Please let me know if you agree with this fix and I can apply it.

Timezone

Intro

A timezone is a very important feature when you combine this with the multiple users in multiple countries, the main idea is providing a correct date (not only a UTC) when any check failed or any information is sent to the users.

The user profile

A principal timezone can be configured into the user profile to inherit in checks or any place we need a timezone

Check

The checks can have a dropdown with a list of timezones, by default this inherits the user timezone.

Dependencies upgrade

Description

We need to upgrade all the dependencies using yarn.

Considerations

  • Avoid add others lock files like npm, pnpm, etc...
  • Test the app before send a pull request, sometime

Add a feature on the history logs to allow download in csv

Description

Add a feature on the history logs to allow download in csv Backend documentation

How to do

  • The first step is checked the following route
    router.get('/:id/logs', verifyToken, CheckController.getLogsByCheckId);
  • The proposal is creating other route like the router.get('/:id/logs') but with a extra parameter to indicate the file download, for example router.get('/:id/logs/download')
  • The response need the header "Content-Type", "text/csv"

Email invitation

  • Email template
  • Send email
  • Update the status invitation when the user enter to the invitation
    • Accepted

[Critical] Retry on fail bug

Describe the bug
The app crash when any "retry on fail" are executed

To Reproduce
Steps to reproduce the behavior:

  1. Create a check with retry on fail
  2. Waiting for a retry on fail

Expected behavior
No crash when any retry on fail have error.

Screenshots

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
This is the error from the build version, I no have a development version at this moment.

Error cleaning logs Error: WHERE parameter "id" has invalid "undefined" value
    at PostgresQueryGenerator.whereItemQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1655:13)
    at /usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1646:25
    at Array.forEach (<anonymous>)
    at PostgresQueryGenerator.whereItemsQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1644:35)
    at PostgresQueryGenerator.getWhereConditions (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1987:19)
    at PostgresQueryGenerator.selectQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:932:28)
    at PostgresQueryInterface.select (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:396:59)
    at Function.findAll (/usr/src/app/node_modules/sequelize/lib/model.js:1126:47)
    at async Function.findOne (/usr/src/app/node_modules/sequelize/lib/model.js:1220:12)
/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1655
      throw new Error(`WHERE parameter "${key}" has invalid "undefined" value`);
            ^

Error: WHERE parameter "id" has invalid "undefined" value
    at PostgresQueryGenerator.whereItemQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1655:13)
    at /usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1646:25
    at Array.forEach (<anonymous>)
    at PostgresQueryGenerator.whereItemsQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1644:35)
    at PostgresQueryGenerator.getWhereConditions (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1987:19)
    at PostgresQueryGenerator.selectQuery (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-generator.js:932:28)
    at PostgresQueryInterface.select (/usr/src/app/node_modules/sequelize/lib/dialects/abstract/query-interface.js:396:59)
    at Function.findAll (/usr/src/app/node_modules/sequelize/lib/model.js:1126:47)
    at async Function.findOne (/usr/src/app/node_modules/sequelize/lib/model.js:1220:12)

Slack integration acts as if it is mandatory

Describe the bug
I'm trying to start the API on development mode and I can't get it started because I'm missing valid environment variables for the Slack integration

To Reproduce
Steps to reproduce the behavior:

  1. Delete all variables refering to the Slack integration from the .env file
  2. Run the API with `yarn dev'
  3. The app will crash

Expected behavior
Deleting the variables should allow the API to run as the integration should not be mandatory

Screenshots
If applicable, add screenshots to help explain your problem.
image

image

Possible solutions
A solution would be to check for the definition of the needed env variables before trying to initialize the SlackService. Check the screenshot below:

Before the fix
image

After the fix
image

Here we have a conditional to check for the needed variables before trying to initialize the app. The code above works for both scenarios:

  1. When the variables are not defined at all
  2. When the variables are in the .env file but have no value.

I can apply the fix and upload the changes if you approve this solution. Please let me know.

Authorization headers in checks

Description

Add an advanced setting to include authentication headers inside the checks. This feature is important for private projects.

How to

  • Added toggle options in check section to show the advance settings
  • Added dropdown with the most used headers and add the possibility to add a custom header
  • Encrypt the authorization value with a secret phrase
  • The authorization value NEVER SEND AGAIN TO THE CLIENT SIDE, create an indicator to tell to the user if the value exists in the database
const crypto = require('crypto');

const algorithm = 'aes-256-ctr';
const secretKey = 'theSecretKey';

const encrypt = (text) => {

  const iv = crypto.randomBytes(16);

  const cipher = crypto.createCipheriv(algorithm, secretKey, iv);

  const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);

  return {
    iv: iv.toString('hex'),
    content: encrypted.toString('hex')
  };
};

const decrypt = (hash) => {

  const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(hash.iv, 'hex'));

  const decrpyted = Buffer.concat([decipher.update(Buffer.from(hash.content, 'hex')), decipher.final()]);

  return decrpyted.toString();
};

const text = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
const encrypted = encrypt(text);
console.log('๐Ÿš€ ~ file: Untitled-1 ~ line 31 ~ encrypted', encrypted);
const decrypted = decrypt(encrypted);
console.log('๐Ÿš€ ~ file: Untitled-1 ~ line 32 ~ decrypted', decrypted);

Remove unused user controller and service

Describe the bug
Dead code in the app

To Reproduce
Steps to reproduce the behavior:

  • Remove the controller
  • Remove the service

Expected behavior
NONE

Screenshots
image

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
NONE

Add tests

Description

We need to add new test cases for functionality of the API. Here you can find the current working test to use as an example.

Shared status page (like teams) WIP

Description

We need a feature to share status page between teams, this need to work as public or with invitation (private).

List of elements;

  • Status page
  • Links with uuid to generate this on the fly
  • Possibility to decide what checks showed on the page
  • Multiple shared status pages (probably a pay feature)
  • Invitation via email
  • Down checks count last hour
  • List of checks and current status
  • Notification methods configured
  • Connection with a web socket to get the last checks logs available

Image

At this point 2 alternatives are available;

Image

Image

Database

Image

TO-DO

Backend

  • #76
  • #79
  • #82
  • Add checks to status page
  • Remove checks from status pages

The option to add and remove checks is a properties on the PUT method;

{
  "checksToRemove": [1, 2],
  "checksToAdd": [3,4],
}

Frontend

  • Add the way to go to creation status page
  • Create a form
    • Add checks
    • Add invitation emails (multiple emails at once)
    • Page to view all the status pages
  • Save the token send on the invitation on the local storage to keep "the session" of the user open

The createdAt column have a wrong date

Describe the bug
The createdAt column have a wrong date information, this is for the timezone implementation, create a new column to store the date with the timezone defined on the check.

To Reproduce
Steps to reproduce the behavior:

  1. Create a check
  2. wait for the logs
  3. Check the created at date

Expected behavior
Created at date to filter and get the most recent logs by date

Screenshots
N/A

Update dependencies

Is your feature request related to a problem? Please describe.
Update dependencies of the API. Remember, the API provide all the necessary to run in local.

Describe the solution you'd like
Use the command of yarn to update the dependencies

yarn upgrade-interactive

Describe alternatives you've considered
None

Get the user timezone on register

Is your feature request related to a problem? Please describe.
Get the user timezone to register with email or any provider.

Describe the solution you'd like

Use Dayjs to get the user timezone and send to the API when the user is new.

  • Register with email and password
  • Discord
  • Github
  • Google
  • Slack

Describe alternatives you've considered
N/A

Additional context
N/A

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.