Installing Web Server
Installing Web Server
After install Node.js and npm Package Manager at previous step, now you have to install some tools, dependencies to run the Kindie web server:
Step 1: Open Kindie project by Visual Studio Code:
Note: You can toogle terminal by hot keys Ctrl + `
Step 2: Install Sails.js using npm Package Manager:
npm -g install sails
Sails.js is a small framework build on top of Express and Node.js framework. You can refer full document about SailsJs here:
https://sailsjs.com/get-started
Step 3: Install others npm Package Manager:
npm install
Step 4: Run MongoDB server
To start MongoDB, run mongod.exe. For example, from the Command Prompt:
C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe
This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.
You can refer full document about MongoDB here:
https://docs.mongodb.com/v3.6/installation/
Step 4: Config database and settings web server
If you need to test on dev eviroment, modify the config here:
config > env > development.js
4.1 Modify the database configuration:
// ssl: true, adapter: 'sails-mongo', host: '127.0.0.1', // defaults to `localhost` if omitted port: 27017, // defaults to 27017 if omitted user: '', //optional password: '', //optional database: 'kindiedb' // or omit if not relevant
4.2 Modify socket config ( For realtime chatbox mobile application): replay our config with your domain
onlyAllowOrigins: [ 'https://kindie.zs.test.zinimedia.com', 'http://localhost:1337', ],
4.3 Modify port: default port for development environment is 1337, you can change what you want
port: 1337,
4.2 Modify socket config ( For realtime chatbox mobile application): replay our config with your domain
Note: For production, you have to config the same things but with this file: config > env > production.js
Step 5: Config email server to send email
service: "Mailgun", auth: { user: "no-reply@yourdomain", //pass: "key-xxx" pass: "yourpassword" }, templateDir: "api/emailTemplates", from: "no-reply@yourdomain", testMode: false, ssl: true
By default we are using Mailgun service, you need to register an account via https://www.mailgun.com/ then input the username/password here. Mailgun supports us to send with 10,000 free emails and a 100 free validations every month.
Step 6: Run the app
From terminal console Visual Studio Code, run:
sails lift
will run sails project on port 1337 by default.
If you get the log message like this, congratulation, you installed successfully the Kindy Web server.
Note: For production, you can run by command sails lift --prod
Note: On production server, You can create .env file and define also all the configurations via .env file at root folder:
MONGO_HOST="127.0.0.1" MONGO_PORT="27017" MONGO_USER="" MONGO_PASSWORD="" MONGO_DB_NAME="kindiedb" SAILS_BASE_URL="http://localhost:1337" SAILS_PORT="1337" MAIL_SERVICE="Mailgun" MAIL_AUTH_USER="no-reply@yourdomain.com" MAIL_AUTH_PASSWORD="xxx" MAIL_FROM="no-reply@yourdomain.com" PATH_FOLDER="/var/www/web-kindie/"
Have fun!