Updated from Sails v0.12 to Sails v1 by Francesc Busquets
-
Generated from scratch with sails-generate
-
Created custom models for "restaurants" and "reviews" in
api/models
-
Created a simple API test suite in
assets/test
-
Created two scripts (
utils/generate-restaurants.js
andutils/generate-reviews.js
), useful for generating the restaurants API test data. To reset the database at its original state, just stop Sails (if running) and launch:npm run reset-db
The steps to reproduce to launch the API server are: Install Sails v1 globally:
npm install -g sails
Install the NPM dependencies:
npm install
Launch Sails in development mode:
sails lift
To launch Sails in production mode, use:
npm run start
In both cases, the API test suite will be available at:
http://localhost:1337/test
To start the server as a daemon service, just install pm2 and launch:
pm2 start ecosystem.config.js
Notice that the PUT
method has been replaced by PATCH
, as proposed by Sails v1.
Original README follows (it must be updated!):
curl "http://localhost:1337/restaurants"
curl "http://localhost:1337/restaurants/{3}"
Local server
- Node.js
- Sails.js
- Brandy Lee Camacho - Technical Project Manager
- David Harris - Web Services Lead
- Omar Albeik - Frontend engineer
Location of server = /server Server depends on node.js LTS Version: v6.11.2 , npm, and sails.js Please make sure you have these installed before proceeding forward.
Great, you are ready to proceed forward; awesome!
Let's start with running commands in your terminal, known as command line interface (CLI)
# npm i
# npm i sails -g
# node server
debug: Environment : development debug: Port : 1337
http://localhost:1337/restaurants/
http://localhost:1337/restaurants/?is_favorite=true
http://localhost:1337/restaurants/<restaurant_id>
http://localhost:1337/reviews/?restaurant_id=<restaurant_id>
http://localhost:1337/reviews/
http://localhost:1337/reviews/<review_id>
http://localhost:1337/reviews/
{
"restaurant_id": <restaurant_id>,
"name": <reviewer_name>,
"rating": <rating>,
"comments": <comment_text>
}
http://localhost:1337/restaurants/<restaurant_id>/?is_favorite=true
http://localhost:1337/restaurants/<restaurant_id>/?is_favorite=false
http://localhost:1337/reviews/<review_id>
{
"name": <reviewer_name>,
"rating": <rating>,
"comments": <comment_text>
}
http://localhost:1337/reviews/<review_id>
If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue to our Waffle Dashboard. Even better you can submit a Pull Request with a fix :)