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

1 min

Creating Veery API NodeJS

Jan 24, 2017

http://veeryapinodejs.soupmode.com

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

From JR's : articles
182 words - 1821 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 - 1:25 p.m. EST