| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a quick example of an Oddworks server with the API running in one process, and a sync service running in a separate process.
This is only an example and should not be used in production. You would likely want to do things differently.
This setup uses the following oddworks stores and services:
You can install this to Heroku as-is to get a quick reference API.
If you have this code locally, you can add your Heroku app as a git remote like so:
$ git remote add heroku https://git.heroku.com/your-heroku-application-name.git
Then you can push changes like so:
$ git push heroku master
*Note: Auto-deploying on Heroku will automatically generate a new JWT_SECRET environment variable for you. You will need this for generating the JWT (json web token) used in the x-access-token header for API requests, or within the various platform SDKs.
After you've cloned this repo locally, follow these steps to get it running.
$ npm install
We use foreman to manage multiple node processes via the ./Procfile.
$ npm install -g foreman
You will need the following environment variables before running this example
You can set these manually, or you can use foreman. foreman recognizes an .env file. You can set one locally for development purposes, but should not check it in to git.
An example .env file:
NODE_ENV=development REDIS_URL=redis://127.0.0.1:6379 VIMEO_API_TOKEN=your-vimeo-api-token GOOGLE_ANALYTICS_ID=UA-XXXX_XX SYNC_INTERVAL=300000 JWT_SECRET=your-secret-token
*Note: You will need real values for REDIS_URL and VIMEO_API_TOKEN.
Locally you can use the following command to start the server:
Using foreman:
$ nf start
Once your server is running, you can begin making requests like so:
$ curl -X GET -H "x-access-token: YOUR_TOKEN_HERE" -H "Accept: application/json" "http://localhost:3000/videos"
Required Headers
The default data includes one channel with an id of odd-networks and three platforms with ids of android, apple-tv, and roku. In order to generate an access token for the sample data, you can use the oddworks-cli like so:
$ oddworks generate-token -c odd-networks -p android -j {your-jwt-secret}
If you did not explicitly set the JWT_SECRET environment varaible, it will default to the value secret. If you deployed using the Heroku auto-deploy, this environment variable was auto-generated for you and can be found by running the following:
$ heroku config -a your-heroku-app-name | grep JWT_SECRET
By default we use the odd-networks seed function provided by ./data/seed.js
We are only using the seed script to load 1 channel and 3 platform entities. The rest of our data is coming from Vimeo (via our sync service and provider) and will only contain video data if you have videos you have uploaded to the associated Vimeo account.
You do not need to override example data, but if you want to, please see ./data/seed.js
| Back | FazBrowse Home | New Git URL |