npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

fastify-twitch-ebs-tools

1.0.1 • Public • Published

fastify-twitch-ebs-tools

npm (latest) Travis Build Status AppVeyor Build Status Maintainability Test Coverage Greenkeeper badge

Fastify plugin providing useful functions for Twitch Extension Backend Services (EBS). Internally it uses twitch-ebs-tools.

Installation

npm install --save fastify-twitch-ebs-tools

Usage

Register as a plugin to get access to additional methods.

Example below assumes Twitch token to be sent via request headers.

const fastify = require('fastify');
 
fastify.register(require('fastify-twitch-ebs-tools'), {
  secret: 'twitch shared secret',
  disabled: false,
});
 
fastify.get('/config/:channelId', (req, reply) => {
  const { token } = req.headers;
  const { channelId } = req.params;
  const valid = fastify.twitchEbs.validatePermission(
    token,
    channelId,
    'broadcaster',
  );
 
  if (valid) {
    // do something and send the reply back
    reply.send(/* reply object */);
  } else {
    // error 400
  }
});
 
fastify.listen(3000, (error) => {
  if (error) throw error;
});

Options

  • secret - Twitch shared secret used to sign and verify JWTs (required). The plugin will throw an error if no secret is provided. Required.

  • disabled - if true, all validation methods will return true. Useful for temporarily disabling route authentication for debugging purposes. Does not affect validateToken() method. Defaults to false. Optional.

Usage

All plugin methods pass arguments to relevant methods of twitch-ebs-tools. Refer to twitch-ebs-tools documentation to get more details.

Available methods:

License

Licensed under MIT License. See LICENSE for more information.

install

npm i fastify-twitch-ebs-tools

Downloadsweekly downloads

0

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability