Manage Users, with node and postgres
npm install @matteo.collina/users-pg --save
The factory for the users module, you can just pass through a pg connection string.
Example:
var connString = 'postgres://localhost/users_tests'
var users = require('@matteo.collina/users-pg')(connString)
Adds or updates an user. An user can have three properties:
- the
'id'
, which needs to be set only for existing users - the
'username'
- the
'status'
, which can be any of'wait'
,'operational'
and'error'
.
Validation is provided by Joi, and a Joi error object will be provided in case of validation errors.
The returned user includes the id
, if missing.
Fetches an users, returns a
boom.notFound
if not present.
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
if not present.
Create the schema in PostgreSQL for this module.
Drop the schema in PostgreSQL for this module.
MIT