Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: preg_match(): Unknown modifier '-' in /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php on line 783

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794

Warning: Cannot modify header information - headers already sent by (output started at /home/akl1986/public_html/support/wp-content/plugins/redux-framework/redux-core/inc/extensions/metaboxes/class-redux-extension-metaboxes.php:783) in /home/akl1986/public_html/support/wp-includes/rest-api/class-wp-rest-server.php on line 1794
{"id":2709,"date":"2019-12-11T00:27:41","date_gmt":"2019-12-11T00:27:41","guid":{"rendered":"https:\/\/support.aklwebhost.com\/?post_type=manual_kb&p=2709"},"modified":"2019-12-11T00:29:34","modified_gmt":"2019-12-11T00:29:34","slug":"setup-sails-js-for-development-on-centos-7","status":"publish","type":"manual_kb","link":"https:\/\/support.aklwebhost.com\/knowledgebase\/setup-sails-js-for-development-on-centos-7\/","title":{"rendered":"Setup Sails.js for Development on CentOS 7"},"content":{"rendered":"

Introduction<\/h3>\n

Sails.js is a MVC framework for Node.js, similar to Ruby on Rails. It makes for developing modern applications very quickly, and is best suited for real-time applications like leaderboards and chat.<\/p>\n

Installation<\/h3>\n

Update the system.<\/p>\n

sudo yum update -y\r\n<\/code><\/pre>\n

Install the necessary packages.<\/p>\n

sudo yum install curl git\r\n<\/code><\/pre>\n

Install Node.js and NPM<\/h4>\n

Enable the EPEL repository.<\/p>\n

sudo yum install epel-release\r\n<\/code><\/pre>\n

Once the EPEL repository is enabled, run the following command to add the Node.js v8 LTS repository.<\/p>\n

curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo -E bash -\r\n<\/code><\/pre>\n

Install Node.js v8 LTS, as well as NPM.<\/p>\n

sudo yum -y install nodejs\r\n<\/code><\/pre>\n

Install build tools.<\/p>\n

sudo yum install gcc-c++ make\r\n<\/code><\/pre>\n

To verify if the Node.js and NPM installation was successful, issue the following command.<\/p>\n

node -v\r\nnpm -v\r\n<\/code><\/pre>\n

The output will be similar to the following.<\/p>\n

v8.x.x\r\n3.x.x\r\n<\/code><\/pre>\n

Install Sails.js<\/h4>\n

To install the latest stable release of sails, issue the following command.<\/p>\n

sudo npm -g install sails\r\n<\/code><\/pre>\n

Create a Test Application<\/h3>\n

Let’s create a boilerplate application called\u00a0testSailsApp<\/code>\u00a0in the directory where you would like your app to be located, for example\u00a0\/var\/www<\/code>, and then run the following command.<\/p>\n

sails new testSailsApp\r\n<\/code><\/pre>\n

To start the application, you will need to change into the project directory,\u00a0testSailsApp<\/code>, and then start the server.<\/p>\n

cd testSailsApp\r\nsails lift\r\n<\/code><\/pre>\n

You will see the following on your command prompt.<\/p>\n

info: Starting app...\r\ninfo:\r\ninfo:\r\ninfo:    Sails              <|\r\ninfo:    v1.0.0             |\\\r\ninfo:                       \/|.\\\r\ninfo:                      \/ || \\\r\ninfo:                    ,'  |'  \\\r\ninfo:                 .-'.-==|\/_--'\r\ninfo:                 `--'-------'\r\ninfo:    __---___--___---___--___---___--___\r\ninfo:  ____---___--___---___--___---___--___-__\r\ninfo:\r\ninfo: Server lifted in `\/root\/testSailsProject`\r\ninfo: To see your app, visit http:\/\/localhost:1337\r\ninfo: To shut down Sails, press <CTRL> + C at any time.\r\n<\/code><\/pre>\n

To access your app from a web browser use\u00a0http:\/\/[aklwebhost-vm-ip-address]:1337<\/code>. You will see a page that says “A brand new App”.<\/p>\n

Playing Around<\/h3>\n

What makes Sails great is its ability to create API’s, using its\u00a0generate<\/code>\u00a0tool, that can be used in production environments without even starting to write code. In production environments for complex apps, there will be policies that you still need to configure to enforce the behavior that you want.<\/p>\n

Issue\u00a0CTRL<\/kbd>\u00a0+\u00a0C<\/kbd>\u00a0from the terminal to stop “testSailsApp”. Run\u00a0sails generate api tweet<\/code>\u00a0to create an API called\u00a0tweet<\/code>. You terminal session will be similar to the following.<\/p>\n

root@install:~\/testSailsProject# sails generate api tweet\r\ninfo: Created a new api!\r\nroot@install:~\/testSailsProject#\r\n<\/code><\/pre>\n

Run\u00a0sails lift<\/code>\u00a0to start the test app again. Then, browse to\u00a0http:\/\/[aklwebhost-vm-ip-address]:1337\/tweet<\/code>. If you receive a migration prompt, choose option 2.<\/p>\n

You will see an empty JSON array\u00a0[]<\/code>\u00a0on your browser because there are currently no tweets in the system.<\/p>\n

Let’s add some tweets to system via our browser address bar.<\/p>\n

First, browse to\u00a0http:\/\/[aklwebhost-vm-ip-address]:1337\/tweet\/create?name=mrLami&msg=aklwebhost Hosting Rocks<\/code>\u00a0and hit\u00a0ENTER<\/kbd>.<\/p>\n

Then, browse to\u00a0http:\/\/[aklwebhost-vm-ip-address]:1337\/tweet\/create?name=theaklwebhost&msg=TGIF half off coupons<\/code>\u00a0and again hit\u00a0ENTER<\/kbd>.<\/p>\n

Now browse to\u00a0http:\/\/[aklwebhost-vm-ip-address]:1337\/tweet<\/code>\u00a0to view the tweets we just added, and you will see the JSON document below.<\/p>\n

[\r\n  {\r\n    \"name\": \"mrLami\",\r\n    \"msg\": \"AKLWEB HOST Hosting Rocks\",\r\n    \"createdAt\": \"2014-11-03T03:49:07.353Z\",\r\n    \"updatedAt\": \"2014-11-03T03:49:07.353Z\",\r\n    \"id\": 1\r\n  },\r\n  {\r\n    \"name\": \"theAKLWEBHOST\",\r\n    \"msg\": \"TGIF half off coupons\",\r\n    \"createdAt\": \"2014-11-03T03:49:29.411Z\",\r\n    \"updatedAt\": \"2014-11-03T03:49:29.411Z\",\r\n    \"id\": 2\r\n  }\r\n]\r\n<\/code><\/pre>\n

Conclusion<\/h3>\n

There is much more that Sails.js can do even before requiring any code. This includes sorting the list of results, and limiting the amount of records received. Sails makes developing realtime apps fun, and a lot quicker to build. Spin up an instance on a AKLWEB HOST VM and start sailing.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[106,388],"manual_kb_tag":[405],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2709"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2709"}],"version-history":[{"count":4,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2709\/revisions"}],"predecessor-version":[{"id":2713,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2709\/revisions\/2713"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2709"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2709"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}