Giter Club home page Giter Club logo

lighthouse-reporter's Introduction

Lighthouse reporter

Generate lighthouse reports and save it in a mongo database.


Get started

Install all dependencies

  yarn install

Add the .env variables

DB_URL=mongodb://<db_user>:<db_pass>@localhost:27017/<db_name>
DB_URL_DEV=mongodb://<db_user_dev>:<db_pass_dev>@localhost:27017/<db_name_dev>
SECRET_KEY=lr-secret-key

Run the project

  yarn dev

API doc:

Sign up

  • Method: POST
  • URL: /api/signup
  • Header: Content-Type: application/json
  • Body:
    {
      "email": "[email protected]",
      "password": "123456"
    }
  • Reponse:
    {
      "message": "User was registered successfully!",
      "user": {
        "id": "6311481641a03f4a480263ad",
        "email": "[email protected]"
      }
    }

Sign in

  • Method: POST
  • URL: /api/signin
  • Header: Content-Type: application/json
  • Body:
    {
      "email": "[email protected]",
      "password": "123456"
    }
  • Reponse:
    {
      "email": "[email protected]",
      "accessToken": "xxYYYxxYYxyxYXyy"
    }

Create trigger

  • Method: POST
  • URL: /api/trigger/create
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:
    {
      "name": "site",
      "pages": ["https://vczb.github.io/", "https://vczb.github.io/about"],
      "callbackUrl": "https://my-site.com/optional/callback"
    }
  • Reponse:
    {
      "message": "Trigger was create successfully!",
      "trigger": {
        "user": "63101417561a7dcc826ff500",
        "name": "site",
        "pages": ["https://vczb.github.io/", "https://vczb.github.io/about"],
        "callbackUrl": "https://my-site.com/optional/callback"
      }
    }

Dispatch trigger

  • Method: POST
  • URL: /api/trigger/dispatch
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:
    {
      "name": "site"
    }
  • Reponse:
    {
      "ok": true,
      "message": "Trigger was dispatched successfully"
    }

Show trigger

  • Method: GET
  • URL: /api/trigger/show
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Reponse:
    {
      "trigger": [
        {
          "user": "63101417561a7dcc826ff500",
          "name": "github",
          "pages": ["https://github.com/vczb"],
          "callbackUrl": "https://my-site.com/optional/callback"
        },
        {
          "user": "63101417561a7dcc826ff500",
          "name": "site",
          "pages": ["https://vczb.github.io/", "https://vczb.github.io/about"],
          "callbackUrl": "https://my-site.com/optional/callback"
        }
      ]
    }

Delete trigger

  • Method: POST
  • URL: /api/trigger/delete
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:
    {
      "name": "site"
    }
  • Reponse:
    {
      "ok": true,
      "message": "Trigger was deleted successfully"
    }

Edit trigger

  • Method: POST
  • URL: /api/trigger/edit/<TRIGGER-NAME>
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:
    {
      "name": "site-updated",
      "pages": ["https://vczb.github.io/", "https://vczb.github.io/about"],
      "callbackUrl": "https://my-site.com/optional/callback"
    }
  • Reponse:
    {
      "message": "Trigger was edited successfully!",
      "trigger": {
        "user": "63101417561a7dcc826ff500",
        "name": "site-updated",
        "pages": ["https://vczb.github.io/", "https://vczb.github.io/about"],
        "callbackUrl": "https://my-site.com/optional/callback"
      }
    }

Show report

  • Method: GET

  • URL: /api/report/show?name=<TRIGGER-NAME>

  • Header:

    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Reponse:

    {
      "report": [
        {
          "user": "63101417561a7dcc826ff500",
          "name": "site",
          "data": [
            {
              "url": "https://vczb.github.io/",
              "accessibility": "78",
              "best": "92",
              "performance": "97",
              "pwa": "30",
              "seo": "100",
              "_id": "631143d30b4556af51696e54"
            },
            {
              "url": "https://vczb.github.io/about",
              "accessibility": "67",
              "best": "92",
              "performance": "93",
              "pwa": "20",
              "seo": "100",
              "_id": "631143d30b4556af51696e55"
            }
          ],
          "createdAt": "2022-09-01T23:44:19.969Z",
          "updatedAt": "2022-09-01T23:44:19.969Z"
        }
      ]
    }

    Delete user

  • Method: POST

  • URL: /api/user/delete

  • Header:

    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:

    {}
  • Reponse:

    {
      "ok": true,
      "message": "User was deleted successfully"
    }

