A boilerplate for the Sails.JS API framework. This particular boiler plate provides a /users
endpoint which supports:
- Creating/updating users
- Login authentication
- Password resets via e-mail
Additionally it supports JSON web tokens for ACL policy validation and stateless transactions, as well as hassle free sending of HTML e-mails.
git clone git@github.com:jcharrell/sailsjs-api-boilerplate.git
cd sailsjs-api-boilerplate
npm install
(may needsudo
).npm run dev
- Accessible at at
http://localhost:3000
Sails.js Installation - Error
--------------------------------------------------------
Unable to check your npm-version
Running this line in your terminal should do the trick:
curl -L https://npmjs.org/install.sh | sudo sh
Then try npm install
again and sails should install with no errors.
$ npm run dev
-bash: sails: command not found
You may need to install sails.js globally. If so run this:
sudo npm install sails -g
Some configurations will need to be made in order to tailor the API for your own needs.
Project settings include the project title, JSON web token secret, consuming website URL, and the returning URI for password reset e-mails.
Database connection settings are defined within connections.js
. There are ample examples of defining database connections within the configuration file itself.
Connection details, such as username
and password
, can and are overridden in environment specific configuration files which are located in /config/env/*.js
.
The model settings define the connection to be used for the project, as well as the data migration method. See Connection Settings
for more information on defining connections.
Policy settings define ACL policies for each controller within the API. Policies have been defined and configured for the existing UserController
controller. In order to create or modify existing policies, see /api/policies
.
This consists of the nodemailer
transporter settings. By default, the boilerplate API utilizes a SMTP pool to deliver e-mails.
####Postman Collection
Included is a Postman collection, with example requests to the /users
API endpoint, which is located at /sails-boilerplate-api.json.postman_collection
.
To import a collection into Postman, ensure that the Collections
tab, in the top left, is selected. To the right of that tab, choose the Import Collection
icon. Simply drag the collection file to the import modal or browse to the collection directly.
####Sails Documentation Documentation specific to the Sails.js framework may be found here.