This package has been deprecated

Author message:

use our guide instead https://community.peerboard.com/post/183197627

@peerboard/node-api
TypeScript icon, indicating that this package has built-in type declarations

0.0.19 • Public • Published

Deprecated

You can just generate the token for your own

Usage

See more detailed guides in our community

yarn add @peerboard/node-api

or

npm install @peerboard/node-api
const { generateBearerToken } = require('@peerboard/node-api');

// Don't forget to protect your endpoint with auth
router.post('/generate-bearer-token', auth.required, async (req, res, next) => {
  const user = await User.findById(req.payload.id);
  const redirect = req.redirect || "/";

  const payload = {
    user_id: user.id, // Required unique user id - should not change(email is bad identifier)
    email: user.email, // Email is required
    name: user.username, // If empty user will be asked to enter her name
    last_name: user.last_name, // You can also specify last name and enable require last name in community settings
    avatar_url: user.image, // Optional url to photo
    bio: user.bio, // Optional
    tagline: user.tagline, // Optional
    // It is possible to use custom profile url into your app.
    // We will substitute all urls to user profile with this.
    // Optional
    profile_url: '<ABSOLUTE_URL_TO_USER_PROFILE>',
    role: "admin"|"member"|"banned", // Is optional by default member on creation
  };
  const token =	generateBearerToken(
    '<YOUR_AUTH_TOKEN>',
    payload,
    redirect,
  );
  return res.json({
    token,
  });
});

Package Sidebar

Install

npm i @peerboard/node-api

Weekly Downloads

12

Version

0.0.19

License

MIT

Unpacked Size

6.19 kB

Total Files

3

Last publish

Collaborators

  • maxim_khokhlov
  • tonknaf
  • vernon99