Audit websites using Google Lighthouse, then store and display the data
Use Prisma for ORM https://www.youtube.com/watch?v=FMnlyi60avU
Google Lighthouse for audits https://github.com/GoogleChrome/lighthouse/blob/master/docs/readme.md#using-programmatically
This is a Next.js project bootstrapped with create-next-app
.
-
Create a database for storing data. I used Heroku's Postgresql database.
-
Get credentials and add them to
.env
DATABASE_URL="postgresql://janedoe:mypassword@localhost:5432/mydb"
- Sync schema with database
npx prisma db push
- Create
env.local
at root and add:
NEXT_PUBLIC_DEV=1
yarn dev
to start the server
-
Use Redis for background services for audit so that response doesn't time out. Currently while hosting on Heroku, the response times out before the audit finishes. So, only way to use the audit feature is locally.
-
Replace old current audit with new current audit if audited.
-
Allow deleting of audits on front end
-
Access PSQL through Heroku CLI using:
heroku pg:psql -a audit-nextjs
-
Table is queried using
"Audit"
instead of'Audit'
because of how Prisma is set up:SELECT * FROM "Audit";
-
Restart Heroku server using CLI:
heroku restart -a audit-nextjs
-
Look at last 200 Heroku logs using CLI:
heroku logs -n 200 -a audit-nextjs
-
On Heroku, required buildpacks in
Settings
are:
heroku/nodejs
https://github.com/heroku/heroku-buildpack-google-chrome.git