Skip to content

Commit 9df495d

Browse files
committed
added jshint and package.json file for better project
more detail about source files on readme
1 parent a15ffe4 commit 9df495d

File tree

7 files changed

+155
-53
lines changed

7 files changed

+155
-53
lines changed

.gitignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#Ignore JetBrains IDE files
2+
.idea
3+
4+
# Created by .ignore support plugin (hsz.mobi)
5+
### Node template
6+
# Logs
7+
logs
8+
*.log
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
15+
# Directory for instrumented libs generated by jscoverage/JSCover
16+
lib-cov
17+
18+
# Coverage directory used by tools like istanbul
19+
coverage
20+
21+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22+
.grunt
23+
24+
# node-waf configuration
25+
.lock-wscript
26+
27+
# Compiled binary addons (http://nodejs.org/api/addons.html)
28+
build/Release
29+
30+
# Dependency directory
31+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
32+
node_modules
33+
34+

.jshintrc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": true,
4+
"immed": true,
5+
"indent": 2,
6+
"latedef": true,
7+
"maxlen": 80,
8+
"maxparams": 5,
9+
"maxdepth": 4,
10+
"multistr": false,
11+
"newcap": true,
12+
"noarg": true,
13+
"nonbsp": true,
14+
"noempty": true,
15+
"nonew": true,
16+
"trailing": true,
17+
"undef": true,
18+
"unused": true,
19+
"eqnull": true,
20+
"node": true,
21+
"browser": true,
22+
"jquery": true,
23+
"boss": false,
24+
"quotmark": true,
25+
"camelcase": true,
26+
"freeze": true,
27+
"globals": {
28+
"describe": false,
29+
"it": false,
30+
"before": false,
31+
"beforeEach": false,
32+
"after": false,
33+
"afterEach": false
34+
}
35+
}

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,31 @@
1-
# Node-ssl
1+
# node-ssl-examples
22
Example code for using ssl with node
3+
4+
5+
Installing
6+
==========
7+
```bash
8+
npm install
9+
```
10+
Examples
11+
========
12+
```js
13+
node server
14+
```
15+
16+
17+
Runs a basic server that serve at port 9000.
18+
19+
This source code uses `express` framework.
20+
21+
22+
```js
23+
node socket
24+
```
25+
26+
27+
This source also serving a basic http server but in additionally using `socket.io`.
28+
29+
You have kill other server if you started it before, because both of these servers are using port 9000
30+
31+
As you can see as same as previous file. Just added `socket.io` configurations.

origins-transports.js

-34
This file was deleted.

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "node-ssl-example",
3+
"version": "0.0.1",
4+
"description": "A basic implementation of using SSL with Express",
5+
"author": {
6+
"name": "Veysel Şahin"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/nodejstr/node-ssl.git"
11+
},
12+
"dependencies": {
13+
"express": "^4.11.1",
14+
"socket.io": "^1.3.2"
15+
}
16+
}

server.js

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
var fs = require('fs'), path = require("path"), url = require("url")
2-
var connect = require('connect');
3-
var base_url = "https://veyselsahin.com.tr/api/";
1+
var fs = require('fs');
42
var options = {
5-
key: fs.readFileSync('/etc/pki/CA/certs/ca.key'),
6-
cert: fs.readFileSync('/etc/pki/CA/certs/ca.crt'),
7-
ca: fs.readFileSync('/etc/pki/tls/certs/ca-bundle.crt'),
8-
requestCert: true,
9-
rejectUnauthorized: false
3+
key: fs.readFileSync('/path/of/file/ca.key'),
4+
cert: fs.readFileSync('/path/of/file/ca.crt'),
5+
ca: fs.readFileSync('/path/of/file/ca-bundle.crt'),
6+
requestCert: true,
7+
rejectUnauthorized: false
108
};
119

12-
13-
var express = require('express'),
14-
app = express(),
15-
https = require('https'),
16-
server = https.createServer(options, app),
17-
io = require('socket.io').listen(server, {origins: '*:*'});
18-
19-
20-
21-
server.listen(9000);
10+
var express = require('express');
11+
var app = express();
12+
var https = require('https');
13+
var server = https.createServer(options, app);
14+
server.listen(9000);

socket.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var fs = require('fs');
2+
var options = {
3+
key: fs.readFileSync('/path/of/file/ca.key'),
4+
cert: fs.readFileSync('/path/of/file/ca.crt'),
5+
ca: fs.readFileSync('/path/of/file/ca-bundle.crt'),
6+
requestCert: true,
7+
rejectUnauthorized: false
8+
};
9+
10+
var express = require('express');
11+
var app = express();
12+
var https = require('https');
13+
var server = https.createServer(options, app);
14+
var io = require('socket.io');
15+
16+
io.listen(server, {origins: '*:*'});
17+
io.set('origins', '*veyselsahin.com.tr*:*');
18+
io.set('transports', [
19+
'websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'
20+
]);
21+
22+
app.configure(function () {
23+
app.use(function (req, res, next) {
24+
res.header('Access-Control-Allow-Origin', '*');
25+
res.header('Access-Control-Allow-Headers', 'origin, content-type, accept');
26+
next();
27+
});
28+
});
29+
server.listen(9000);

0 commit comments

Comments
 (0)