Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Remove server as it will only work for one person and I don't want to…
Browse files Browse the repository at this point in the history
… manage state for others. Add dark mode css and convert to typescript.
  • Loading branch information
rhyst committed Nov 17, 2021
1 parent d2f9017 commit 22ff657
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 189 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist
config.js
config.js
*.sqlite
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

29 changes: 4 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ The Strava webhooks only trigger if the title of an activity changes. If you wan

### Install

⚠ Directus 9 is a moving target and subject to change and until it stabilized it is likely this extension will only work with a particular version of directus. This will be noted in the release notes.
Compatible with Directus 9.0.x.

Install the extension by copying the release files to your directus extensions folder:

- Copy `endpoint.js` to `<directus_root>/extensions/endpoints/strava/index.js`
- Copy `config.js` to `<directus_root>/extensions/endpoints/strava/config.js`

Configure the extension by editing `config.js`. See below for config options. You must set `directusUrl` for authentication to work.
Configure the extension by editing `config.js`. See below for config options. You must set `directusUrl` for authentication to work. You must create a strava oauth application and set the `clientId` and `clientSecret`.

Then you can visit `<directus_url>/strava` where you can authenticate and start fetching activities.

Expand All @@ -34,6 +34,8 @@ Configuration is done in `config.js`. The options are:

| Option | Type | Default | Description |
| ------------------- | -------- | ----------------------------------------- | ------------------------------------------------------------------------------- |
| `clientId` | string | | Strava OAuth application client id |
| `clientSecret` | string | | Strava OAuth application client secret |
| `directusUrl` | string | | The full url to your directus instance |
| `webhookSecret` | string | | A random secret to obfusticate the webhook url |
| `collection` | string | `"strava"` | The directus collection to insert strava data into |
Expand All @@ -44,29 +46,6 @@ Configuration is done in `config.js`. The options are:
| `athleteEmail` | string | | Your strava account email - only required for retrieving "full" activities |
| `athletePassword` | string | | Your strava account password - only required for retrieving "full" activities |

### Server

By default the extension uses the Directus Strava heroku app as an authentication proxy server. This is a stateless app that stores no authentication information.

If you would prefer to host your own authentication server then first set up a Strava applicaton on the [strava website](https://developers.strava.com/docs/).

Then deploy the Heroku app:

```
heroku apps:create <name-for-your-heroku-app>
heroku config:set CLIENT_ID=<your-apps-client-id>
heroku config:set CLIENT_SECRET=<your-apps-client-secret>
npm run deploy
```

Finally update the `authProxyUrl` in `config.js` to your heroku app:

```
authProxyUrl: "https://my-heroku-app.herokuapp.com"
```

## Development

Install dependencies:
Expand Down
Empty file added db/.keep
Empty file.
63 changes: 62 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"main": "dist/index.js",
"scripts": {
"build": "rollup -c",
"build:dev": "rollup -c -m inline",
"server": "node dist/server.js",
"deploy": "git push -f heroku master"
"watch": "rollup -c -w",
"start": "docker run --rm --name directus -p 8055:8055 -v $PWD/db:/directus/database -v $PWD/dist:/directus/extensions/endpoints/strava -e KEY=test -e SECRET=test -e [email protected] -e ADMIN_PASSWORD=d1r3ctu5 directus/directus"
},
"author": "",
"license": "MIT",
Expand All @@ -18,12 +17,14 @@
"got": "^11.8.2",
"node-html-parser": "^4.1.4",
"nunjucks": "^3.2.3",
"tough-cookie": "^4.0.0"
"tough-cookie": "^4.0.0",
"typescript": "^4.5.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^19.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-typescript": "^8.3.0",
"rollup": "^2.56.3",
"rollup-plugin-clean": "^1.0.0",
"rollup-plugin-copy": "^3.4.0",
Expand Down
18 changes: 3 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import json from "@rollup/plugin-json";
import copy from "rollup-plugin-copy";
import clean from "rollup-plugin-clean";
import { string } from "rollup-plugin-string";
import typescript from "@rollup/plugin-typescript";

export default [
{
input: "src/client/index.js",
input: "src/client/index.ts",
output: {
file: "dist/index.js",
format: "cjs",
exports: "default",
},
plugins: [
typescript(),
clean(),
nodeResolve({
preferBuiltins: true,
Expand All @@ -29,18 +31,4 @@ export default [
}),
],
},
{
input: "src/server/index.js",
output: {
file: "dist/server.js",
format: "cjs",
},
plugins: [
clean(),
nodeResolve({ preferBuiltins: true }),
commonjs(),
json(),
],
onwarn: () => {},
},
];
4 changes: 2 additions & 2 deletions src/client/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
// Auth
clientId: 123456,
clientSecret: "",
athleteEmail: "", // Your strava account email - only required for retrieving "full" activities
athletePassword: "", // Your strava account password - only required for retrieving "full" activities
authClientId: 68343, // Strava Application id - leave as default unless you are hosting your own server
authProxyUrl: " https://directus-strava.herokuapp.com", // Auth proxy url - leave as default unless you are hosting your own server
webhookSecret: "", // A random secret to obfusticater the webhook url
// Paths
directusUrl: "", // The full url to your directus instance
Expand Down
Loading

0 comments on commit 22ff657

Please sign in to comment.