npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

example-single-process

v1.0.1

Published

An example implementation of an Oddworks server in a single process.

Downloads

3

Readme

Oddworks Example Server - Single Process

slack.oddnetworks.com

This is a quick example of an Oddworks server with all services, stores, and the API running in a single 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:

*Note: We're using fakeredis and make no guarantees about your data here. You would probably not want to use this in production.

Deploy It!

You can install this to Heroku as-is to get a quick reference API.

Deploy

	Note: Auto-deploying on Heroku will generate the JWT_SECRET environment variable.

Setup

After you've cloned this repo locally, follow these steps to get it running.

Install node modules

	$ npm install

Environment Variables

You can override the default values we use, or run the server as-is.

  • NODE_ENV - this environment variable will tell which environment to run node in. The default value is development.
  • PORT - this environment variable will tell which port to run the express server on. The default value is 3000.
  • JWT_SECRET - this environment variable is used as the secret used to sign your JWT tokens. The default value is secret.
  • DATA_DIR - this environment variable will tell our server where to look for a seed.js file. By default this is undefined and we use @oddnetworks/oddworks-example-data's nasa seed script. Read below about Example Data
  • GOOGLE_ANALYTICS_ID - this environment variable is used to send event metrics into the google-analytics event analyzer. The default value is UA-XXXX-XX.

Startup

Locally you can use the following command to start the server:

	npm run dev

We use nodemon for development to automatically reload the server for us when file changes are detected.

Hit the API

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

  • x-access-token - the value here will depend on how you deployed and your environment. See Access Tokens
  • accept - the value here should always be application/json

Access Tokens

The default data includes one channel named nasa and three platforms with ids of apple-ios, 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 nasa -p apple-ios -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

Example Data

By default we use the nasa seed function provided by the @oddnetworks/oddworks-example-data package.

You do not need to override example data, but if you want to:

The configuration file relies on example data and a seed script to get running. For examples of how to set this up yourself, and override the seed script using the DATA_DIR environment variable, please check out the oddworks-example-data repo.

You can clone the oddworks-example-data repo, or if you want to start working with the seed script within this project you can use the oddworks-cli and run:

	$ oddworks fetch-data