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

loopback-boot-create-access-token

v0.2.0

Published

Module for generating an access token with an administrator account with all access.

Downloads

12

Readme

This module is exclusively designed for Strongloop Loopback. It provides model and method testing thanks to an access token with quick access.

Getting started

Install

npm install --save loopback-boot-create-access-token

Usage

Modify server.js file by adding BOOTOPTIONS as below. This change will run the module startup script, and then start the scripts in the server/boot directory.

// app.start = function () { ... }

const BOOTOPTIONS = {
    'appRootDir': __dirname,
    'bootDirs': [
        '../node_modules/loopback-boot-create-access-token/lib/index.js'
    ]
};
boot(app, BOOTOPTIONS, function (err) {
    if (err) throw err;
    
    // start the server if `$ node server.js`
    if (require.main === module)
        app.start();
});

In order to take full advantage of the access token, you will need to create a new ACL rule that allows the new user to access any type of method. To do this type command : lb acl or apic loopback:acl or slc loopback:acl. Then choose the options as below :

  • Select the template to apply the ACL entry : (all existing models)
  • Select ACL scope : All methods and properties
  • Select type of access : All (match all types)
  • Select the role : other
  • Enter the role name : {The name of the role you chose or the default (superadmin)}
  • Select the right to apply : Explicitly grant access

Configuration

The initial configuration is set to work with the basic user model (User). This configuration will create a superadmin role and a DeveloperAdmin user.

| Key | Type | Default value | Description | |------------------------------------|---------|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| | showDebug | boolean | true | Display additional console log | | userModelName | string | User | Name of the user model to manage users | | defaultRoleUser | object | | An object contains all the information about the role and the user to create | | defaultRoleUser.name | string | superadmin | Name of the role that will allow you to have all the access after the configuration of the ACLs. | | defaultRoleUser.description | string | Role having all access and no restrictions (Provider : loopback-boot-create-access-token). | Description of the role for better visibility in the database. | | defaultRoleUser.user | object | | An object containing the administrator user | | defaultRoleUser.user.username | string | DeveloperAdmin | Username that you will use to log in | | defaultRoleUser.user.email | string | [email protected] | Email address that you will use to log in | | defaultRoleUser.user.emailVerified | boolean | true | Allows you to creates a user without sending a validation email | | defaultRoleUser.user.password | string | @dminD€v | Password you will use to log in |

The configuration is customizable by modifying server.js and add/modifying items as the following example:

var loopback = require('loopback');
var boot = require('loopback-boot');
var bootCreateAccessToken = require('loopback-boot-create-access-token');

// => Configuration
bootCreateAccessToken.configurations({
    showDebug: false,
    userModelName: "Account",
    defaultRoleUser: {
        name: "admin",
        user: {
            username: "RedekProject",
            email: "[email protected]",
            emailVerified: true,
            password: "l00pb@ck@d!n",
            firstName: "Philippe",
            lastName: "Desplats"
        }
    }
});

Testing

Run the unit tests

npm test

Author

License

This project is licensed under the MIT License - see the LICENSE.md file for details.