Git Product home page Git Product logo

pwa-workshop-api's Introduction

A simple Twitter-based API for PWA Workshop

Prerequisites

Latest stable versions of node, npm installed. Having yarn installed is strongly recommended.

Install

  1. Clone the repo
yarn

or

npm install

Creating settings file

  1. Save .env.template as .env and open it in the editor

Getting Twitter credentials

  1. Go to https://apps.twitter.com/app/new and create a new app. Website field - any valid URL
  2. Go to "Keys and Access Tokens" tab and click "Create my access token" button
  3. Use Consumer Key, Consumer Secret, Access Token, Access Token Secret to fill in the corresponding fields in .env

Getting VAPID credentials

Go to https://web-push-codelab.glitch.me/ and use the newly generated Public and Private VAPID keys to fill in the corresponding fields in .env

Starting the app

  1. In the terminal
node .

You should see the output:

{
  "level": "info",
  "message": "Listening on port 3000"
}
  1. Open http://localhost:3000/. You should see PWA Workshop API works!.
  2. Open http://localhost:3000/timeline/. You should see the JSON with your latest tweets.
  3. Open http://localhost:3000/timeline/angular/. You should see the JSON with @angular latest tweets. Instead of angular you can use any other Twitter handle.
  4. Check the console: you will see the entries
{
  "level": "info",
  "message": "Tweet stream received"
}

appear there periodically.

Customizing the app

By default it streams the new tweets with javascript string. You can change this setting:

node . --stringToMonitor angular

Important

Please allow 10-15 seconds after application stop before the new start. Otherwise your connection will be rejected by Twitter's rate limit control (Status Code: 420). Just wait 30 seconds before the new start in this case.

Fallback solution for Push messaging

If Twitter Stream API doesn't work, set the last parameter of new CronJob to true to start pushing messages by timer.

pwa-workshop-api's People

Contributors

webmaxru avatar jjdeu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.