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

authr-sql

v0.1.2

Published

sql adapter for authr

Downloads

5

Readme

authr-sql

Introduction

This is a SQL adapter for authr.

It uses Sequelize and supports the following databases:

  • MySQL
  • MariaDB
  • PostgresSQL
  • SQLite

Installation

Use this adapter with authr and the database engine of your choice:

  1. Install authr, authr-sql, and a database engine npm install -save authr authr-sql mysql

  2. Set up authr

var Authr = require('authr');

// create a config object and create a new instance of authr with it
var config = {
    db: {
        type: 'mysql',
        host: 'localhost',
        port: 3306,
        database_name: 'authr',
        collection: 'users'
    }
}

var authr = new Authr(config);

var signup = {
    username: 'some_user',
    password: 'super_secure'
}

authr.signUp(signup, function(user){
    console.log(user); // returns the user inserted into nedb.
});

Config

If you are using fields outside of the default user config, you must specify a custom key in your config that defines the names and data types for each extra field.

Example:

// Use the default error message and user values
var config = {
    db:{
        type:'mysql',
        host:'localhost',
        port: 3306,
        database_name: 'authr',
        collection: 'users'
    },
    // Specify custom fields
    custom:{
        company_name: {type: 'string'}
    }
}

This setup will specify a SQL database that uses the default column names for the user information (e.g., username and password) and an extra field for company name.

authr-sql doesn't currently set default values for existing columns, so if you have a schema in your database already, make sure it is set to handle null values or you will get errors.

Some sort of validation may be added in the future to prevent those.