You're viewing old version number 4. - Current version

1 min

Creating Veery API NodeJS

Jan 24, 2017

http://veeryapinodejs.soupmode.com


edit dns.
create cname record:
hostname = veeryapinodejs
is an alias of = @

cd into /home/veery

mkdir Veery-API-NodeJS

cd into Veery-API-NodeJS

mkdir js

cd js

mkdir node_modules, although it might get automatically created later

create package.json

{
"name" : "Veery-API-NodeJS",
"version" : "1.0.0",
"dependencies" : {
"express" : "4.14.0",
"body-parser" : "1.16.0",
"html-entities" : "1.2.0",
"querystring" : "0.2.0"
}
}

unsure if i need all of those packages. i looked up the most recent package version numbers at https://www.npmjs.com

the command "npm install" will read the package.json file, create node_modules directory, and place the downloaded the packages listed in the json file in that directory.

within the same "js" directory, create dispatch.js

var express = require('express'),
bodyParser = require('body-parser'),
path = require('path'),

app = express();

app.use(bodyParser.urlencoded({ extended: true })); // parse application/x-www-form-urlencoded

app.get('/', function(req, res){
res.send('hello world');
});

app.listen(3002);

cd /etc/nginx/sites-available

create veeryapinodejs.soupmode.com

##########
# veery api nodejs
##########

  1. veeryapinodejs.soupmode.com-info

server {
listen 80;
server_name veeryapinodejs.soupmode.com;

location ~ ^/(css/|javascript/|images/) {
root /home/veery/Veery-Client-NodeJS/root;
access_log off;
expires max;
}

location / {
default_type text/html;
error_page 404 = @fallback;
}

location @fallback {
proxy_pass http://veeryapinodejs.soupmode.com:3002;
}

}

ln -s /etc/nginx/sites-available/veeryapinodejs.soupmode.com /etc/nginx/sites-enabled/veeryapinodejs.soupmode.com

service nginx restart

forever start dispatch.js

more about forever commands:

usage: forever [start | stop | stopall | list] [options] SCRIPT [script options]

options:
start start SCRIPT as a daemon
stop stop the daemon SCRIPT
stopall stop all running forever scripts
list list all running forever scripts

forever list

http://jothut.com/cgi-bin/junco.pl/blogpost/36422/10Nov2014/Learning-NodeJS-Programming

From JR's : articles
243 words - 2341 chars - 1 min read
created on
updated on - #
source - versions



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: Nov 15, 2024 - 3:35 p.m. EST