Skip to content

Latest commit

 

History

History
129 lines (90 loc) · 3.84 KB

README.md

File metadata and controls

129 lines (90 loc) · 3.84 KB

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev

Open http://localhost:3000 with your browser to see the result.

Dashboards

Database

Database is hosted on Supabase.

Update db schema

Updates are done via Prisma. Edit the schema in prisma/schema.prisma and run the following commands to apply the changes.

Production

  1. Make changes to the schema in prisma/schema.prisma
  2. Run npx prisma db push
  3. Run npx prisma generate
  4. Restart dev server

Seeding

Resets the database and seeds it with data for Cim and Comarca tables.

Caution

This will delete all data in the database!

npx prisma db seed

Strava Webhook

Note

Because Strava allows only one authorization callback domain per app and one app per account, we have a separate strava accounts (and app) for development and production.

Prerequisites

  • Environement variables (e.g. source .env)
    STRAVA_CLIENT_ID=...
    STRAVA_CLIENT_SECRET=...
    STRAVA_VERIFY_TOKEN=...
  • jq to parse json
  • ngrok to test locally (optional) - Instrucions here

View subsciption

curl -sS -G https://www.strava.com/api/v3/push_subscriptions \
    -d client_id=${STRAVA_CLIENT_ID} \
    -d client_secret=${STRAVA_CLIENT_SECRET} | jq '.[] | .id'

Create subscription

local
curl -sS http://127.0.0.1:4040/api/tunnels \
| jq -r '.tunnels[0].public_url' \
| xargs -I {} \
curl -X POST https://www.strava.com/api/v3/push_subscriptions \
    -F client_id=${STRAVA_CLIENT_ID} \
    -F client_secret=${STRAVA_CLIENT_SECRET} \
    -F verify_token=${STRAVA_VERIFY_TOKEN} \
    -F callback_url={}/api/strava/webhook
production
curl -X POST https://www.strava.com/api/v3/push_subscriptions \
    -F client_id=${STRAVA_CLIENT_ID} \
    -F client_secret=${STRAVA_CLIENT_SECRET} \
    -F verify_token=${STRAVA_VERIFY_TOKEN} \
    -F callback_url=https://100cims.vercel.app/api/strava/webhook

Delete subscription

curl -sS -G https://www.strava.com/api/v3/push_subscriptions \
    -d client_id=${STRAVA_CLIENT_ID} \
    -d client_secret=${STRAVA_CLIENT_SECRET} \
| jq '.[] | .id' \
| xargs -I {} \
curl -X DELETE \
    "https://www.strava.com/api/v3/push_subscriptions/{}?client_id=${STRAVA_CLIENT_ID}&client_secret=${STRAVA_CLIENT_SECRET}"

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.