Edit user

  • Method: POST
  • URL: /api/user/edit
  • Header:
    • Content-Type: application/json
    • x-access-token: XxxXXXXXxx
  • Body:
    {
      "email": "[email protected]",
      "password": "123456",
    }
  • Reponse:
    {
      "ok": true,
      "message": "User was edited successfully!",
    }

Contributing

You can contribute to this project by opening an issue or creating a pull request.

Check the best practices on the CONTRIBUTING file.

License

This project is licensed under the MIT License.

lighthouse-reporter's People

Contributors

abhigyan-mohanta avatar guillergood avatar mshehu5 avatar semioz avatar vczb avatar yasionfire avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

lighthouse-reporter's Issues

Create a Social preview image

  • File should be located on the root dir and named as Social.png
  • Should be PNG
  • Can be equal to Logo or not ( if not follow the same styled-guide )
  • Follow the width / height as bellow

image

Remove unnecessary data from JSON responses

Some responses are returning unnecessary data like "_id" and "__v"

Let's cleanup the response JSON and return only what is needed

In the README we have the API documentation, which should be updated too

BUG - Error generating report in production

Sep 3 08:49:11 PM  (node:52) UnhandledPromiseRejectionWarning: Error
Sep 3 08:49:11 PM      at new LauncherError (/opt/render/project/src/node_modules/chrome-launcher/src/utils.ts:31:18)
Sep 3 08:49:11 PM      at new ChromePathNotSetError (/opt/render/project/src/node_modules/chrome-launcher/dist/utils.js:33:9)
Sep 3 08:49:11 PM      at Object.linux (/opt/render/project/src/node_modules/chrome-launcher/src/chrome-finder.ts:153:11)
Sep 3 08:49:11 PM      at Function.getFirstInstallation (/opt/render/project/src/node_modules/chrome-launcher/src/chrome-launcher.ts:192:61)
Sep 3 08:49:11 PM      at Launcher.launch (/opt/render/project/src/node_modules/chrome-launcher/src/chrome-launcher.ts:262:37)
Sep 3 08:49:11 PM      at Object.launch (/opt/render/project/src/node_modules/chrome-launcher/src/chrome-launcher.ts:73:18)
Sep 3 08:49:11 PM      at /opt/render/project/src/src/services/lighthouse.ts:5:39
Sep 3 08:49:11 PM      at step (/opt/render/project/src/src/services/lighthouse.ts:33:23)
Sep 3 08:49:11 PM      at Object.next (/opt/render/project/src/src/services/lighthouse.ts:14:53)
Sep 3 08:49:11 PM      at /opt/render/project/src/src/services/lighthouse.ts:8:71
Sep 3 08:49:11 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Sep 3 08:49:11 PM  (node:52) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Catch Async Function

In order to get rid of multiple try-catch blocks, I want to create a file under the utilities folder to achieve this. If it is a good idea, can you assign this to me? Thank you.

Update contributing section on README

Should add clear information about how to contribute. Fork, clone, create a branch, etc... Also, is very important explain how to update your forked repository after some changes ( with rebase ).

Fell free to research on others repositories and google for examples.


thanks

any question I'm available

Global Error Handler

I would create a folder which contains "Global Error Handler". Can you assign this issue to me?

Protocol "https:" not supported. Expected "http:"

This error occur when dispatch a report

  LH:status Generating results... +3ms
Report is done for https://vczb.github.io/about
Report finished
Report data:
 [
  {
    url: 'https://vczb.github.io/',
    accessibility: 81,
    best: 92,
    performance: 76,
    pwa: 30,
    seo: 98
  },
  {
    url: 'https://vczb.github.io/about',
    accessibility: 71,
    best: 92,
    performance: 67,
    pwa: 20,
    seo: 97
  }
]
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
    at new NodeError (node:internal/errors:371:5)
    at new ClientRequest (node:_http_client:158:11)
    at Object.request (node:http:96:10)
    at /home/vini/src/lighthouse-reporter/src/app/controllers/trigger.controller.ts:111:28
    at step (/home/vini/src/lighthouse-reporter/src/app/controllers/trigger.controller.ts:33:23)
    at Object.next (/home/vini/src/lighthouse-reporter/src/app/controllers/trigger.controller.ts:14:53)
    at fulfilled (/home/vini/src/lighthouse-reporter/src/app/controllers/trigger.controller.ts:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_INVALID_PROTOCOL'
}
[nodemon] app crashed - waiting for file changes before starting...

Create project LOGO

  • Design a logo.
  • Export the logo as SVG and PNG on the root directory (name logo.svg and logo.png)

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.