Coder Social home page Coder Social logo

github30 / lighthouse-keeper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlechromelabs/lighthouse-keeper

0.0 2.0 0.0 859 KB

Serves Lighthouse data over time

Home Page: https://lighthouse-dot-webdotdevsite.appspot.com/

License: Apache License 2.0

JavaScript 71.09% HTML 24.36% CSS 4.56%

lighthouse-keeper's Introduction

Lighthouse Keeper

Lighthouse keeper is a backend for providing historical Lighthouse results for an URL. It's used to power the Lighthouse integration on web.dev.

There are several bits:

  • Runs the Lighthouse API against a URL and stores reports over time (Firestore). Provides querying capabilities.
  • The latest (full) report for the URL is stored (Google Cloud Storage).
  • The server itself is Google App Engine (NodeJS). Cron jobs schedule tasks to update scores for each URL in the system.

There's page demo page (/public/index.html) that shows how this package can be used to render results. Note: if you're testing, CI_HOST needs to be switched over to http:localhost:8080 in the app.js.

web.dev frontend rendering data from this server

Development

  1. Install it:
npm i
  1. Decrypt the service account and memcache json files:
npm run decrypt

You will be prompted to for a passphrase to decrypt serviceAccount.json.enc and memcacheCredentials.json.enc. These files are required for the backend to communicate with Firestore and the Redis memcache service. The password can be found in Google's shared password tool.

  1. Run the web server:
npm run start
  1. Build it

To build the CSS/JS bundles, run of npm run build:js, npm run build:css, or the single command:

npm run build

There are also watch tasks if you want to iterate on the files while the server is running:

npm run watch:css
npm run watch:js

API

Metadata handlers

Lists the Lighthouse categories:

GET /lh/categories

Lists the Lighthouse audits:

GET /lh/audits

Lighthouse data handlers:

Lists the latest MAX_REPORTS reports for the URL. If the ?since=YYYY-MM-DD query parameter is used, the results will be filtered to on or after that date.

GET /lh/reports?url=https://example.com/
GET /lh/reports?url=https://example.com/&since=2018-10-25

Lists the URLs that have been saved in the system.

GET /lh/urls

Displays the latest Lighthouse HTML report for url. If the download param is included, the file is downloaded.

GET /lh/html?url=https://example.com
GET /lh/html?url=https://example.com&download

Starts a new Lighthouse audit for url.

POST /lh/newaudit
Content-Type: application/json

{"url": "https://example.com"}

Lists the median scores (for each Lighthouse category) of all the URLs in the system, or just for a particular URL.

GET /lh/medians[?url=https://example.com/]

Private handlers

Seeds the db with the list of URLs in seeds_urls.json by scheduling a task to run a Lighthouse audit on each URL. Note: this handler can only run if there are no URLs already stored. It should be run if the db is ever cleared.

GET /lh/seed_urls

Used by the cron job (see cron.yaml) to update Lighthouse scores for each URL saved in the system. Note: this handler is only accessible to the App Engine backend.

GET /cron/update_lighthouse_scores

Used by the cron job (see cron.yaml) to delete existing results if the URL hasn't been viewed/audited or otherwise "touched" in the last 60 days. Note: this handler is only accessible to the App Engine backend.

GET /cron/delete_stale_lighthouse_reports

lighthouse-keeper's People

Contributors

devnook avatar ebidel avatar robdodson avatar samthor avatar

Watchers

 avatar  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.