Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Submission for TNTP by Sunil Jadhav #5

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Stevens-CS546

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions Start up instruction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Please clone
# Install all necessary packages
npm Install

# to run the application
node server.js (in the terminal in the same directory)
go to browser and hit localhost:3000
6 changes: 6 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var exports = module.exports = {};

exports.mongoConfig = {
serverUrl: "mongodb://localhost:27017/",
database: "lab7"
};
47 changes: 47 additions & 0 deletions data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var MongoClient = require('mongodb').MongoClient,
settings = require('./config.js'),
Promise = require('promise'),
Guid = require('guid');

var fullMongoUrl = settings.mongoConfig.serverUrl + settings.mongoConfig.database;

var exports = module.exports = {};

MongoClient.connect(fullMongoUrl)
.then(function(db) {
var chat_collection = db.collection("tntpchatroomdb1");

// setup your body
exports.createComment = function(_comment, _name) {
console.log('In Create Comment');
// throws an error if there has been invalid input
if (_comment == '' || _comment == undefined) {
console.log('Comment was empty.');
return Promise.reject('Can not enter EMPTY string');
} else if (_name == '' || _name == undefined) {
console.log('name was empty.');
return Promise.reject('name can not be null.');
} else {
// return a promise that resolves the new comment
var _date = new Date();
console.log('Create a post at : ' + _date);
var jsonData = {
_id: Guid.create().toString(),
comment: _comment,
name: _name,
date: _date
};
return chat_collection.insertOne(jsonData).then(function(newDoc) {
return newDoc.insertedId;
});
}

};

exports.getAllComments = function() {
return chat_collection.find().sort({ date: -1 }).toArray().then(function(params) {
//console.log(" All posts : " + JSON.stringify(params));
return params;
});
}
});
1 change: 1 addition & 0 deletions node_modules/.bin/har-validator

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-conv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-sign

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-verify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 170 additions & 0 deletions node_modules/accepts/HISTORY.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions node_modules/accepts/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading