Skip to content

Commit 5392e8a

Browse files
balanced update attempts
1 parent ebabc31 commit 5392e8a

File tree

6 files changed

+27
-115
lines changed

6 files changed

+27
-115
lines changed

README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
# RESTfullAPI
1+
# SchoolCom Second round conding task
2+
[nodejs]: https://docs.npmjs.com/getting-started/installing-node
3+
[mlab]: http://docs.mlab.com/ops/
4+
5+
**Quick start guide list:**
6+
7+
* [Install NodeJs][nodejs]
8+
* [Create mlab account for mongoDB][mlab]
9+
* Install jsonwebtoken and bcrypt module
10+
* npm install jsonwebtoken
11+
* npm install bcrypt
12+
13+
14+
**API check list**
15+
16+
* http://localhost:3000/userlist
17+
18+
19+
20+

api/controllers/todoListController.js

-54
This file was deleted.

api/models/todoListModel.js

-24
This file was deleted.

api/routes/todoListRoutes.js

-24
This file was deleted.

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "todolistapi",
2+
"name": "schoolcom",
33
"version": "1.0.0",
4-
"description": "Restful todoListApi",
4+
"description": "Restful SchoolCom",
55
"main": "index.js",
66
"scripts": {
77
"test": "\"echo \\\"Error: no test specified\\\"&& exit 1\""
@@ -12,8 +12,7 @@
1212
},
1313
"keywords": [
1414
"\"RESTfull\"",
15-
"\"API\"",
16-
"\"Tutorial\""
15+
"\"API\""
1716
],
1817
"author": "Pushpendra Kumar",
1918
"license": "ISC",

server.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ var express = require('express'),
22
app = express(),
33
port = process.env.PORT || 3000,
44
mongoose = require('mongoose'),
5-
Task = require('./api/models/todoListModel'),
65
User = require('./api/models/userModel'),
76
bodyParser = require('body-parser');
87
jsonwebtoken = require("jsonwebtoken");
@@ -11,12 +10,11 @@ mongoose.Promise = global.Promise;
1110
mongoose.connect('mongodb://school:school@ds249079.mlab.com:49079/schoolcom');
1211
app.use(bodyParser.urlencoded({ extended: true }));
1312
app.use(bodyParser.json());
13+
//Middleware for user validation start...
1414
app.use(function(req, res, next){
15-
1615
if(req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0]=='JWT'){
1716
jsonwebtoken.verify(req.headers.authorization.split(' ')[1], 'schoolcom',function(err, decode){
1817
if(err){
19-
console.log(err);
2018
req.user = undefined;
2119
}
2220
req.user = decode;
@@ -27,11 +25,9 @@ app.use(function(req, res, next){
2725
next();
2826
};
2927
});
30-
var routes = require('./api/routes/todoListRoutes');
28+
//Middleware for user validation end.....
29+
var routes = require('./api/routes/schoolcomRoutes');
3130
routes(app);
32-
33-
3431
app.listen(port);
35-
36-
console.log('todo list RESTful API server started on: ' + port);
32+
console.log('SchoolCom API server started on: ' + port);
3733

0 commit comments

Comments
 (0)