Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcollina/users-pg
Store and authenticate users with postgres
https://github.com/mcollina/users-pg
Last synced: 13 days ago
JSON representation
Store and authenticate users with postgres
- Host: GitHub
- URL: https://github.com/mcollina/users-pg
- Owner: mcollina
- License: mit
- Created: 2015-06-30T10:02:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-04-21T08:58:09.000Z (over 6 years ago)
- Last Synced: 2024-05-02T01:06:04.404Z (8 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# users-pg
Manage Users, with node and postgres
## Install
```
npm install @matteo.collina/users-pg --save
```*
buildUsers()
*users.put()
*users.get()
*users.authenticate()
*users.createSchema()
*users.dropSchema()
-------------------------------------------------------
### buildusers(connectionString)The factory for the users module, you can just pass through a
[pg](http:/npm.im/pg) connection string.Example:
```js
var connString = 'postgres://localhost/users_tests'
var users = require('@matteo.collina/users-pg')(connString)
```-------------------------------------------------------
### users.put(object, callback(err, user))Adds or updates an user. An user can have three properties:
1. the `'id'`, which needs to be set only for existing users
2. the `'username'`
3. the `'status'`, which can be any of
`'wait'`, `'operational'` and `'error'`.Validation is provided by [Joi](http://npm.im/joi), and a Joi error
object will be provided in case of validation errors.The returned user includes the `id`, if missing.
-------------------------------------------------------
### users.get(id, callback(err, user))Fetches an users, returns a
[`boom.notFound`](https://www.npmjs.com/package/boom#boom-notfound-message-data)
if not present.-------------------------------------------------------
### users.authenticate(user, callback(err, result, user))Fetches a user, hashes the password with the stored salt and matches it
against the database. `result` is `true` if the match is successful,
`false` otherwise.
Returns [`boom.notFound`](https://www.npmjs.com/package/boom#boom-notfound-message-data)
if not present.-------------------------------------------------------
### users.createSchema(callback(err))Create the schema in PostgreSQL for this module.
-------------------------------------------------------
### users.dropSchema(callback(err))Drop the schema in PostgreSQL for this module.
## License
MIT