# express-strava

> Express handlers for the Strava webhook API.

Latest version **2.0.0** (published 2023-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-strava
pnpm add express-strava
yarn add express-strava
bun add express-strava
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-05-14 |
| First published | 2023-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mark Bradley |
| Maintainers | markbradley27 |
| Keywords | strava, express, api, webhook |

## Links

- npm: https://www.npmjs.com/package/express-strava
- Repository: https://github.com/markbradley27/express-strava
- Homepage: https://github.com/markbradley27/express-strava#readme
- Issues: https://github.com/markbradley27/express-strava/issues
- npm.io page: https://npm.io/package/express-strava

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^4.3.4
- [express](https://npm.io/package/express.md) ^4.18.2

## Recent versions

- 2.0.0 (latest) — 2023-05-14
- 1.0.4 — 2023-04-25
- 1.0.3 — 2023-04-25
- 1.0.2 — 2023-04-25
- 1.0.1 — 2023-04-25
- 1.0.0 — 2023-04-25

## README

# express-strava

[![build](https://github.com/markbradley27/express-strava/workflows/build/badge.svg)](https://github.com/markbradley27/express-strava/actions/workflows/build.yaml)
[![test](https://github.com/markbradley27/express-strava/workflows/test/badge.svg)](https://github.com/markbradley27/express-strava/actions/workflows/test.yaml)

Express handlers for the strava webhook API.

## Quickstart

1. The following code will spin up an express server that handles strava webhooks:

   ```typescript
   // server.ts
   import express from "express";
   import { ActivityCreateData, StravaHandlers } from "express-strava";

   const app = express();

   app.use(
     "/webhook",
     StravaHandlers({
       // Specify the verify token that will be provided when creating the
       // webhook subscription.
       verify_token: "STRAVA",

       // Register handlers for webhook events. We're only handling activity
       // creation here, but you can register handlers for all event types.
       activity_create_handler: (data: ActivityCreateData) =>
         console.log(`activity_create_handler here, handling activity: ${data.object_id}`),
     })
   );

   const port = 8080;
   app.listen(port, () => {
     console.log(`Listening on port: ${port}`);
   });
   ```

1. Fire it up (with debug output) and it should start listening:

   ```bash
   $ DEBUG=express-strava:* ts-node server.ts
   Listening on port: 8080
   ```

1. To create the webhook subscription, follow [these
   instructions](https://developers.strava.com/docs/webhookexample/), skipping
   the steps for creating and running your express server (we just did that!
   😃).

   If the subscription was created successfully, you should have seen something
   like this:

   ```
   express-strava:get echoing challenge; {"hub.verify_token":"STRAVA","hub.challenge":"80292665ca052d4e","hub.mode":"subscribe"} +0ms
   ```

1. Go do something cool and post it to Strava! Once you're done, you should see
   the server receive the activity created event and dispatch it to your
   handler:

   ```
   express-strava:post dispatching to activity_create_handler; {"aspect_type":"create","event_time":1682391474,"object_id":1234567890,"object_type":"activity","owner_id":2222222,"subscription_id":333333,"updates":{}} +0ms
   activity_create_handler here, handling activity: 1234567890
   ```

---
_Source: https://npm.io/package/express-strava · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
