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

accountdown-parser

v0.2.0

Published

Facilitates account creation and user input validation using accountdown and json-schema

Downloads

11

Readme

accountdown-parser

Account creation and user input validation for accountdown using json-schema. Primary usage is on the server.

example

create an accountdown-parser instance and define a json-schema

  var validator = require('is-my-json-valid');
  var validate = validator({
    required: true,
    type: 'object',
    properties: {
      login: {
        required: false,
        type: 'object',
        properties: {
          basic: {
            required: true,
            type: 'object',
            properties: {
              uuid: {
                required: true,
                type: 'string'
              },
              password: {
                required: true,
                type: 'string'
              }
            }
          }

        },
      value: {
        required: true,
        type: 'object',
        properties: {
          key: {
            required: true,
            type: 'string'
          },
          admin: {
            required: false,
            type: 'boolean'
          },
          color: {
            required: false,
            type: 'string'
          },
          username: {
            required: false,
            type: 'string'
          },
          email: {
            required: false,
            type: 'string'
          }
        }
      }

      }
    }
  }, {
    verbose: true
  });
  opts = {
    validate: validate,
    format: function (body) {
      body.value.admin = !!(body.value.admin);
      if (body.value.key && body.login) {
        body.login.basic.uuid = body.value.key;
      }
      return body;
    },
    updateLoginCreds: function (account) {
      return account.hasOwnProperty('login');
    }

methods

var p = accountdown-parser(accountdown, opts)

Return a parser instance p given an accountdown instance a.

Set opts.validate as an instance of is-my-json-valid to define the schema that will be validated for each user instance.

Set an optional opts.format to define how client-side requests should be parsed.

Another optional, but useful, opts.updateLoginCreds function defines whether the client's input is updating the login creds, which will require deletion and re-creation of the account when it returns true. Otherwise, only the account's value will be updated.

p.create(req, res, callback)

req, res: Parses the req and res objects using the body's body/any module, along with a querystring, and creates an account

Internally, all accounts are created with the key generated from uuid, version 1.

callback(err, account) fires with any errors or an account containing the account values.

p.update(req, res, callback)

The same as p.create except the function opts.updateLoginCreds is checked to determine whether to delete and recreate the accounts (when opts.updateLoginCreds exists and returns true), otherwise the new accounts values are put into the new account.

install

With npm do:

npm install accountdown-parser