Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisaacson/userific-postgres
Implement the Userific interface using a postgres database to store user data
https://github.com/nisaacson/userific-postgres
Last synced: about 1 month ago
JSON representation
Implement the Userific interface using a postgres database to store user data
- Host: GitHub
- URL: https://github.com/nisaacson/userific-postgres
- Owner: nisaacson
- Created: 2013-06-16T22:27:38.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-09T19:45:44.000Z (over 11 years ago)
- Last Synced: 2024-09-16T10:04:59.099Z (about 2 months ago)
- Language: JavaScript
- Size: 309 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Userfic PostGRES backend
[![Build Status](https://travis-ci.org/nisaacson/userific-postgres.png)](https://travis-ci.org/nisaacson/userific-postgres)
[![Dependency Status](https://david-dm.org/nisaacson/userific-postgres.png)](https://david-dm.org/nisaacson/userific-postgres)Manage users using a postgres database. This module implements the abstract [Userific](https://github.com/nisaacson/userific) interface
# Installation
```bash
npm install -S userific-postgres
```# Requirements
This module requires that you have already have a table setup to handle your users. You can create a default users table using the text sql dump file located at `./share/users.sql`. To create a users table with the required columns, execute the following command in the root of this module. This will create a users table in the specified database with all the required columns
```bash
psql -d -f ./share/users.sql
```# Usage
```javascript
var UserificPostGRES = require('userific-postgres')
var config = {
host: 'localhost', // the host of the postgres server
port: '27017', // the port of the postgres server
db: 'userific-postgres-test', // the postgres database to use,
table: 'users' // the table name of where users are stored in the database
user: 'postgres username here', // optional
pass: 'postgres password here', // optional
useAccessTokens: true // optional, when true users must supply a valid accessToken value when registering
}var backend = new UserificPostGRES(config)
// you must call the asynchronous init function before this postgres backend can be used
backend.init(function(err) {
// backend implements all the interface methods of the abstract Userific module
var registerData = {
email: '[email protected]',
password: 'barPassword',
accessToken: 'valid access token value here'
}
backend.register(registerData, function(err, user) {
if (err) {
inspect(err, 'error registering user via the userific mongoose backend')
return
}
inspect(user, 'registered user correctly')
})
})
```# Test
```bash
# install development dependencies
npm install
# run tests
npm test
```