@joystick.js/node

Signup

Create new user accounts from anywhere on your server.

To create new user accounts, the accounts.signup() method can be called from anywhere on your server.

Example Usage

api/users/setters.js

import joystick, { accounts } from '@joystick.js/node';

const setters = {
  create_user: {
    input: {
      email_address: {
        type: 'string',
        required: true,
      },
      password: {
        type: 'string',
        required: true,
      },
      name: {
        type: 'object',
        required: true,
        fields: {
          first: {
            type: 'string',
            required: true,
          },
          last: {
            type: 'string',
            required: true,
          }
        }
      }
    },
    set: (input = {}) => {
      return accounts.signup({
        email_address: input?.email_address,
        username: `${input?.name?.first?.charAt(0)?.toLowerCase()}${input?.name?.last?.toLowerCase()}`,
        password: input?.password,
        metadata: {
          name: input?.name,
        }
      });
    },
  },
};

Above, inside of a hypothetical setter create_user, we take in the input for a new user and validate it. Then, inside of our set() function, we call accounts.signup() mapping values from input to the options object.

API

Definition

accounts.signup(options: object) => Promise

Parameters

options object required
An object defining the parameters for the new user account.
email_address string required
The email address for the new user account.
username string
The username for the new user account.
password string required
The password for the new user account.
metadata object
Additional metadata for the new user account.
language string
Preferred language for the user as an ISO Language Code.