Skip to content

glencoden/berta-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Berta Berlin YouTube API caching

Dependencies

This lib requires no further dependencies.

Configuration

In config.js you can configure the cache worker's behavior. Most notably:

CACHE_PATH: The location on your local filesystem for data to be cached.
YOUTUBE_API_CACHE_STALE_TIME: The time interval for data to be cached.
YOUTUBE_CHANNEL_ID: The id of the youtube channel to get cached.

Usage

In your node express application...

const express = require('express');
const app = express();

// ...REQUIRE THE CACHE WORKER'S ROUTER

const bertaRouter = require('path-to-cache-worker/router');

// ...PASS EXPRESS AND YOUR APP TO THE ROUTER AND app.use IT ON YOUR ROUTE

app.use('/my-cache-route', bertaRouter(app, express));

app.listen('8080');

Done!

The cache worker will now update the youtube data in the interval set in config.js.

You can fetch the cached data with a GET request to your route. Don't forget to pass the resource query parameter with a value from ALLOWED_RESOURCES in config.js.

Example GET path:

/my-cache-route?resource=video

About

Collect, cache and transform youtube API data for Berta Berlin website

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published