Sign Up
To create new user accounts, the accounts.signup()
method can be called from anywhere on your server:
/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: () => {
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 and then inside of our set()
function, call to accounts.signup()
mapping values from input
to the options object for accounts.signup()
.
API Reference
Function API
Function API
accounts.signup(options: object) => Promise;
Arguments
-
options object
An
object
defining the parameters for the new user account.-
email_address string Required
A
string
defining the email address for the new user account. -
username string
A
string
defining the username for the new user account. -
password string Required
A
string
defining the password for the new user account. -
metadata object
An
object
defining additional metadata for the new user account.-
language string
A
string
defining the preferred language for the user as an ISO Language Code.
-
-