├── .gitignore ├── LICENSE ├── README.md ├── day-10-crypto-module-part-2 ├── enc-priv-dec-pub.js ├── enc-pub-dec-priv.js ├── priv.key ├── pub.key ├── symmetric-enc-dec.js ├── user.priv.key └── user.pub.key ├── day1-TheBeginning ├── hello-world-in-node.js ├── index.html ├── index.pdf ├── serve-html.js ├── serve-json.js ├── serve-mp3.js ├── serve-mp4.js ├── serve-pdf.js ├── serve-string.js └── simple-server-in-node.js ├── day11-express-framework ├── content.txt ├── request-with-params.js ├── routes_in_express.js └── simple-server-express.js ├── day13-signup-form ├── package.json ├── public │ ├── index.html │ ├── style.css │ └── success.html └── server.js ├── day14-socket.io ├── changing-css-dynamically │ ├── css-color-admin.html │ ├── css-color-server.js │ └── css-color.html └── real-time-quotes │ ├── admin.html │ ├── index.html │ └── server.js ├── day16-zlib ├── newfile.txt ├── newfile.txt.gz ├── unzip-using-zlib.js ├── unzip.txt └── zip-using-zlib.js ├── day17-crud-mysql ├── create-table-mysql.js ├── delete-mysql.js ├── demo.js ├── drop-table-mysql.js ├── insert-mysql.js ├── package-lock.json ├── read-mysql.js └── update-mysql.js ├── day18-callbacks ├── blocking-code.js ├── non-blocking-code.js └── output.txt ├── day19-queryString ├── qs-parse.js └── qs-stringify.js ├── day2-filesystem ├── data.txt.txt ├── fs.appendFile.js ├── fs.appendFileSync.js ├── fs.readFile.js ├── fs.readfileSync.js ├── fs.rename.js ├── fs.renameSync.js ├── fs.unlink.js ├── fs.unlinkSync.js ├── fs.writeFile.js └── fs.writeFileSync.js ├── day20-timers ├── clearImmediate().js ├── clearInterval().js ├── clearTimeout().js ├── setImmediate().js ├── setInterval().js └── setTimeout().js ├── day21-buffers ├── buffer.alloc.js ├── buffer.allocUnsafe.js ├── buffer.compare.js ├── buffer.concat.js ├── buffer.copy.js ├── buffer.equals.js ├── buffer.fill.js ├── buffer.from.js ├── buffer.indexOf.js ├── buffer.length.js ├── buffer.slice.js ├── bufferToJSON.js └── bufferToString.js ├── day22-string-decoder └── write.js ├── day24-child-processes ├── master-exec.js ├── master-execFile.js ├── master-fork.js ├── master-spawn.js └── slave.js ├── day25-clusters ├── cluster.js └── demo.js ├── day27-assert ├── assert-1.js ├── assert-snippet-false.js ├── assert-snippet-true.js ├── assert.deepEqual.js ├── assert.deepStrictEqual.js ├── assert.equal.js ├── assert.fail.js ├── assert.ifError.js ├── assert.js ├── assert.notDeepEqual.js ├── assert.notDeepStrictEqual.js ├── assert.notEqual.js ├── assert.notStrictEqual.js ├── assert.ok.js ├── assert.strictEqual.js └── assert.throw.js ├── day28-Getting-tweets-using-node ├── package-lock.json ├── package.json ├── public │ ├── index.html │ └── style.css └── server.js ├── day29-dropbox-file-upload ├── dropbox-file-upload.js ├── package-lock.json └── package.json ├── day3-regular-expressions ├── data.html ├── data.txt ├── regex-find-string.js ├── regex-find-tags.js ├── regex-validate-email.js ├── regex-validate-hexadecimal.js └── regex-validate-password.js ├── day30-github-api-with-nodejs └── github-auth.js ├── day4-console ├── console.clear().js ├── console.count().js ├── console.countReset().js ├── console.error().js ├── console.log().js ├── console.time().js ├── console.warn().js └── create-custom-console.js ├── day6-array-methods ├── concat.js ├── create-array.js ├── every.js ├── filter.js ├── find.js ├── forEach.js ├── indexOf.js ├── join.js ├── lastIndexOf.js ├── pop.js ├── push.js ├── reduce.js ├── reverse.js ├── shift.js ├── slice.js ├── sort.js ├── splice-add.js ├── splice-remove.js └── unshift.js └── day9-crypto-module ├── createCipher.js ├── crypto.getHashes.js ├── data.txt ├── getCiphers.js ├── getCurves.js ├── getDiffieHellman.js ├── hashing_a_file.js ├── hmac_md5.js ├── hmac_on_file.js ├── hmac_sha256.js ├── hmac_sha512.js ├── hmac_whirlpool.js ├── md5.js ├── ripemd.js ├── sha1.js ├── sha1WithRSAEncryption.js ├── sha224.js ├── sha256.js ├── sha384.js ├── sha512.js └── whirlpool.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (http://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 nodejsera 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 30 days of node - Nodejs tutorial series 2 | 30 days of node is a code base tutorial series for node.js which deals with providing a practical project based learning experience as well as talking about its conceptual details. 3 | 4 | 1. [Day 1 - The Beginning](https://www.nodejsera.com/nodejs-tutorial-day1-thebeginning.html) 5 | 2. [Day 2 - File System in node.js](https://www.nodejsera.com/nodejs-tutorial-day2-filesystem.html) 6 | 3. [Day 3 - Regular expressions in node.js](https://www.nodejsera.com/nodejs-tutorial-day3-regular-expressions.html) 7 | 4. [Day 4 - Console module in node.js](https://www.nodejsera.com/nodejs-tutorial-day4-console-module.html) 8 | 5. [Day 5 - All about errors](https://www.nodejsera.com/nodejs-tutorial-day5-all-about-errors.html) 9 | 6. [Day 6 - Array methods](https://www.nodejsera.com/nodejs-tutorial-day6-array-methods.html) 10 | 7. [Day 7 - All about NPM](https://www.nodejsera.com/nodejs-tutorial-day7-all-about-npm.html) 11 | 8. [Day 8 - Publishing package on NPM](https://www.nodejsera.com/nodejs-tutorial-day8-publishing-on-npm.html) 12 | 9. [Day 9 - Crypto Module ( Hashing and HMAC)](https://www.nodejsera.com/nodejs-tutorial-day9-crypto-module.html) 13 | 10. [Day 10 - Crypto Module ( Encryption and Decryption )](https://www.nodejsera.com/nodejs-tutorial-day10-crypto-module-symmetric-asymmetric-encryption-decryption.html) 14 | 11. [Day 11 - Express Framework](https://www.nodejsera.com/nodejs-tutorial-day11-express-framework.html) 15 | 12. [Day 12 - CRUD in MongoDB using node.js](https://www.nodejsera.com/nodejs-tutorial-day12-crud-in-mongodb.html) 16 | 13. [Day 13 - Sign Up form in node.js](https://www.nodejsera.com/nodejs-tutorial-day13-signup-using-nodejs-express-mongodb.html) 17 | 14. [Day 14 - Introduction to socket.io](https://www.nodejsera.com/nodejs-tutorial-day14-introduction-to-socket-io.html) 18 | 15. [Day 15 - All about streams](https://www.nodejsera.com/nodejs-tutorial-day15-all-about-streams.html) 19 | 16. [Day 16 - Zlib Module](https://www.nodejsera.com/nodejs-tutorial-day16-zlib-module.html) 20 | 17. [Day 17 - CRUD in MySQL using node.js](https://www.nodejsera.com/nodejs-tutorial-day17-crud-in-mysql.html) 21 | 18. [Day 18 - Concepts of callbacks in node.js](https://www.nodejsera.com/nodejs-tutorial-day18-callbacks.html) 22 | 19. [Day 19 - Query String in node.js](https://www.nodejsera.com/nodejs-tutorial-day19-query-string.html) 23 | 20. [Day 20 - Timers in node.js](https://www.nodejsera.com/nodejs-tutorial-day20-timers.html) 24 | 21. [Day 21 - Buffers in node.js](https://www.nodejsera.com/nodejs-tutorial-day21-buffers.html) 25 | 22. [Day 22 - String Decoder Module in node.js](https://www.nodejsera.com/nodejs-tutorial-day22-string-decoder.html) 26 | 23. [Day 23 - Debugger module in node.js](https://www.nodejsera.com/nodejs-tutorial-day23-debuggers.html) 27 | 24. [Day 24 - Child Processes in node.js](https://www.nodejsera.com/nodejs-tutorial-day24-child-processes.html) 28 | 25. [Day 25 - Clusters in node.js](https://www.nodejsera.com/nodejs-tutorial-day25-clusters.html) 29 | 26. [Day 26 - OS module in node.js](https://www.nodejsera.com/nodejs-tutorial-day26-os-module.html) 30 | 27. [Day 27 - Assert module in node.js](https://www.nodejsera.com/nodejs-tutorial-day27-assert.html) 31 | 28. [Day 28 - Getting Tweets using node.js](https://www.nodejsera.com/nodejs-tutorial-day28-getting-tweets-using-nodejs.html) 32 | 29. [Day 29 - Uploading file to dropbox using node.js](https://www.nodejsera.com/nodejs-tutorial-day29-uploading-files-dropbox.html) 33 | 30. [Day 30 - Github API with node.js](https://www.nodejsera.com/nodejs-tutorial-day30-github-api-with-node.html) 34 | -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/enc-priv-dec-pub.js: -------------------------------------------------------------------------------- 1 | /** 2 | Example of Asymmetric encryption 3 | Encrypting using private key and decrypting using public key 4 | File Name : enc-priv-dec-pub.js 5 | Author : @nodejsera 6 | **/ 7 | //Including the required modules 8 | var crypto = require('crypto'); 9 | var fs = require('fs'); 10 | 11 | //Reading the Private Key 12 | privK = { 13 | key: fs.readFileSync('priv.key').toString(), 14 | passphrase: 'nodejsera' 15 | } 16 | //Passing the text to be encrypted using private key 17 | var buf = Buffer.from('rishabh', 'utf8'); 18 | 19 | //Encrypting the text 20 | secretData = crypto.privateEncrypt(privK, buf); 21 | //printing the encrypted text 22 | console.log(secretData.toString('utf8')); 23 | //reading the Public key 24 | pubK = fs.readFileSync('pub.key').toString(); 25 | //decrypting the text using public key 26 | origData = crypto.publicDecrypt(pubK, secretData) 27 | //Printing the original content 28 | console.log(origData.toString()); -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/enc-pub-dec-priv.js: -------------------------------------------------------------------------------- 1 | /** 2 | Example of Asymmetric encryption 3 | Encrypting using public key and decrypting using private key 4 | File Name : enc-pub-dec-priv.js 5 | Author : @nodejsera 6 | **/ 7 | //Including the required modules 8 | var crypto = require('crypto'); 9 | var fs = require('fs'); 10 | 11 | //Reading the Public Key 12 | pubK = privK = fs.readFileSync('pub.key').toString(); 13 | 14 | //Passing the text to be encrypted using private key 15 | var buf = Buffer.from('This is secret code', 'utf8'); 16 | 17 | //Encrypting the text 18 | secretData = crypto.publicEncrypt(pubK, buf); 19 | //printing the encrypted text 20 | console.log(secretData.toString('utf8')); 21 | //reading the Private key 22 | privK = { 23 | key: fs.readFileSync('priv.key').toString(), 24 | passphrase: 'nodejsera' 25 | } 26 | //decrypting the text using public key 27 | origData = crypto.privateDecrypt(privK, secretData) 28 | //Printing the original content 29 | console.log(origData.toString()); -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/priv.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,D881D8AD164DDF78 4 | 5 | vVACPx+pbY1YEiDJj81czSGV4I0v0e0aXyMQvWJO536Yjr2JyhAt7+5o1YImoT9C 6 | tf6q1vNo56XgzwYfVoxnH+BIjDZuRq9M8E4ebdg0ptXDvkkffQv7EebduGWVL0JW 7 | f/GEG9DQw2VprKT84LUTIQB0o6HvnV5j8tmbQfOulwcwUFlBufa2YAH7pS+iZjfN 8 | nrLCuCXEi5tpR+Qtptv5BIz0W36OzrjfvKQQiTKP7+HxGrC+B+6QSNNSr5kMGlH6 9 | asIa7YQt6PnDNyySMbKwedwb5uxOZ+fAoGEHgXl/G2AS45nI++a4+k80k8l3njQH 10 | pwn+P+1VBCUHo79uVULYJqOY0Kjkpkrm0JrZTYPcL6SYAAa0sQ4on90tRKLjR04y 11 | CeZTWC0un2jRr225plIc6L9hbCA9eaIZM+J0LuoWNfk8yLQ1wQFlVNeH2qhlTDlM 12 | 54K2K3lFZHa1iG0KjvztVZjvf7pbv+bizKe9Cgqv6MvC5u8qesHr/OAZqc3HHZ8K 13 | Zf5TKBejpD8XgMuYnabOiglOQ/R96WGzfMUwwGF8mvvOuB1Fz21pzxIefrVnLm0T 14 | TlL93uiH3oKNF9TJENxoqdHsRs+dd9oUQlYysBdC6pWlLF7bm1OGLvBVvcMT0aK2 15 | cIH7FUeNHtPo6CKp30kifB+pBEtkwKLHpL0OHvpzQ4mvTlBdgF3Wtdx/WHvM7pKL 16 | +86pziWXEDP2As1KiAIDIEG0etuQt9DCW5fGw4DBtV7th5sl5NashDVfnpDFSDMj 17 | vjD2w5g/H5Gv4TSyM0b5E8ZkisXSXmmbNMcghG3FON2UVz6wAWMBdgaQ+MtsAsxk 18 | FPKs8PiEefuqonRaklpmiJyI3gS6TbW3tqT5aHLfxAIJjoe5kyix6Skh43HasVst 19 | ztoKSMJ+UODV6+YrTSazTK9sFevf9B4otHL12KNV7lM9P1gKvUZTc8NXsBJitnOo 20 | KWRUpCaZDo1iGma+RB/CZB5TNgnAtFM0p7rrVfzWZA1HJYVydcNKSZiCVrAAtLdy 21 | rB4UyH7aUph28oE7+HZ0kFSFt1gbLh5rKy51mS8zWQNIugsWiMwKwruxqV4fBTAN 22 | cY0OPHdX4RahEzB2L5I/Qt/nbq91/AuyPIq8A0XXbIgMC2BfpRvwLEBzkcyIkrsi 23 | yCGWYNnYWwdCTWkUZV2v0BAxVLC0fzmM6IO2UTkJ/I1/1g43YirQ3S6cw9ww3ZI4 24 | EH6xyMwY+VMCbyZSmfqXqNYWWIxuAdYEoHKZBZi2ZmM/WjbGFAd1lqnkin1eBuQs 25 | E+SQPxUNsLbvHTNPlito9r6H+0LdjpBoH3UVMJbndYmQGAD2Gu9fLvBZwjm9GT2h 26 | KfEhIhqPxSRZROAYioPdWJTT/ig/DZs+2m6Tac49KPrKTSMZmbT5gseG4rtOGfIf 27 | YRImIo3N0sUAYy/8g48V0IsEQo0Vd57D53xjByiaqdC6XCYWebTSAaQGWjH/D840 28 | E7qg4Oh+o1GT5PCJJA1Uuxc3nIrcr6JSPgVI7vbVvj81jyXrV0EI3KS5GxPn1TcP 29 | /bMUkbX/EV9w/aOc6yfU7Uv5p3fLRvtEzHBhvo790HX9Lw9+M/5Af/sqsPEMlsKb 30 | -----END RSA PRIVATE KEY----- 31 | -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/pub.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo9sqaQbz3ddaxd8uQG3K 3 | GIr98k/NS6xUxssTadR4uOgiJtcm9uknBgAAa2+RuSup60uCGW0KFiPHYfpDYzr8 4 | V8ZnErGkl2VUEGEiduNcwvaqOcGYWu4FoOAVn6tuf62l8qChn+S5CHV2Kx2UszWS 5 | 00Gcryl/Dm/cFKZ0bmWfa1EYtMcpbEZJBM79RQKB1WL17fYs5EXkFmf5eVQ2C4O7 6 | VtxeyrgW4ner7KpqytYc/z/XD6FZ+kEpMQcle9CvIGFi78yb8YoW+eVxgyZfloQv 7 | X1aaRnmZMu6mLNekv1ZZSCRWLjzO5x4ODDNRqjvMpqmUTJkK4j2qrad41FiRoXDl 8 | uQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/symmetric-enc-dec.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'),algorithm = 'aes-256-ctr',password = 'RJ23edrf'; 2 | //Here "aes-256-cbc" is the advance encryption standard we are using for encryption. 3 | //Text is the Confidential data which we need to encrypt using 'password'(Key). 4 | 5 | function encrypt(text){ 6 | var cipher = crypto.createCipher(algorithm,password) 7 | var crypted = cipher.update(text,'utf8','hex') 8 | crypted += cipher.final('hex'); 9 | return crypted; 10 | } 11 | 12 | //Here "aes-256-cbc" is the advance encyption standard we used for encrytion. 13 | //Text is the Cipher which we need to decrypt using 'password'(Key). 14 | function decrypt(text){ 15 | var decipher = crypto.createDecipher(algorithm,password) 16 | var dec = decipher.update(text,'hex','utf8') 17 | dec += decipher.final('utf8'); 18 | return dec; 19 | } 20 | 21 | //Actual content 22 | var text = "Nodejsera for all web development languages"; 23 | //Calling the encrypt function and printing the encrypted content 24 | var e = encrypt(text); 25 | console.log(e); 26 | //calling the decrypt function and printing the decrypted content 27 | var d = decrypt(e); 28 | console.log(d); -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/user.priv.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,05391439A8237D95 4 | 5 | w492ZsqxSXeM4XnVK4TMW1DpXLf3+yJqhXdjXfPRGnVelIcPkb/zrrUtYqFKqHH+ 6 | 2UHIWW5yWEJ7UxkHBd436QkePt88fFxHX8X8HTUvHtVQ/3y3TMghFSqyG/An2SDQ 7 | AXEoYioxU/cXixIzsB00Qe9jbmsmrfId7xfPoPeSl8GBOt4N8gEfMROoGVaxyN9n 8 | EN0u3LZRs+u2OBPgYPbMwAD8NdGPRFFL21wpAfG9z6dCC0wrTK16ecjH2+f53zeD 9 | rRx534TO167Fy79jS1YOfsn+Aeyi1FMpinojPDQSaQ+aNGEmoY6P1hd+Xn85lz5Q 10 | VuKkH7LDcsNfulsUTzGiL3rM9+YSgUGL1EjPmfi7eRJpWJ3jdfOUwFV96Z2baKhg 11 | NgAfMqJhq/Gdpphdfg9KCyM6SLDXJaeaBqOM0spPvhlBAq9J7KcKsPJMAOaAttsM 12 | qqzwzq4orknRX71HEs+qxJqd7DtgRt4khlFZkunkFpOAlzgOXVkfzKFOP3DhPkrI 13 | Ft84DAU5MN8MIf/ZYX4VNqmM5ytnC5tf8AHSFEKdRVbSkmr/ZWN1Exfegmlgp3TR 14 | J++UpAIwEhdI1kgCP4awvAJBcHNvtqt0fOHvuIWDiHJD8BkVWRGf9EuyWxXUHe8H 15 | HiHm9dDHVI+fVYtQda2NzYCfxFgi+Ro3Xv1dD29FK0hBnZTxRbsOSvIQfiAB8WPA 16 | /mdX86uhJURJB9XWAI3KgRajcQcZ9p8eNNCrebVlxqRW2kq9lUjW2g6Hein8T8xK 17 | 2UM6OVi7u9sEyqS812Iyh3jwOki77pwXm5iK/YTL8WCGixlSyLgPOUEyw7cpK0dz 18 | ZTM8h4r60PoQXBo6nOFuUb7R6uveKL0f116s3YFijS3bmbiEOgaLrR1DJeKd/iM2 19 | yyoWOPbDv4RGHv12+1MdyTiqlhIqlAs+/PSubTtyowJ8wvBEMDlZ9gwt48XcfudH 20 | MSiecr3mSuAvPAdEDj/35vn74u2xOMU2a+FE4cbXhwcNSsjyP3zR+iaE8bftqYoZ 21 | wmzgc5BujDnS5391kg6sFSfAoy5DeHcTKjffI6BdpD2TkrpfUPI5eFxX/WS3LIRu 22 | y+a+M+5FF2pheu9s+ECal60/pbfrCmWbht0xc/cbKr6ezIKBpMTP/VK4ue2p94lW 23 | VA1ycil1ptsjeyR8fD9ytyN+iDFBokYcYwq2YgK9Z9HdtjIsA7464Y+k/2MGQft9 24 | 3Lbyg6mgnKj4sUU66Xl2u6zGIuqNmZv0KbdvjiOBtNpl9MOZTUWDFejwaOWVW0Jx 25 | 7cFnuoF0MSjG7S1TltOzR1NUHExlndS8YG6Q/5qdb0YAwKZDx7cnrmQSvkflrJtI 26 | FcYywrW2xiKLUShYpeWbTUD0NukttMWtYGDKit8CQpdaW7Bd8DSt40u/7PYMHv7C 27 | Ccr5efh+JtBS40+Xam+TtZWKNHuxb7DlCPswaZvzVlgiONNjXQtLIudm9nxKOf7H 28 | Ej5cdpk5qPsMqgj7Jsi5R6GirGah1lBvuzfXLlRjiCj4cXJ0iSWLwAZbv03IXPTj 29 | Jt6YinRsJ/Ad+CZ3ue6AcW1KaNhu4+V8ad2vDOriNpYEReVs1Bjocg== 30 | -----END RSA PRIVATE KEY----- 31 | -------------------------------------------------------------------------------- /day-10-crypto-module-part-2/user.pub.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzIUe9DwLYTHe15MKVLdw 3 | c1Qz0UanMc1DqsXz9/vX2edjbLWaz5KSLbTU/m+iZKBqNc7AtvTuC3CSH9V64U3G 4 | kE5qClnVptHMA7c1UzDHwA2ZldOEIGT1xhf+/xj6ts+XmXATQJooMcYAeQGOqdsr 5 | kDWi3XUk1kunMFOzzDXGb0UXn/BNknEm/RB5niBbuP0J1mYiH9qCssR0a0YJct5p 6 | pVq/49yN7E62JPKV/43vBOX4nxej2NzQ9GWtb8x080EA8aZ377yuSO4d+Oa+A1pq 7 | Kr8S8FA/wthCrcyzDpBwu8oovjbRmvGZVITnuPJDesqCpUWFPrBYbMLarRHl57aM 8 | JwIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /day1-TheBeginning/hello-world-in-node.js: -------------------------------------------------------------------------------- 1 | //hello-world-in-node.js 2 | console.log('hello world'); -------------------------------------------------------------------------------- /day1-TheBeginning/index.html: -------------------------------------------------------------------------------- 1 |

2 | Finally I am serving an HTML File via a server. 3 | But it is not recommended for production. 4 |

-------------------------------------------------------------------------------- /day1-TheBeginning/index.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodejsera/30daysofnode/900fa9a5f04b308e6c379e5989ab773d16a19237/day1-TheBeginning/index.pdf -------------------------------------------------------------------------------- /day1-TheBeginning/serve-html.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | 4 | 5 | http.createServer(function (req, res) { 6 | console.log("Port Number : 3000"); 7 | res.writeHead(200, {'Content-Type': 'text/html'}); 8 | // change the to 'text/plain' to 'text/html' it will work as your index page 9 | fs.readFile('index.html', (err, data) => { 10 | if (err) 11 | throw err; 12 | console.log("Operation Success"); 13 | res.end(data); 14 | }); 15 | }).listen(3000); -------------------------------------------------------------------------------- /day1-TheBeginning/serve-json.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | 4 | 5 | http.createServer(function (req, res) { 6 | console.log("Port Number : 3000"); 7 | res.writeHead(200, {'Content-Type': 'application/json'}); 8 | // change the to 'text/plain' to 'text/html' it will work as your index page 9 | let json_response = { 10 | status : 200 , 11 | message : 'succssful' , 12 | result : [ 'sunday' , 'monday' , 'tuesday' , 'wednesday' ] , 13 | code : 2000 14 | } 15 | res.end( JSON.stringify(json_response) ); 16 | }).listen(3000); -------------------------------------------------------------------------------- /day1-TheBeginning/serve-mp3.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | 4 | 5 | http.createServer(function (req, res) { 6 | console.log("Port Number : 3000"); 7 | // change MIME type to 'audio/mp3' 8 | res.writeHead(200, {'Content-Type': 'audio/mp3'}); 9 | fs.exists('audio.mp3',function(exists){ 10 | if(exists) 11 | { 12 | var rstream = fs.createReadStream('audio.mp3'); 13 | rstream.pipe(res); 14 | } 15 | else 16 | { 17 | res.end("Its a 404"); 18 | } 19 | 20 | }); 21 | 22 | }).listen(3000); 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /day1-TheBeginning/serve-mp4.js: -------------------------------------------------------------------------------- 1 | 2 | var http = require('http'); 3 | var fs = require('fs'); 4 | 5 | 6 | http.createServer(function (req, res) { 7 | console.log("Port Number : 3000"); 8 | res.writeHead(200, {'Content-Type': 'video/mp4'}); 9 | // change the to 'text/plain' to 'text/html' it will work as your index page 10 | var file = 'index.mp3'; 11 | fs.exists('video.mp4',function(exists){ 12 | if(exists) 13 | { 14 | var rstream = fs.createReadStream('video.mp4'); 15 | rstream.pipe(res); 16 | } 17 | else 18 | { 19 | res.send("Its a 404"); 20 | res.end(); 21 | } 22 | 23 | }); 24 | 25 | }).listen(3000); 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /day1-TheBeginning/serve-pdf.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | 4 | 5 | http.createServer(function (req, res) { 6 | console.log("Port Number : 3000"); 7 | res.writeHead(200, {'Content-Type': 'text/html'}); 8 | // change the to 'text/plain' to 'text/html' it will work as your index page 9 | fs.readFile('index.pdf',function(error,data){ 10 | if(error){ 11 | res.json({'status':'error',msg:err}); 12 | }else{ 13 | res.writeHead(200, {"Content-Type": "application/pdf"}); 14 | res.write(data); 15 | res.end(); 16 | } 17 | }); 18 | }).listen(3000); 19 | 20 | 21 | -------------------------------------------------------------------------------- /day1-TheBeginning/serve-string.js: -------------------------------------------------------------------------------- 1 | //simple-server-in-nodejs.js 2 | var http = require('http'); 3 | 4 | var host = '127.0.0.1' 5 | var port = 3000 6 | 7 | var server = http.createServer((request, response) => { 8 | response.writeHead(200, {"Content-Type": "text/plain"}); 9 | response.write("Hello World!"); 10 | response.end(); 11 | }); 12 | 13 | server.listen(port,host, (error) => { 14 | if (error) { 15 | return console.log('Error occured : ', error ); 16 | } 17 | 18 | console.log('server is listening on ' + host + ':'+ port); 19 | }); -------------------------------------------------------------------------------- /day1-TheBeginning/simple-server-in-node.js: -------------------------------------------------------------------------------- 1 | //simple-server-in-nodejs.js 2 | var http = require('http'); 3 | 4 | var host = '127.0.0.1' 5 | var port = 3000 6 | 7 | var server = http.createServer((request, response) => { 8 | response.writeHead(200, {"Content-Type": "text/html"}); 9 | console.log("server Working"); 10 | response.end('Server Working Success'); 11 | }); 12 | 13 | server.listen(port,host, (error) => { 14 | if (error) { 15 | return console.log('Error occured : ', error ); 16 | } 17 | 18 | console.log('server is listening on ' + host + ':'+ port); 19 | }); -------------------------------------------------------------------------------- /day11-express-framework/content.txt: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /day11-express-framework/request-with-params.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var fs = require('fs') 3 | 4 | var app = express() 5 | 6 | app.get('/', function (req, res) { 7 | res.send('Simple Example of routes!'); 8 | }) 9 | 10 | app.get('/signup', function(req,res){ 11 | // this is how we will receive params from front end 12 | 13 | var name = req.query.name; 14 | var email = req.query.email; 15 | var password = req.query.password; 16 | //For demo purpose 17 | console.log(name + '' + email + ' ' + password); 18 | 19 | /** 20 | * Store this in a database and perform further processing 21 | */ 22 | res.send("In signup module") 23 | }); 24 | 25 | app.listen(3000, function () { 26 | console.log('Server is listening at 3000') 27 | }) 28 | -------------------------------------------------------------------------------- /day11-express-framework/routes_in_express.js: -------------------------------------------------------------------------------- 1 | var express = require('express') 2 | var app = express() 3 | 4 | app.get('/', function (req, res) { 5 | res.send('Simple Example of routes!'); 6 | }) 7 | 8 | app.get('/signup', function (req, res) { 9 | res.send('This is demo route for sign up'); 10 | }) 11 | 12 | app.get('/signin', function (req, res) { 13 | res.send('This is demo route for sign in'); 14 | }) 15 | 16 | 17 | 18 | app.get('/signin/dashboard', function (req, res) { 19 | res.send('This is demo route for user who signed in and now reaches their dashboard'); 20 | }) 21 | 22 | 23 | app.listen(3000, function () { 24 | console.log('Server is listening at 3000') 25 | }) 26 | -------------------------------------------------------------------------------- /day11-express-framework/simple-server-express.js: -------------------------------------------------------------------------------- 1 | var express = require('express') 2 | var app = express() 3 | 4 | app.get('/', function (req, res) { 5 | res.send('Hello World!') 6 | }) 7 | app.listen(3000, function () { 8 | console.log('Server is listening at 3000') 9 | }) 10 | -------------------------------------------------------------------------------- /day13-signup-form/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nj-signup", 3 | "version": "1.0.0", 4 | "description": "Sign up using node, express and mongo", 5 | "main": "serve.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "author": "@rajatgarian", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.16.1", 14 | "mongodb": "^2.2.30" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /day13-signup-form/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Signup Form | nodejsera 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 |
17 |
18 |
19 |
20 | 21 |
22 | 23 |
24 | 25 | 26 |
27 | 28 |

Signup form

29 | 30 |
31 | 32 |
33 | 34 |
35 | 36 |
37 |
38 |
39 | 40 |
41 | 42 |
43 | 44 | 45 |
46 | 47 |
48 | 49 |
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /day13-signup-form/public/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Josefin+Slab'); 2 | 3 | .main{ 4 | padding:20px; 5 | font-family: 'Josefin Slab', serif; 6 | border : 2px solid #50d8a4; 7 | border-radius: 15px; 8 | 9 | } 10 | .main h1{ 11 | font-size: 50px; 12 | text-align:center; 13 | font-family: 'Josefin Slab', serif; 14 | color: #549978; 15 | } 16 | input{ 17 | font-family: 'Josefin Slab', serif; 18 | width: 100%; 19 | font-size: 30px; 20 | padding: 12px 20px; 21 | margin: 8px 0; 22 | border: none; 23 | border-bottom: 2px solid #50d8a4; 24 | } 25 | input[type=submit] { 26 | font-family: 'Josefin Slab', serif; 27 | width: 100%; 28 | background-color: #549978; 29 | border: none; 30 | color: white; 31 | padding: 16px 32px; 32 | text-decoration: none; 33 | margin: 4px 2px; 34 | cursor: pointer; 35 | border-radius: 15px; 36 | } 37 | input:focus, 38 | select:focus, 39 | textarea:focus, 40 | button:focus { 41 | outline: none; 42 | } 43 | 44 | input:hover { 45 | font-family: 'Josefin Slab', serif; 46 | width: 100%; 47 | padding: 12px 20px; 48 | margin: 8px 0; 49 | box-sizing: border-box; 50 | border: none; 51 | border-bottom: 2px solid #549978; 52 | } 53 | 54 | input[type=submit]:hover { 55 | font-family: 'Josefin Slab', serif; 56 | width: 100%; 57 | background-color: #549978; 58 | border: none; 59 | color: white; 60 | padding: 16px 32px; 61 | text-decoration: none; 62 | margin: 4px 2px; 63 | cursor: pointer; 64 | border-radius: 15px; 65 | } -------------------------------------------------------------------------------- /day13-signup-form/public/success.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Signup Form | nodejsera 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 |

Signup Successful
Congratulations!!

20 | 21 |
22 | 23 | 24 |
25 |
26 | 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /day13-signup-form/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | var fs = require('fs'); 4 | var app = express(); 5 | var mongo = require('mongodb'); 6 | var new_db = "mongodb://localhost:27017/agfgf"; 7 | var bodyParser = require('body-parser'); 8 | var crypto = require('crypto'); 9 | //Creating the database 10 | 11 | app.get('/',function(req,res){ 12 | res.set({ 13 | 'Access-Control-Allow-Origin' : '*' 14 | }); 15 | return res.redirect('/public/index.html'); 16 | }).listen(3000); 17 | 18 | console.log("Server listening at : 3000"); 19 | app.use('/public', express.static(__dirname + '/public')); 20 | app.use( bodyParser.json() ); 21 | app.use(bodyParser.urlencoded({ // to support URL-encoded bodies 22 | extended: true 23 | })); 24 | 25 | var getHash = ( pass , phone ) => { 26 | 27 | var hmac = crypto.createHmac('sha512', phone); 28 | 29 | //passing the data to be hashed 30 | data = hmac.update(pass); 31 | //Creating the hmac in the required format 32 | gen_hmac= data.digest('hex'); 33 | //Printing the output on the console 34 | console.log("hmac : " + gen_hmac); 35 | return gen_hmac; 36 | } 37 | 38 | // Sign-up function starts here. . . 39 | app.post('/sign_up' ,function(req,res){ 40 | var name = req.body.name; 41 | var email= req.body.email; 42 | var pass = req.body.password; 43 | var phone = req.body.phone; 44 | var password = getHash( pass , phone ); 45 | 46 | 47 | var data = { 48 | "name":name, 49 | "email":email, 50 | "password": password, 51 | "phone" : phone 52 | } 53 | 54 | mongo.connect(new_db , function(error , db){ 55 | if (error){ 56 | throw error; 57 | } 58 | console.log("connected to database successfully"); 59 | //CREATING A COLLECTION IN MONGODB USING NODE.JS 60 | db.collection("details").insertOne(data, (err , collection) => { 61 | if(err) throw err; 62 | console.log("Record inserted successfully"); 63 | console.log(collection); 64 | }); 65 | }); 66 | 67 | console.log("DATA is " + JSON.stringify(data) ); 68 | res.set({ 69 | 'Access-Control-Allow-Origin' : '*' 70 | }); 71 | return res.redirect('/public/success.html'); 72 | 73 | /** 74 | var filePath = path.join(__dirname, 'public/success.html'); 75 | var stat = fs.statSync(filePath); 76 | 77 | res.writeHead(200, { 78 | 'Content-Type': 'text/html', 79 | 'Content-Length': stat.size 80 | }); 81 | 82 | var readStream = fs.createReadStream(filePath); 83 | // We replaced all the event handlers with a simple call to readStream.pipe() 84 | readStream.pipe(res); 85 | */ 86 | 87 | }); 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /day14-socket.io/changing-css-dynamically/css-color-admin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 45 | 46 | 47 | 48 |
49 |
50 |
51 |
52 | 53 | 54 | 55 |

Click Here to Pick Color

56 | 57 | 58 | 59 |
60 |
61 |
62 |
63 |
64 | 65 | 66 | 67 | 68 | 69 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /day14-socket.io/changing-css-dynamically/css-color-server.js: -------------------------------------------------------------------------------- 1 | //Including the required files 2 | var app = require('express')(); 3 | var server = require('http').Server(app); 4 | var io = require('socket.io')(server); 5 | //server listening at 127.0.0.1:3000 6 | server.listen(3000); 7 | console.log("Listening at 3000"); 8 | //Handling the default route 9 | app.get('/', function (req, res) { 10 | res.sendFile(__dirname + '/css-color.html'); 11 | }); 12 | //Handling the route for admin 13 | app.get('/admin' , function(req,res) { 14 | res.sendFile(__dirname + '/css-color-admin.html'); 15 | }) 16 | //Code for sockets 17 | io.on('connection', function (socket) { 18 | socket.on('admin' , function(data) { 19 | console.log(data); 20 | console.log('about to broadcast') 21 | io.sockets.emit( 'color' , { data : data } ) 22 | }) 23 | }); -------------------------------------------------------------------------------- /day14-socket.io/changing-css-dynamically/css-color.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | 28 | 29 | 30 |
31 |
32 |
33 |
34 |

Changing CSS Dynamically using Socket.io

35 |
36 |
37 |

A Normal

38 |

text paragraph in which

39 |

we are using sockets to change CSS

40 |

dynamically from the admin panel

41 |

But it will only change the CSS of content which is inside p (paragraph) tag.

42 | 43 | 44 |
45 | 46 | 47 |
48 |
49 |
50 | 51 | 52 | 53 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /day14-socket.io/real-time-quotes/admin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Real Time Quotes | Admin Panel | Nodejsera 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 56 | 57 | 58 | 59 | 60 |
61 |
62 |
63 |
64 | 65 |

66 | Add Your Quotes in Realtime using Sockets and node.js 67 |

68 |
69 | 70 |
71 | 72 | 73 |
74 |
75 | 76 |
77 | 78 |
79 |
80 |
81 |
82 |
83 |
84 | 85 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /day14-socket.io/real-time-quotes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Real Time Quotes | Nodejsera 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 30 | 31 | 32 | 33 | 34 | 35 |
36 |
37 | 38 |
39 |
40 | 41 |
Real Time Quotes
42 |
43 | 44 |
45 |
have a great day , have a great life
46 |
47 |
48 |
49 |
50 | 51 |
52 | 53 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /day14-socket.io/real-time-quotes/server.js: -------------------------------------------------------------------------------- 1 | //Including the required files 2 | var app = require('express')(); 3 | var server = require('http').Server(app); 4 | var io = require('socket.io')(server); 5 | //server listening at 127.0.0.1:3000 6 | server.listen(3000); 7 | console.log("Server listening at: 3000"); 8 | //Handling the default route 9 | app.get('/', function (req, res) { 10 | res.sendFile(__dirname + '/index.html'); 11 | }); 12 | //Handling the route for admin 13 | app.get('/admin' , function(req,res) { 14 | res.sendFile(__dirname + '/admin.html'); 15 | }) 16 | //Code for sockets 17 | io.on('connection', function (socket) { 18 | 19 | socket.emit('welcome', { data: 'welcome' }); 20 | 21 | socket.on('new' , function(data) { 22 | console.log('About to upload Quote') 23 | io.sockets.emit( 'next' , { data : data } ) 24 | }) 25 | }); -------------------------------------------------------------------------------- /day16-zlib/newfile.txt.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nodejsera/30daysofnode/900fa9a5f04b308e6c379e5989ab773d16a19237/day16-zlib/newfile.txt.gz -------------------------------------------------------------------------------- /day16-zlib/unzip-using-zlib.js: -------------------------------------------------------------------------------- 1 | // Including the required modules 2 | var zlib = require('zlib'); 3 | var fs = require('fs'); 4 | 5 | var unzip = zlib.createUnzip(); 6 | 7 | var read = fs.createReadStream('newfile.txt.gz'); 8 | var write = fs.createWriteStream('unzip.txt'); 9 | //Transform stream which is unzipping the zipped file 10 | read.pipe(unzip).pipe(write); 11 | console.log("unZipped Successfully"); 12 | 13 | -------------------------------------------------------------------------------- /day16-zlib/zip-using-zlib.js: -------------------------------------------------------------------------------- 1 | // Including the required modules 2 | var zlib = require('zlib'); 3 | var fs = require('fs'); 4 | 5 | var zip = zlib.createGzip(); 6 | 7 | var read = fs.createReadStream('newfile.txt'); 8 | var write = fs.createWriteStream('newfile.txt.gz'); 9 | //Transform stream which is zipping the input file 10 | read.pipe(zip).pipe(write); 11 | console.log("Zipped Successfully"); -------------------------------------------------------------------------------- /day17-crud-mysql/create-table-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | var table = "CREATE TABLE details (id int(15) NOT NULL AUTO_INCREMENT,"+ 11 | "name varchar(30) DEFAULT NULL,"+ 12 | "age float(15) DEFAULT NULL,"+ 13 | "PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1"; 14 | 15 | //establishing connection 16 | connect.getConnection(function(err, connection){ 17 | //Creating details table 18 | connection.query(table, function(err){ 19 | if(err) throw err; 20 | else { 21 | console.log('Table created Successfully!'); 22 | } 23 | }); 24 | 25 | //releasing connection 26 | connection.release(); 27 | 28 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/delete-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | 11 | var delete_R = 'DELETE FROM details WHERE name=?'; 12 | //establishing connection 13 | connect.getConnection(function(err, connection){ 14 | 15 | //Deleting a record from details 16 | connection.query(delete_R,['regii'], function(err, res){ 17 | if(err) throw err; 18 | else { 19 | console.log('A record is removed !'); 20 | } 21 | }); 22 | 23 | //releasing connection 24 | connection.release(); 25 | 26 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/demo.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var pool = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | var createTable = "CREATE TABLE employee(id int(11) NOT NULL AUTO_INCREMENT,"+ 11 | "name varchar(20) DEFAULT NULL,"+ 12 | "salary float(11) DEFAULT NULL,"+ 13 | "PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1"; 14 | 15 | var insertRecord = 'INSERT INTO employee(name,salary) VALUE(?,?)'; 16 | 17 | var readTable = 'SELECT * FROM employee'; 18 | 19 | var updateRecord = 'UPDATE employee SET salary = ? WHERE name=?'; 20 | 21 | var deleteRecord = 'DELETE FROM employee WHERE name=?'; 22 | 23 | var dropTable = 'DROP table employee'; 24 | 25 | pool.getConnection(function(err, connection){ 26 | //Create a table called employee 27 | connection.query(createTable, function(err){ 28 | if(err) throw err; 29 | else { 30 | console.log('Table created!'); 31 | } 32 | }); 33 | 34 | //Insert a record. 35 | connection.query(insertRecord,['Joe',50000], function(err,res){ 36 | if(err) throw err; 37 | else { 38 | console.log('A new employee has been added.'); 39 | } 40 | }); 41 | 42 | //Read table. 43 | connection.query(readTable, function(err, rows){ 44 | if(err) throw err; 45 | else { 46 | console.log(rows); 47 | } 48 | }); 49 | 50 | //Update a record. 51 | connection.query(updateRecord,[60000,'Joe'], function(err, res){ 52 | if(err) throw err; 53 | else { 54 | console.log('Increased the salary for Joe.'); 55 | } 56 | }); 57 | 58 | //Read table. 59 | connection.query(readTable, function(err, rows){ 60 | if(err) throw err; 61 | else { 62 | console.log(rows); 63 | } 64 | }); 65 | 66 | //Delete a record. 67 | connection.query(deleteRecord,['Joe'], function(err, res){ 68 | if(err) throw err; 69 | else { 70 | console.log('An employee is removed.'); 71 | } 72 | }); 73 | 74 | //Drop a table. 75 | connection.query(dropTable, function(err, res){ 76 | if(err) throw err; 77 | else { 78 | console.log('The employee table is removed.'); 79 | } 80 | }); 81 | 82 | connection.release();//release the connection 83 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/drop-table-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | 11 | var drop_T = 'DROP table details'; 12 | //establishing connection 13 | connect.getConnection(function(err, connection){ 14 | 15 | //Drop the details table 16 | connection.query(drop_T, function(err, res){ 17 | if(err) throw err; 18 | else { 19 | console.log('The details table is removed successfully'); 20 | } 21 | }); 22 | 23 | //releasing connection 24 | connection.release(); 25 | 26 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/insert-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | 11 | var insert_R = 'INSERT INTO details(name,age) VALUE(?,?)'; 12 | //establishing connection 13 | connect.getConnection(function(err, connection){ 14 | 15 | //Inserting a record into details 16 | connection.query(insert_R,['rejii',24], function(err,res){ 17 | if(err) throw err; 18 | else { 19 | console.log('Details added successfully'); 20 | } 21 | }); 22 | 23 | //releasing connection 24 | connection.release(); 25 | 26 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "requires": true, 3 | "lockfileVersion": 1, 4 | "dependencies": { 5 | "bignumber.js": { 6 | "version": "4.0.4", 7 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.0.4.tgz", 8 | "integrity": "sha512-LDXpJKVzEx2/OqNbG9mXBNvHuiRL4PzHCGfnANHMJ+fv68Ads3exDVJeGDJws+AoNEuca93bU3q+S0woeUaCdg==" 9 | }, 10 | "core-util-is": { 11 | "version": "1.0.2", 12 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 13 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 14 | }, 15 | "inherits": { 16 | "version": "2.0.3", 17 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 18 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 19 | }, 20 | "isarray": { 21 | "version": "1.0.0", 22 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 23 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 24 | }, 25 | "mysql": { 26 | "version": "2.15.0", 27 | "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.15.0.tgz", 28 | "integrity": "sha512-C7tjzWtbN5nzkLIV+E8Crnl9bFyc7d3XJcBAvHKEVkjrYjogz3llo22q6s/hw+UcsE4/844pDob9ac+3dVjQSA==", 29 | "requires": { 30 | "bignumber.js": "4.0.4", 31 | "readable-stream": "2.3.3", 32 | "safe-buffer": "5.1.1", 33 | "sqlstring": "2.3.0" 34 | } 35 | }, 36 | "process-nextick-args": { 37 | "version": "1.0.7", 38 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", 39 | "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" 40 | }, 41 | "readable-stream": { 42 | "version": "2.3.3", 43 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", 44 | "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", 45 | "requires": { 46 | "core-util-is": "1.0.2", 47 | "inherits": "2.0.3", 48 | "isarray": "1.0.0", 49 | "process-nextick-args": "1.0.7", 50 | "safe-buffer": "5.1.1", 51 | "string_decoder": "1.0.3", 52 | "util-deprecate": "1.0.2" 53 | } 54 | }, 55 | "safe-buffer": { 56 | "version": "5.1.1", 57 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 58 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 59 | }, 60 | "sqlstring": { 61 | "version": "2.3.0", 62 | "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.0.tgz", 63 | "integrity": "sha1-UluKT9Jtb3GqYegipsr5dtMa0qg=" 64 | }, 65 | "string_decoder": { 66 | "version": "1.0.3", 67 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", 68 | "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", 69 | "requires": { 70 | "safe-buffer": "5.1.1" 71 | } 72 | }, 73 | "util-deprecate": { 74 | "version": "1.0.2", 75 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 76 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /day17-crud-mysql/read-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | 11 | var read_R = 'SELECT * FROM details'; 12 | //establishing connection 13 | connect.getConnection(function(err, connection){ 14 | 15 | //retrieving a record from details 16 | connection.query(read_R, function(err, data){ 17 | if(err) throw err; 18 | else { 19 | console.log(data); 20 | } 21 | }); 22 | 23 | //releasing connection 24 | connection.release(); 25 | 26 | }); -------------------------------------------------------------------------------- /day17-crud-mysql/update-mysql.js: -------------------------------------------------------------------------------- 1 | var mysql = require('mysql'); 2 | 3 | var connect = mysql.createPool({ 4 | host : 'localhost', 5 | user : 'root', 6 | password: '', 7 | database: 'test' 8 | }); 9 | 10 | 11 | var update_R = 'UPDATE details SET age = ? WHERE name=?'; 12 | //establishing connection 13 | connect.getConnection(function(err, connection){ 14 | 15 | //Updating a record from details 16 | connection.query(update_R,[25,'regii'], function(err, res){ 17 | if(err) throw err; 18 | else { 19 | console.log('Updated the age of regii !'); 20 | } 21 | }); 22 | 23 | //releasing connection 24 | connection.release(); 25 | 26 | }); -------------------------------------------------------------------------------- /day18-callbacks/blocking-code.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | //For calculating execution time 3 | var date1 = new Date(); 4 | var time_start = date1.getTime(); 5 | console.log("starting at: " + time_start); 6 | console.log("Let's start reading file"); 7 | 8 | var filename = 'output.txt'; //Name of the file to be read 9 | //Reading file synchronously 10 | var content = fs.readFileSync(filename); 11 | console.log('Content : ' + content); 12 | //For calculating execution time 13 | var date2 = new Date(); 14 | var time_end = date2.getTime(); 15 | console.log("finishing at: " + time_end); 16 | var execution_time = time_end - time_start; 17 | console.log("Time for execution: " + execution_time ); 18 | //Consider it some another task in queue 19 | console.log('Another task to be executed'); -------------------------------------------------------------------------------- /day18-callbacks/non-blocking-code.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | 4 | //For calculating execution time 5 | var date1 = new Date(); 6 | var time_start = date1.getTime(); 7 | console.log("starting at: " + time_start); 8 | console.log("Let's start reading file"); 9 | 10 | 11 | //Name of the file to be read 12 | var filename = 'output.txt'; 13 | //Reading file asynchronously 14 | fs.readFile('output.txt', (err, data) => { 15 | if (err) 16 | throw err; 17 | 18 | console.log("Content : " + data); 19 | }); 20 | 21 | 22 | //For calculating execution time 23 | var date2 = new Date(); 24 | var time_end = date2.getTime(); 25 | console.log("finishing at: " + time_end); 26 | var execution_time = time_end - time_start; 27 | console.log("Time for execution: " + execution_time ); 28 | //Consider it some another task in queue 29 | console.log('Another task to be executed'); -------------------------------------------------------------------------------- /day19-queryString/qs-parse.js: -------------------------------------------------------------------------------- 1 | 2 | var qs = require('querystring'); 3 | 4 | var value_json = qs.parse('id=1&name=rj&name=njsera&tutorial=30daysofnode&creator=nodejsera') 5 | console.log(value_json); 6 | 7 | var value_json_2 = qs.parse('id%2&name%reij&name%njsera2&tutorial%30daysofnode&creator%nodejsera','&','%'); 8 | console.log("Changing the default 'eq' from '=' to '%'. An example is shown below:"); 9 | console.log(value_json_2); 10 | 11 | var value_json_3 = qs.parse('id%3#name%emily#name%njsera3#tutorial%30daysofnode#creator%nodejsera','#','%'); 12 | console.log("Changing the default Separator 'sep' from '&' to '#'. An example is shown below:") 13 | console.log(value_json_3); 14 | 15 | -------------------------------------------------------------------------------- /day19-queryString/qs-stringify.js: -------------------------------------------------------------------------------- 1 | 2 | var qs = require('querystring'); 3 | 4 | var value_json = qs.stringify({ id: 1, name: ['abc', 'njera'], tutorial: '30days of node', creator : 'nodejsera' }); 5 | console.log(value_json); 6 | 7 | var value_json_2 = qs.stringify({ id: 2, name: ['def', 'njera2'], tutorial: '30days of node', creator : 'nodejsera' },';'); 8 | console.log("Changing the default 'sep' from '&' to ';'. An example is shown below:"); 9 | console.log(value_json_2); 10 | 11 | var value_json_3 = qs.stringify( {id: 3, name: ['hij', 'njera3'], tutorial: '30days of node', creator : 'nodejsera' },';',':'); 12 | console.log("Changing the default 'eq' from '=' to ':'. An example is shown below:") 13 | console.log(value_json_3); 14 | 15 | -------------------------------------------------------------------------------- /day2-filesystem/data.txt.txt: -------------------------------------------------------------------------------- 1 | This is a demo text file. -------------------------------------------------------------------------------- /day2-filesystem/fs.appendFile.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | new_data = "This data will be appended at the end of the file."; 4 | 5 | fs.appendFile('input.txt', new_data , (err) => { 6 | if(err) 7 | throw err; 8 | console.log('The new_content was appended successfully'); 9 | }); -------------------------------------------------------------------------------- /day2-filesystem/fs.appendFileSync.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var content = "We are Appending this file synchronously using node.js"; 3 | fs.appendFileSync('input.txt', content); 4 | console.log("File Appended Successfully"); -------------------------------------------------------------------------------- /day2-filesystem/fs.readFile.js: -------------------------------------------------------------------------------- 1 | var fs=require('fs'); 2 | 3 | fs.readFile('message.txt', (err, data) => { 4 | if (err) 5 | throw err; 6 | 7 | console.log("Content : " + data); 8 | }); -------------------------------------------------------------------------------- /day2-filesystem/fs.readfileSync.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var filename = 'content.txt'; 4 | 5 | var content = fs.readFileSync(filename); 6 | 7 | console.log('Content : ' + content); -------------------------------------------------------------------------------- /day2-filesystem/fs.rename.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | // you have to pass the Relative path of the file from the Current working directory. 3 | fs.rename('data.txt', 'new_data.txt', (err) => { 4 | if (err) 5 | throw err; 6 | console.log('File renamed successfully'); 7 | }); 8 | 9 | // To check it's Asynchronous nature ! 10 | console.log("This method is Asynchronous"); -------------------------------------------------------------------------------- /day2-filesystem/fs.renameSync.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | //you have to pass the Relative path of the file from the Current working directory. 3 | fs.renameSync('data.txt', 'newData.txt'); 4 | console.log('File renamed successfully'); 5 | 6 | // To check it's Synchronous nature ! 7 | console.log("This method is Synchronous"); -------------------------------------------------------------------------------- /day2-filesystem/fs.unlink.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = 'content.txt'; 3 | fs.unlink(filename, (err) => { 4 | if (err) 5 | throw err; 6 | console.log('File deleted successfully'); 7 | }); -------------------------------------------------------------------------------- /day2-filesystem/fs.unlinkSync.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = 'data.txt'; 3 | fs.unlinkSync(filename); 4 | console.log('File Deleted Successfully'); -------------------------------------------------------------------------------- /day2-filesystem/fs.writeFile.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var content= "this is the content in the file"; 3 | fs.writeFile('message.txt', content , (err) => { 4 | if (err) 5 | throw err; 6 | console.log('It\'s saved!'); 7 | }); -------------------------------------------------------------------------------- /day2-filesystem/fs.writeFileSync.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var content = "We are writing this file synchronously using node.js"; 4 | 5 | fs.writeFileSync('content.txt', content , ); 6 | console.log("File Written Successfully"); -------------------------------------------------------------------------------- /day20-timers/clearImmediate().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will not run at all"); 3 | } 4 | console.log("It is supposed to print the data immediately") 5 | var imm = setImmediate(hello); 6 | clearImmediate(imm); -------------------------------------------------------------------------------- /day20-timers/clearInterval().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will Not Run at all"); 3 | } 4 | console.log("It is supposed Print the data recursively after a delay of 2000ms again and again") 5 | var s_int = setInterval(hello,2000); 6 | clearInterval(s_int); -------------------------------------------------------------------------------- /day20-timers/clearTimeout().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will not run at all"); 3 | } 4 | console.log("It will Print the data once after the delay of 2000ms") 5 | var tim = setTimeout(hello,2000); 6 | clearTimeout(tim); 7 | -------------------------------------------------------------------------------- /day20-timers/setImmediate().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will run Immediately"); 3 | } 4 | console.log("It will Print the data Immediately") 5 | setImmediate(hello); 6 | 7 | -------------------------------------------------------------------------------- /day20-timers/setInterval().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will run recursively"); 3 | } 4 | console.log("It will Print the data recursively after a delay of 2000ms again and again") 5 | setInterval(hello,2000); -------------------------------------------------------------------------------- /day20-timers/setTimeout().js: -------------------------------------------------------------------------------- 1 | function hello () { 2 | console.log("This will run only once"); 3 | } 4 | console.log("It will Print the data once after the delay of 2000ms") 5 | setTimeout(hello,2000); 6 | -------------------------------------------------------------------------------- /day21-buffers/buffer.alloc.js: -------------------------------------------------------------------------------- 1 | //Name of the file : buffer.alloc.js 2 | var buff = Buffer.alloc(20); 3 | console.log(buff); -------------------------------------------------------------------------------- /day21-buffers/buffer.allocUnsafe.js: -------------------------------------------------------------------------------- 1 | //Name of the file : buffer.allocUnsafe.js 2 | var buff = Buffer.allocUnsafe(10); 3 | console.log(buff); -------------------------------------------------------------------------------- /day21-buffers/buffer.compare.js: -------------------------------------------------------------------------------- 1 | var buffer1 = Buffer.from('Nodejsera'); 2 | var buffer2 = Buffer.from('Nodejsera'); 3 | var output = buffer1.compare(buffer2); 4 | console.log(output) 5 | if(output < 0) { 6 | console.log(buffer1 +" comes before " + buffer2); 7 | }else if(output == 0){ 8 | console.log(buffer1 +" is same as " + buffer2); 9 | }else { 10 | console.log(output +" comes after " + buffer2); 11 | } -------------------------------------------------------------------------------- /day21-buffers/buffer.concat.js: -------------------------------------------------------------------------------- 1 | var buff1 = Buffer.from('Nodejsera for nodejs'); 2 | var buff2 = Buffer.from('- 30 days of node'); 3 | var buff3 = Buffer.concat([buff1,buff2]); 4 | console.log("buff3 content: " + buff3.toString()); -------------------------------------------------------------------------------- /day21-buffers/buffer.copy.js: -------------------------------------------------------------------------------- 1 | var buff = Buffer.from('Nodejsera'); 2 | var newbuff = Buffer.alloc(20); 3 | buff.copy(newbuff); 4 | console.log("Content of newbuff : " + newbuff.toString()); -------------------------------------------------------------------------------- /day21-buffers/buffer.equals.js: -------------------------------------------------------------------------------- 1 | var buff1 = Buffer.from('nodejsera'); 2 | var buff2 = Buffer.from('nodejsera'); 3 | 4 | console.log(buff1.equals(buff2)); -------------------------------------------------------------------------------- /day21-buffers/buffer.fill.js: -------------------------------------------------------------------------------- 1 | var buff = Buffer.allocUnsafe(10).fill('nj'); 2 | console.log(buff.toString()); -------------------------------------------------------------------------------- /day21-buffers/buffer.from.js: -------------------------------------------------------------------------------- 1 | var buff1 = Buffer.from('Nodejsera'); 2 | console.log("buff1 : " + buff1); 3 | -------------------------------------------------------------------------------- /day21-buffers/buffer.indexOf.js: -------------------------------------------------------------------------------- 1 | var buff1 = Buffer.from('Nodejsera'); 2 | console.log(buff1.indexOf('j')); -------------------------------------------------------------------------------- /day21-buffers/buffer.length.js: -------------------------------------------------------------------------------- 1 | var buf = Buffer.from('Nodejsera for nodejs'); 2 | console.log( buf.length); -------------------------------------------------------------------------------- /day21-buffers/buffer.slice.js: -------------------------------------------------------------------------------- 1 | var buff1 = Buffer.from('Nodejsera'); 2 | var buff2 = buff1.slice(0,5); 3 | console.log("content of buff2 : " + buff2.toString()); -------------------------------------------------------------------------------- /day21-buffers/bufferToJSON.js: -------------------------------------------------------------------------------- 1 | var buf = Buffer.from('Nodejsera'); 2 | var json = buf.toJSON(buf); 3 | console.log(json); -------------------------------------------------------------------------------- /day21-buffers/bufferToString.js: -------------------------------------------------------------------------------- 1 | var buf = Buffer.from('Nodejsera for nodejs'); 2 | console.log( buf.toString('ascii')); -------------------------------------------------------------------------------- /day22-string-decoder/write.js: -------------------------------------------------------------------------------- 1 | var stringDecoder = require('string_decoder').StringDecoder; 2 | var sd = new stringDecoder('utf8'); 3 | var buff = Buffer('data to be buffered'); 4 | //Print the buffered data 5 | console.log(buff); 6 | //Print the decoded buffer 7 | console.log(sd.write(buff)); -------------------------------------------------------------------------------- /day24-child-processes/master-exec.js: -------------------------------------------------------------------------------- 1 | var cp = require('child_process'); 2 | 3 | for(var i=1; i<6; i++) { 4 | var workerProcess = cp.exec('node slave.js ' + i , function(error, stdout, stderr) { 5 | if (error) { 6 | console.log(error.stack); 7 | console.log('Error Code: '+error.code); 8 | console.log('Error Signal: '+error.signal); 9 | } 10 | 11 | if(stderr){ 12 | console.log('value of stderr: ' + stderr); 13 | } 14 | 15 | console.log('Value of stdout: ' + stdout); 16 | 17 | 18 | }); 19 | workerProcess.on('exit', function (code) { 20 | //console.log("exit code : "+ code); 21 | console.log('Child process exited '); 22 | }); 23 | } -------------------------------------------------------------------------------- /day24-child-processes/master-execFile.js: -------------------------------------------------------------------------------- 1 | var ef = require('child_process').execFile; 2 | var child = ef('node', ['--version'], (err, stdout, stderr) => { 3 | if (err) { 4 | console.log('stderr', stderr); 5 | throw err; 6 | } 7 | console.log('Node.js version : ', stdout); 8 | }); -------------------------------------------------------------------------------- /day24-child-processes/master-fork.js: -------------------------------------------------------------------------------- 1 | var cp = require('child_process'); 2 | 3 | for(var i=1; i<6; i++) { 4 | var worker = cp.fork("slave.js", [i]); 5 | 6 | worker.on('close', function (code) { 7 | console.log('child process exited with code ' + code); 8 | }); 9 | } -------------------------------------------------------------------------------- /day24-child-processes/master-spawn.js: -------------------------------------------------------------------------------- 1 | var cp = require('child_process'); 2 | 3 | for(var i = 1; i<6; i++) { 4 | var worker = cp.spawn('node', ['slave.js', i]); 5 | 6 | worker.stdout.on('data', function (data) { 7 | console.log('Value of Stdout : ' + data); 8 | }); 9 | 10 | worker.stderr.on('data', function (data) { 11 | console.log('stderr: ' + data); 12 | }); 13 | 14 | worker.on('close', function (code) { 15 | //console.log("Exit code : " + code); 16 | console.log('child process exited with code '); 17 | }); 18 | } -------------------------------------------------------------------------------- /day24-child-processes/slave.js: -------------------------------------------------------------------------------- 1 | console.log("Child Process number " + process.argv[2] + " is executed." ); -------------------------------------------------------------------------------- /day25-clusters/cluster.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | var http = require('http'); 3 | var numofCPUs = require('os').cpus().length; 4 | 5 | if (cluster.isMaster) { 6 | console.log(`Master with Process ID : ${process.pid} is running`); 7 | 8 | // Fork workers. 9 | for (var i = 0; i < numofCPUs; i++) { 10 | cluster.fork(); 11 | } 12 | 13 | cluster.on('exit', (worker, code, signal) => { 14 | console.log(`worker with Process ID : ${worker.process.pid} died`); 15 | }); 16 | } else { 17 | // Workers sharing an HTTP server 18 | http.createServer((req, res) => { 19 | res.writeHead(200); 20 | res.end('An example of clusters\n'); 21 | }).listen(3000); 22 | console.log(`Worker with Process ID : ${process.pid} started`); 23 | 24 | } -------------------------------------------------------------------------------- /day25-clusters/demo.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | var numCPUs = require('os').cpus().length; 3 | 4 | if (cluster.isMaster) { 5 | // Fork workers. 6 | for (var i = 0; i < numCPUs; i++) { 7 | cluster.fork(); 8 | } 9 | 10 | Object.keys(cluster.workers).forEach(function(id) { 11 | console.log("I am running with ID : "+cluster.workers[id].process.pid); 12 | }); 13 | 14 | cluster.on('exit', function(worker, code, signal) { 15 | console.log('worker ' + worker.process.pid + ' died'); 16 | }); 17 | } else { 18 | 19 | console.log("else loop"); 20 | } -------------------------------------------------------------------------------- /day27-assert/assert-1.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert-1.js 2 | 3 | var assert = require('assert'); 4 | var a = 10; 5 | var b = 20; 6 | assert(a > b); -------------------------------------------------------------------------------- /day27-assert/assert-snippet-false.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | function demo (x,y,z) { 3 | var value = x + y + z ; 4 | return value; 5 | } 6 | var output = demo(3,2,10); 7 | console.log("Output : " + output); 8 | var expected_output = 12; 9 | console.log("Expected Output : " + expected_output); 10 | assert( output === expected_output , 'This is not what we expected'); -------------------------------------------------------------------------------- /day27-assert/assert-snippet-true.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | function demo (x,y,z) { 3 | var value = x + y + z ; 4 | return value; 5 | } 6 | var output = demo(3,2,10); 7 | console.log("Output : " + output); 8 | var expected_output = 15; 9 | console.log("Expected Output : " + expected_output); 10 | assert( output === expected_output , 'This is not what we expected'); -------------------------------------------------------------------------------- /day27-assert/assert.deepEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.deepEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | var c = 10.25; 6 | //Case 1 7 | assert.deepEqual(a,b, "Nothing printed because they are using == for comparison"); 8 | //Case 2 9 | assert.deepEqual(a,c, "Error because values doesn't match"); -------------------------------------------------------------------------------- /day27-assert/assert.deepStrictEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.deepStrictEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | 6 | assert.deepStrictEqual(a,b, "Error because they are using === for comparison"); 7 | -------------------------------------------------------------------------------- /day27-assert/assert.equal.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.equal.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | var c = 10.25; 6 | //Case 1 7 | assert.equal(a,b, "Nothing printed because they are using == for comparison"); 8 | //Case 2 9 | assert.equal(a,c, "Error because values doesn't match"); -------------------------------------------------------------------------------- /day27-assert/assert.fail.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.fail.js 2 | var assert = require('assert'); 3 | assert.fail(1, 2, 'This is an error', '>'); -------------------------------------------------------------------------------- /day27-assert/assert.ifError.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.ifError.js 2 | var assert = require('assert'); 3 | //Case 1 : No error 4 | assert.ifError(0); 5 | //Case 2 : throws 1 6 | assert.ifError(1); 7 | //Case 3 : throws error 8 | assert.ifError('error'); 9 | 10 | 11 | 12 | 13 | /**var assert = require('assert'); 14 | function sayHello(name, callback) { 15 | var error = true; 16 | var str = "Hello "+name; 17 | callback(error, str); 18 | } 19 | 20 | // use the function 21 | sayHello('World', function(err, value){ 22 | assert.ifError(err); 23 | assert.equal(value, "Hello World"); 24 | }) **/ -------------------------------------------------------------------------------- /day27-assert/assert.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = 20; 5 | assert(a > b , "A should be greater than B"); -------------------------------------------------------------------------------- /day27-assert/assert.notDeepEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.notDeepEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | var c = 10.25; 6 | //Case 1 7 | assert.notDeepEqual(a,c, "Nothing printed because they are using !== for comparison"); 8 | //Case 2 9 | assert.notDeepEqual(a,b, "Error because values match here"); 10 | 11 | -------------------------------------------------------------------------------- /day27-assert/assert.notDeepStrictEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.notDeepStrictEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | var c = 10; 6 | //Case 1 7 | assert.notDeepStrictEqual(a,b, "No Error because they are checking for not deep strict equal"); 8 | //Case 2 9 | assert.notDeepStrictEqual(a,c, "Error because values are equal"); 10 | -------------------------------------------------------------------------------- /day27-assert/assert.notEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.notEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = 10.25; 5 | var c = '10'; 6 | 7 | //Case 1 8 | assert.notEqual(a,b, "Nothing printed because they are using != for comparison"); 9 | //Case 2 10 | assert.notEqual(a,c, "Error because values match"); -------------------------------------------------------------------------------- /day27-assert/assert.notStrictEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.notStrictEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = 10.25; 5 | var c = '10'; 6 | var d = 10; 7 | 8 | //Case 1 9 | assert.notStrictEqual(a,b, "Nothing printed because they are using !== for comparison"); 10 | //Case 2 11 | assert.notStrictEqual(a,c, "Nothing printed because still its not a match"); 12 | //case 3 13 | assert.notStrictEqual(a,d, "Error because its a match"); 14 | -------------------------------------------------------------------------------- /day27-assert/assert.ok.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | //Case 1 3 | assert.ok(true, "No error "); 4 | //Case 2 5 | assert.ok(1,"No error"); 6 | //Case 3 7 | assert.ok(false,"It is an error"); 8 | //Case 4 9 | assert.ok(0 , " Again error"); 10 | //case 5 11 | var a = 10; 12 | var b = 20; 13 | assert(a > b , "A should be greater than B"); 14 | 15 | -------------------------------------------------------------------------------- /day27-assert/assert.strictEqual.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.strictEqual.js 2 | var assert = require('assert'); 3 | var a = 10; 4 | var b = '10'; 5 | var c = 10; 6 | 7 | //Case 1 8 | assert.strictEqual(a,c, "Nothing printed"); 9 | //Case 2 10 | assert.strictEqual(a,b, "Error acc to strict equality comparison"); 11 | 12 | -------------------------------------------------------------------------------- /day27-assert/assert.throw.js: -------------------------------------------------------------------------------- 1 | //Name of the file : assert.throw.js 2 | var assert = require('assert'); 3 | assert.throws( 4 | () => { 5 | throw new Error('An error occured'); 6 | }, 7 | Error 8 | ); -------------------------------------------------------------------------------- /day28-Getting-tweets-using-node/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "day28-getting-tweets-using-node", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.3", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", 10 | "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", 11 | "requires": { 12 | "mime-types": "2.1.17", 13 | "negotiator": "0.6.1" 14 | } 15 | }, 16 | "after": { 17 | "version": "0.8.2", 18 | "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", 19 | "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" 20 | }, 21 | "ajv": { 22 | "version": "5.5.1", 23 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.1.tgz", 24 | "integrity": "sha1-s4u4h22ehr7plJVqBOch6IskjrI=", 25 | "requires": { 26 | "co": "4.6.0", 27 | "fast-deep-equal": "1.0.0", 28 | "fast-json-stable-stringify": "2.0.0", 29 | "json-schema-traverse": "0.3.1" 30 | } 31 | }, 32 | "arraybuffer.slice": { 33 | "version": "0.0.6", 34 | "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", 35 | "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=" 36 | }, 37 | "asn1": { 38 | "version": "0.2.3", 39 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", 40 | "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" 41 | }, 42 | "assert-plus": { 43 | "version": "1.0.0", 44 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 45 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 46 | }, 47 | "async-limiter": { 48 | "version": "1.0.0", 49 | "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", 50 | "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==" 51 | }, 52 | "asynckit": { 53 | "version": "0.4.0", 54 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 55 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 56 | }, 57 | "aws-sign2": { 58 | "version": "0.7.0", 59 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", 60 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" 61 | }, 62 | "aws4": { 63 | "version": "1.6.0", 64 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", 65 | "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" 66 | }, 67 | "backo2": { 68 | "version": "1.0.2", 69 | "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", 70 | "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" 71 | }, 72 | "base64-arraybuffer": { 73 | "version": "0.1.5", 74 | "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", 75 | "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" 76 | }, 77 | "base64id": { 78 | "version": "1.0.0", 79 | "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", 80 | "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=" 81 | }, 82 | "bcrypt-pbkdf": { 83 | "version": "1.0.1", 84 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", 85 | "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", 86 | "optional": true, 87 | "requires": { 88 | "tweetnacl": "0.14.5" 89 | } 90 | }, 91 | "better-assert": { 92 | "version": "1.0.2", 93 | "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", 94 | "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", 95 | "requires": { 96 | "callsite": "1.0.0" 97 | } 98 | }, 99 | "bignumber.js": { 100 | "version": "4.0.4", 101 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-4.0.4.tgz", 102 | "integrity": "sha512-LDXpJKVzEx2/OqNbG9mXBNvHuiRL4PzHCGfnANHMJ+fv68Ads3exDVJeGDJws+AoNEuca93bU3q+S0woeUaCdg==" 103 | }, 104 | "blob": { 105 | "version": "0.0.4", 106 | "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", 107 | "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=" 108 | }, 109 | "body-parser": { 110 | "version": "1.18.2", 111 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", 112 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", 113 | "requires": { 114 | "bytes": "3.0.0", 115 | "content-type": "1.0.4", 116 | "debug": "2.6.9", 117 | "depd": "1.1.1", 118 | "http-errors": "1.6.2", 119 | "iconv-lite": "0.4.19", 120 | "on-finished": "2.3.0", 121 | "qs": "6.5.1", 122 | "raw-body": "2.3.2", 123 | "type-is": "1.6.15" 124 | } 125 | }, 126 | "boom": { 127 | "version": "4.3.1", 128 | "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", 129 | "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", 130 | "requires": { 131 | "hoek": "4.2.0" 132 | } 133 | }, 134 | "bytes": { 135 | "version": "3.0.0", 136 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 137 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 138 | }, 139 | "callsite": { 140 | "version": "1.0.0", 141 | "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", 142 | "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" 143 | }, 144 | "caseless": { 145 | "version": "0.12.0", 146 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 147 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 148 | }, 149 | "co": { 150 | "version": "4.6.0", 151 | "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", 152 | "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" 153 | }, 154 | "combined-stream": { 155 | "version": "1.0.5", 156 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", 157 | "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", 158 | "requires": { 159 | "delayed-stream": "1.0.0" 160 | } 161 | }, 162 | "component-bind": { 163 | "version": "1.0.0", 164 | "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", 165 | "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" 166 | }, 167 | "component-emitter": { 168 | "version": "1.2.1", 169 | "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", 170 | "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" 171 | }, 172 | "component-inherit": { 173 | "version": "0.0.3", 174 | "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", 175 | "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" 176 | }, 177 | "content-type": { 178 | "version": "1.0.4", 179 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 180 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 181 | }, 182 | "cookie": { 183 | "version": "0.3.1", 184 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 185 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 186 | }, 187 | "core-util-is": { 188 | "version": "1.0.2", 189 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 190 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 191 | }, 192 | "cryptiles": { 193 | "version": "3.1.2", 194 | "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", 195 | "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", 196 | "requires": { 197 | "boom": "5.2.0" 198 | }, 199 | "dependencies": { 200 | "boom": { 201 | "version": "5.2.0", 202 | "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", 203 | "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", 204 | "requires": { 205 | "hoek": "4.2.0" 206 | } 207 | } 208 | } 209 | }, 210 | "dashdash": { 211 | "version": "1.14.1", 212 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 213 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 214 | "requires": { 215 | "assert-plus": "1.0.0" 216 | } 217 | }, 218 | "debug": { 219 | "version": "2.6.9", 220 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 221 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 222 | "requires": { 223 | "ms": "2.0.0" 224 | } 225 | }, 226 | "deep-extend": { 227 | "version": "0.5.0", 228 | "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.0.tgz", 229 | "integrity": "sha1-bvSgmwX5iw41jW2T1Mo8rsZnKAM=" 230 | }, 231 | "delayed-stream": { 232 | "version": "1.0.0", 233 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 234 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 235 | }, 236 | "depd": { 237 | "version": "1.1.1", 238 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", 239 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" 240 | }, 241 | "ecc-jsbn": { 242 | "version": "0.1.1", 243 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", 244 | "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", 245 | "optional": true, 246 | "requires": { 247 | "jsbn": "0.1.1" 248 | } 249 | }, 250 | "ee-first": { 251 | "version": "1.1.1", 252 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 253 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 254 | }, 255 | "engine.io": { 256 | "version": "3.1.4", 257 | "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.4.tgz", 258 | "integrity": "sha1-PQIRtwpVLOhB/8fahiezAamkFi4=", 259 | "requires": { 260 | "accepts": "1.3.3", 261 | "base64id": "1.0.0", 262 | "cookie": "0.3.1", 263 | "debug": "2.6.9", 264 | "engine.io-parser": "2.1.1", 265 | "uws": "0.14.5", 266 | "ws": "3.3.2" 267 | } 268 | }, 269 | "engine.io-client": { 270 | "version": "3.1.4", 271 | "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.4.tgz", 272 | "integrity": "sha1-T88TcLRxY70s6b4nM5ckMDUNTqE=", 273 | "requires": { 274 | "component-emitter": "1.2.1", 275 | "component-inherit": "0.0.3", 276 | "debug": "2.6.9", 277 | "engine.io-parser": "2.1.1", 278 | "has-cors": "1.1.0", 279 | "indexof": "0.0.1", 280 | "parseqs": "0.0.5", 281 | "parseuri": "0.0.5", 282 | "ws": "3.3.2", 283 | "xmlhttprequest-ssl": "1.5.4", 284 | "yeast": "0.1.2" 285 | } 286 | }, 287 | "engine.io-parser": { 288 | "version": "2.1.1", 289 | "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz", 290 | "integrity": "sha1-4Ps/DgRi9/WLt3waUun1p+JuRmg=", 291 | "requires": { 292 | "after": "0.8.2", 293 | "arraybuffer.slice": "0.0.6", 294 | "base64-arraybuffer": "0.1.5", 295 | "blob": "0.0.4", 296 | "has-binary2": "1.0.2" 297 | } 298 | }, 299 | "express": { 300 | "version": "4.16.2", 301 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", 302 | "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", 303 | "requires": { 304 | "accepts": "1.3.4", 305 | "array-flatten": "1.1.1", 306 | "body-parser": "1.18.2", 307 | "content-disposition": "0.5.2", 308 | "content-type": "1.0.4", 309 | "cookie": "0.3.1", 310 | "cookie-signature": "1.0.6", 311 | "debug": "2.6.9", 312 | "depd": "1.1.1", 313 | "encodeurl": "1.0.1", 314 | "escape-html": "1.0.3", 315 | "etag": "1.8.1", 316 | "finalhandler": "1.1.0", 317 | "fresh": "0.5.2", 318 | "merge-descriptors": "1.0.1", 319 | "methods": "1.1.2", 320 | "on-finished": "2.3.0", 321 | "parseurl": "1.3.2", 322 | "path-to-regexp": "0.1.7", 323 | "proxy-addr": "2.0.2", 324 | "qs": "6.5.1", 325 | "range-parser": "1.2.0", 326 | "safe-buffer": "5.1.1", 327 | "send": "0.16.1", 328 | "serve-static": "1.13.1", 329 | "setprototypeof": "1.1.0", 330 | "statuses": "1.3.1", 331 | "type-is": "1.6.15", 332 | "utils-merge": "1.0.1", 333 | "vary": "1.1.2" 334 | }, 335 | "dependencies": { 336 | "accepts": { 337 | "version": "1.3.4", 338 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", 339 | "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", 340 | "requires": { 341 | "mime-types": "2.1.17", 342 | "negotiator": "0.6.1" 343 | } 344 | }, 345 | "array-flatten": { 346 | "version": "1.1.1", 347 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 348 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 349 | }, 350 | "body-parser": { 351 | "version": "1.18.2", 352 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", 353 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", 354 | "requires": { 355 | "bytes": "3.0.0", 356 | "content-type": "1.0.4", 357 | "debug": "2.6.9", 358 | "depd": "1.1.1", 359 | "http-errors": "1.6.2", 360 | "iconv-lite": "0.4.19", 361 | "on-finished": "2.3.0", 362 | "qs": "6.5.1", 363 | "raw-body": "2.3.2", 364 | "type-is": "1.6.15" 365 | } 366 | }, 367 | "bytes": { 368 | "version": "3.0.0", 369 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 370 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 371 | }, 372 | "content-disposition": { 373 | "version": "0.5.2", 374 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 375 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" 376 | }, 377 | "content-type": { 378 | "version": "1.0.4", 379 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 380 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 381 | }, 382 | "cookie": { 383 | "version": "0.3.1", 384 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 385 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 386 | }, 387 | "cookie-signature": { 388 | "version": "1.0.6", 389 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 390 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 391 | }, 392 | "debug": { 393 | "version": "2.6.9", 394 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 395 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 396 | "requires": { 397 | "ms": "2.0.0" 398 | } 399 | }, 400 | "depd": { 401 | "version": "1.1.1", 402 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", 403 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" 404 | }, 405 | "destroy": { 406 | "version": "1.0.4", 407 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 408 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 409 | }, 410 | "ee-first": { 411 | "version": "1.1.1", 412 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 413 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 414 | }, 415 | "encodeurl": { 416 | "version": "1.0.1", 417 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", 418 | "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" 419 | }, 420 | "escape-html": { 421 | "version": "1.0.3", 422 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 423 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 424 | }, 425 | "etag": { 426 | "version": "1.8.1", 427 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 428 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 429 | }, 430 | "finalhandler": { 431 | "version": "1.1.0", 432 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", 433 | "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", 434 | "requires": { 435 | "debug": "2.6.9", 436 | "encodeurl": "1.0.1", 437 | "escape-html": "1.0.3", 438 | "on-finished": "2.3.0", 439 | "parseurl": "1.3.2", 440 | "statuses": "1.3.1", 441 | "unpipe": "1.0.0" 442 | } 443 | }, 444 | "forwarded": { 445 | "version": "0.1.2", 446 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 447 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 448 | }, 449 | "fresh": { 450 | "version": "0.5.2", 451 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 452 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 453 | }, 454 | "http-errors": { 455 | "version": "1.6.2", 456 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", 457 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", 458 | "requires": { 459 | "depd": "1.1.1", 460 | "inherits": "2.0.3", 461 | "setprototypeof": "1.0.3", 462 | "statuses": "1.3.1" 463 | }, 464 | "dependencies": { 465 | "setprototypeof": { 466 | "version": "1.0.3", 467 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", 468 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" 469 | } 470 | } 471 | }, 472 | "iconv-lite": { 473 | "version": "0.4.19", 474 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 475 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 476 | }, 477 | "inherits": { 478 | "version": "2.0.3", 479 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 480 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 481 | }, 482 | "ipaddr.js": { 483 | "version": "1.5.2", 484 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", 485 | "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" 486 | }, 487 | "media-typer": { 488 | "version": "0.3.0", 489 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 490 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 491 | }, 492 | "merge-descriptors": { 493 | "version": "1.0.1", 494 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 495 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 496 | }, 497 | "methods": { 498 | "version": "1.1.2", 499 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 500 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 501 | }, 502 | "mime": { 503 | "version": "1.4.1", 504 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", 505 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" 506 | }, 507 | "mime-db": { 508 | "version": "1.30.0", 509 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", 510 | "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" 511 | }, 512 | "mime-types": { 513 | "version": "2.1.17", 514 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", 515 | "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", 516 | "requires": { 517 | "mime-db": "1.30.0" 518 | } 519 | }, 520 | "ms": { 521 | "version": "2.0.0", 522 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 523 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 524 | }, 525 | "negotiator": { 526 | "version": "0.6.1", 527 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 528 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 529 | }, 530 | "on-finished": { 531 | "version": "2.3.0", 532 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 533 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 534 | "requires": { 535 | "ee-first": "1.1.1" 536 | } 537 | }, 538 | "parseurl": { 539 | "version": "1.3.2", 540 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", 541 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" 542 | }, 543 | "path-to-regexp": { 544 | "version": "0.1.7", 545 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 546 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 547 | }, 548 | "proxy-addr": { 549 | "version": "2.0.2", 550 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", 551 | "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", 552 | "requires": { 553 | "forwarded": "0.1.2", 554 | "ipaddr.js": "1.5.2" 555 | } 556 | }, 557 | "qs": { 558 | "version": "6.5.1", 559 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 560 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 561 | }, 562 | "range-parser": { 563 | "version": "1.2.0", 564 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", 565 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" 566 | }, 567 | "raw-body": { 568 | "version": "2.3.2", 569 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", 570 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", 571 | "requires": { 572 | "bytes": "3.0.0", 573 | "http-errors": "1.6.2", 574 | "iconv-lite": "0.4.19", 575 | "unpipe": "1.0.0" 576 | } 577 | }, 578 | "safe-buffer": { 579 | "version": "5.1.1", 580 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 581 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 582 | }, 583 | "send": { 584 | "version": "0.16.1", 585 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", 586 | "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", 587 | "requires": { 588 | "debug": "2.6.9", 589 | "depd": "1.1.1", 590 | "destroy": "1.0.4", 591 | "encodeurl": "1.0.1", 592 | "escape-html": "1.0.3", 593 | "etag": "1.8.1", 594 | "fresh": "0.5.2", 595 | "http-errors": "1.6.2", 596 | "mime": "1.4.1", 597 | "ms": "2.0.0", 598 | "on-finished": "2.3.0", 599 | "range-parser": "1.2.0", 600 | "statuses": "1.3.1" 601 | } 602 | }, 603 | "serve-static": { 604 | "version": "1.13.1", 605 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", 606 | "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", 607 | "requires": { 608 | "encodeurl": "1.0.1", 609 | "escape-html": "1.0.3", 610 | "parseurl": "1.3.2", 611 | "send": "0.16.1" 612 | } 613 | }, 614 | "setprototypeof": { 615 | "version": "1.1.0", 616 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", 617 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" 618 | }, 619 | "statuses": { 620 | "version": "1.3.1", 621 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", 622 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" 623 | }, 624 | "type-is": { 625 | "version": "1.6.15", 626 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", 627 | "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", 628 | "requires": { 629 | "media-typer": "0.3.0", 630 | "mime-types": "2.1.17" 631 | } 632 | }, 633 | "unpipe": { 634 | "version": "1.0.0", 635 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 636 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 637 | }, 638 | "utils-merge": { 639 | "version": "1.0.1", 640 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 641 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 642 | }, 643 | "vary": { 644 | "version": "1.1.2", 645 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 646 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 647 | } 648 | } 649 | }, 650 | "extend": { 651 | "version": "3.0.1", 652 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", 653 | "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" 654 | }, 655 | "extsprintf": { 656 | "version": "1.3.0", 657 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", 658 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" 659 | }, 660 | "fast-deep-equal": { 661 | "version": "1.0.0", 662 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", 663 | "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" 664 | }, 665 | "fast-json-stable-stringify": { 666 | "version": "2.0.0", 667 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", 668 | "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" 669 | }, 670 | "forever-agent": { 671 | "version": "0.6.1", 672 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 673 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" 674 | }, 675 | "form-data": { 676 | "version": "2.3.1", 677 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", 678 | "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", 679 | "requires": { 680 | "asynckit": "0.4.0", 681 | "combined-stream": "1.0.5", 682 | "mime-types": "2.1.17" 683 | } 684 | }, 685 | "getpass": { 686 | "version": "0.1.7", 687 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 688 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 689 | "requires": { 690 | "assert-plus": "1.0.0" 691 | } 692 | }, 693 | "har-schema": { 694 | "version": "2.0.0", 695 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", 696 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" 697 | }, 698 | "har-validator": { 699 | "version": "5.0.3", 700 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", 701 | "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", 702 | "requires": { 703 | "ajv": "5.5.1", 704 | "har-schema": "2.0.0" 705 | } 706 | }, 707 | "has-binary2": { 708 | "version": "1.0.2", 709 | "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.2.tgz", 710 | "integrity": "sha1-6D26SfC5vk0CbSc2U1DZ8D9Uvpg=", 711 | "requires": { 712 | "isarray": "2.0.1" 713 | }, 714 | "dependencies": { 715 | "isarray": { 716 | "version": "2.0.1", 717 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", 718 | "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" 719 | } 720 | } 721 | }, 722 | "has-cors": { 723 | "version": "1.1.0", 724 | "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", 725 | "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" 726 | }, 727 | "hawk": { 728 | "version": "6.0.2", 729 | "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", 730 | "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", 731 | "requires": { 732 | "boom": "4.3.1", 733 | "cryptiles": "3.1.2", 734 | "hoek": "4.2.0", 735 | "sntp": "2.1.0" 736 | } 737 | }, 738 | "hoek": { 739 | "version": "4.2.0", 740 | "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", 741 | "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" 742 | }, 743 | "http-errors": { 744 | "version": "1.6.2", 745 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", 746 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", 747 | "requires": { 748 | "depd": "1.1.1", 749 | "inherits": "2.0.3", 750 | "setprototypeof": "1.0.3", 751 | "statuses": "1.4.0" 752 | } 753 | }, 754 | "http-signature": { 755 | "version": "1.2.0", 756 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", 757 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", 758 | "requires": { 759 | "assert-plus": "1.0.0", 760 | "jsprim": "1.4.1", 761 | "sshpk": "1.13.1" 762 | } 763 | }, 764 | "iconv-lite": { 765 | "version": "0.4.19", 766 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 767 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 768 | }, 769 | "indexof": { 770 | "version": "0.0.1", 771 | "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", 772 | "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" 773 | }, 774 | "inherits": { 775 | "version": "2.0.3", 776 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 777 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 778 | }, 779 | "is-typedarray": { 780 | "version": "1.0.0", 781 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 782 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" 783 | }, 784 | "isarray": { 785 | "version": "1.0.0", 786 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 787 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 788 | }, 789 | "isstream": { 790 | "version": "0.1.2", 791 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 792 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 793 | }, 794 | "jsbn": { 795 | "version": "0.1.1", 796 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 797 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", 798 | "optional": true 799 | }, 800 | "json-schema": { 801 | "version": "0.2.3", 802 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 803 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" 804 | }, 805 | "json-schema-traverse": { 806 | "version": "0.3.1", 807 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", 808 | "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" 809 | }, 810 | "json-stringify-safe": { 811 | "version": "5.0.1", 812 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 813 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 814 | }, 815 | "jsprim": { 816 | "version": "1.4.1", 817 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", 818 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", 819 | "requires": { 820 | "assert-plus": "1.0.0", 821 | "extsprintf": "1.3.0", 822 | "json-schema": "0.2.3", 823 | "verror": "1.10.0" 824 | } 825 | }, 826 | "media-typer": { 827 | "version": "0.3.0", 828 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 829 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 830 | }, 831 | "mime-db": { 832 | "version": "1.30.0", 833 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", 834 | "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" 835 | }, 836 | "mime-types": { 837 | "version": "2.1.17", 838 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", 839 | "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", 840 | "requires": { 841 | "mime-db": "1.30.0" 842 | } 843 | }, 844 | "ms": { 845 | "version": "2.0.0", 846 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 847 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 848 | }, 849 | "mysql": { 850 | "version": "2.15.0", 851 | "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.15.0.tgz", 852 | "integrity": "sha512-C7tjzWtbN5nzkLIV+E8Crnl9bFyc7d3XJcBAvHKEVkjrYjogz3llo22q6s/hw+UcsE4/844pDob9ac+3dVjQSA==", 853 | "requires": { 854 | "bignumber.js": "4.0.4", 855 | "readable-stream": "2.3.3", 856 | "safe-buffer": "5.1.1", 857 | "sqlstring": "2.3.0" 858 | } 859 | }, 860 | "negotiator": { 861 | "version": "0.6.1", 862 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 863 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 864 | }, 865 | "oauth-sign": { 866 | "version": "0.8.2", 867 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", 868 | "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" 869 | }, 870 | "object-component": { 871 | "version": "0.0.3", 872 | "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", 873 | "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" 874 | }, 875 | "on-finished": { 876 | "version": "2.3.0", 877 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 878 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 879 | "requires": { 880 | "ee-first": "1.1.1" 881 | } 882 | }, 883 | "parseqs": { 884 | "version": "0.0.5", 885 | "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", 886 | "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", 887 | "requires": { 888 | "better-assert": "1.0.2" 889 | } 890 | }, 891 | "parseuri": { 892 | "version": "0.0.5", 893 | "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", 894 | "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", 895 | "requires": { 896 | "better-assert": "1.0.2" 897 | } 898 | }, 899 | "performance-now": { 900 | "version": "2.1.0", 901 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", 902 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" 903 | }, 904 | "process-nextick-args": { 905 | "version": "1.0.7", 906 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", 907 | "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" 908 | }, 909 | "punycode": { 910 | "version": "1.4.1", 911 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 912 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" 913 | }, 914 | "qs": { 915 | "version": "6.5.1", 916 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 917 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 918 | }, 919 | "raw-body": { 920 | "version": "2.3.2", 921 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", 922 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", 923 | "requires": { 924 | "bytes": "3.0.0", 925 | "http-errors": "1.6.2", 926 | "iconv-lite": "0.4.19", 927 | "unpipe": "1.0.0" 928 | } 929 | }, 930 | "readable-stream": { 931 | "version": "2.3.3", 932 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", 933 | "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", 934 | "requires": { 935 | "core-util-is": "1.0.2", 936 | "inherits": "2.0.3", 937 | "isarray": "1.0.0", 938 | "process-nextick-args": "1.0.7", 939 | "safe-buffer": "5.1.1", 940 | "string_decoder": "1.0.3", 941 | "util-deprecate": "1.0.2" 942 | } 943 | }, 944 | "request": { 945 | "version": "2.83.0", 946 | "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", 947 | "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", 948 | "requires": { 949 | "aws-sign2": "0.7.0", 950 | "aws4": "1.6.0", 951 | "caseless": "0.12.0", 952 | "combined-stream": "1.0.5", 953 | "extend": "3.0.1", 954 | "forever-agent": "0.6.1", 955 | "form-data": "2.3.1", 956 | "har-validator": "5.0.3", 957 | "hawk": "6.0.2", 958 | "http-signature": "1.2.0", 959 | "is-typedarray": "1.0.0", 960 | "isstream": "0.1.2", 961 | "json-stringify-safe": "5.0.1", 962 | "mime-types": "2.1.17", 963 | "oauth-sign": "0.8.2", 964 | "performance-now": "2.1.0", 965 | "qs": "6.5.1", 966 | "safe-buffer": "5.1.1", 967 | "stringstream": "0.0.5", 968 | "tough-cookie": "2.3.3", 969 | "tunnel-agent": "0.6.0", 970 | "uuid": "3.1.0" 971 | } 972 | }, 973 | "safe-buffer": { 974 | "version": "5.1.1", 975 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 976 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 977 | }, 978 | "setprototypeof": { 979 | "version": "1.0.3", 980 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", 981 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" 982 | }, 983 | "sntp": { 984 | "version": "2.1.0", 985 | "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", 986 | "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", 987 | "requires": { 988 | "hoek": "4.2.0" 989 | } 990 | }, 991 | "socket.io": { 992 | "version": "2.0.4", 993 | "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.4.tgz", 994 | "integrity": "sha1-waRZDO/4fs8TxyZS8Eb3FrKeYBQ=", 995 | "requires": { 996 | "debug": "2.6.9", 997 | "engine.io": "3.1.4", 998 | "socket.io-adapter": "1.1.1", 999 | "socket.io-client": "2.0.4", 1000 | "socket.io-parser": "3.1.2" 1001 | } 1002 | }, 1003 | "socket.io-adapter": { 1004 | "version": "1.1.1", 1005 | "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", 1006 | "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=" 1007 | }, 1008 | "socket.io-client": { 1009 | "version": "2.0.4", 1010 | "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz", 1011 | "integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=", 1012 | "requires": { 1013 | "backo2": "1.0.2", 1014 | "base64-arraybuffer": "0.1.5", 1015 | "component-bind": "1.0.0", 1016 | "component-emitter": "1.2.1", 1017 | "debug": "2.6.9", 1018 | "engine.io-client": "3.1.4", 1019 | "has-cors": "1.1.0", 1020 | "indexof": "0.0.1", 1021 | "object-component": "0.0.3", 1022 | "parseqs": "0.0.5", 1023 | "parseuri": "0.0.5", 1024 | "socket.io-parser": "3.1.2", 1025 | "to-array": "0.1.4" 1026 | } 1027 | }, 1028 | "socket.io-parser": { 1029 | "version": "3.1.2", 1030 | "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.2.tgz", 1031 | "integrity": "sha1-28IoIVH8T6675Aru3Ady66YZ9/I=", 1032 | "requires": { 1033 | "component-emitter": "1.2.1", 1034 | "debug": "2.6.9", 1035 | "has-binary2": "1.0.2", 1036 | "isarray": "2.0.1" 1037 | }, 1038 | "dependencies": { 1039 | "isarray": { 1040 | "version": "2.0.1", 1041 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", 1042 | "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" 1043 | } 1044 | } 1045 | }, 1046 | "sqlstring": { 1047 | "version": "2.3.0", 1048 | "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.0.tgz", 1049 | "integrity": "sha1-UluKT9Jtb3GqYegipsr5dtMa0qg=" 1050 | }, 1051 | "sshpk": { 1052 | "version": "1.13.1", 1053 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", 1054 | "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", 1055 | "requires": { 1056 | "asn1": "0.2.3", 1057 | "assert-plus": "1.0.0", 1058 | "bcrypt-pbkdf": "1.0.1", 1059 | "dashdash": "1.14.1", 1060 | "ecc-jsbn": "0.1.1", 1061 | "getpass": "0.1.7", 1062 | "jsbn": "0.1.1", 1063 | "tweetnacl": "0.14.5" 1064 | } 1065 | }, 1066 | "statuses": { 1067 | "version": "1.4.0", 1068 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", 1069 | "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" 1070 | }, 1071 | "string_decoder": { 1072 | "version": "1.0.3", 1073 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", 1074 | "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", 1075 | "requires": { 1076 | "safe-buffer": "5.1.1" 1077 | } 1078 | }, 1079 | "stringstream": { 1080 | "version": "0.0.5", 1081 | "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", 1082 | "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" 1083 | }, 1084 | "to-array": { 1085 | "version": "0.1.4", 1086 | "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", 1087 | "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" 1088 | }, 1089 | "tough-cookie": { 1090 | "version": "2.3.3", 1091 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", 1092 | "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", 1093 | "requires": { 1094 | "punycode": "1.4.1" 1095 | } 1096 | }, 1097 | "tunnel-agent": { 1098 | "version": "0.6.0", 1099 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 1100 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 1101 | "requires": { 1102 | "safe-buffer": "5.1.1" 1103 | } 1104 | }, 1105 | "tweetnacl": { 1106 | "version": "0.14.5", 1107 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 1108 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", 1109 | "optional": true 1110 | }, 1111 | "twitter": { 1112 | "version": "1.7.1", 1113 | "resolved": "https://registry.npmjs.org/twitter/-/twitter-1.7.1.tgz", 1114 | "integrity": "sha1-B2I3jx3BwFDkj2ZqypBOJLGpYvQ=", 1115 | "requires": { 1116 | "deep-extend": "0.5.0", 1117 | "request": "2.83.0" 1118 | } 1119 | }, 1120 | "type-is": { 1121 | "version": "1.6.15", 1122 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", 1123 | "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", 1124 | "requires": { 1125 | "media-typer": "0.3.0", 1126 | "mime-types": "2.1.17" 1127 | } 1128 | }, 1129 | "ultron": { 1130 | "version": "1.1.1", 1131 | "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", 1132 | "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" 1133 | }, 1134 | "unpipe": { 1135 | "version": "1.0.0", 1136 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 1137 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 1138 | }, 1139 | "util-deprecate": { 1140 | "version": "1.0.2", 1141 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 1142 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 1143 | }, 1144 | "uuid": { 1145 | "version": "3.1.0", 1146 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", 1147 | "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" 1148 | }, 1149 | "uws": { 1150 | "version": "0.14.5", 1151 | "resolved": "https://registry.npmjs.org/uws/-/uws-0.14.5.tgz", 1152 | "integrity": "sha1-Z6rzPEaypYel9mZtAPdpEyjxSdw=", 1153 | "optional": true 1154 | }, 1155 | "verror": { 1156 | "version": "1.10.0", 1157 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", 1158 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", 1159 | "requires": { 1160 | "assert-plus": "1.0.0", 1161 | "core-util-is": "1.0.2", 1162 | "extsprintf": "1.3.0" 1163 | } 1164 | }, 1165 | "ws": { 1166 | "version": "3.3.2", 1167 | "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.2.tgz", 1168 | "integrity": "sha512-t+WGpsNxhMR4v6EClXS8r8km5ZljKJzyGhJf7goJz9k5Ye3+b5Bvno5rjqPuIBn5mnn5GBb7o8IrIWHxX1qOLQ==", 1169 | "requires": { 1170 | "async-limiter": "1.0.0", 1171 | "safe-buffer": "5.1.1", 1172 | "ultron": "1.1.1" 1173 | } 1174 | }, 1175 | "xmlhttprequest-ssl": { 1176 | "version": "1.5.4", 1177 | "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.4.tgz", 1178 | "integrity": "sha1-BPVgkVcks4kIhxXMDteBPpZ3v1c=" 1179 | }, 1180 | "yeast": { 1181 | "version": "0.1.2", 1182 | "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", 1183 | "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" 1184 | } 1185 | } 1186 | } 1187 | -------------------------------------------------------------------------------- /day28-Getting-tweets-using-node/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "day28-getting-tweets-using-node", 3 | "version": "1.0.0", 4 | "description": "Getting tweets from twitter using node.js , twitter's streaming api and sockets.", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [ 11 | "nodejs", 12 | "socket.io", 13 | "twitter", 14 | "getting", 15 | "tweets", 16 | "using", 17 | "node.js", 18 | "30", 19 | "days", 20 | "of", 21 | "node", 22 | "day", 23 | "28" 24 | ], 25 | "author": "@nodejsera , @rajatgarian", 26 | "license": "ISC", 27 | "dependencies": { 28 | "body-parser": "^1.18.2", 29 | "express": "^4.16.2", 30 | "mysql": "^2.15.0", 31 | "socket.io": "^2.0.4", 32 | "twitter": "^1.7.1" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /day28-Getting-tweets-using-node/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tweetoletics | nodejsera 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
22 |
23 |
24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |

Enter the Keyword

32 | 33 |
34 | 35 | 36 | 37 |
38 |
39 | 40 |
41 | 42 |
43 |
44 |
45 |
46 |
47 |
48 | 49 |
50 | 51 |
52 | 53 |
54 |

Live Tweets

55 | 56 |
57 |
58 |
59 | 60 | 61 |
62 | 63 |
64 | 65 |
66 |
67 | 68 | 69 | 91 | 92 | -------------------------------------------------------------------------------- /day28-Getting-tweets-using-node/public/style.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Josefin+Slab'); 2 | @import url('https://fonts.googleapis.com/css?family=Inconsolata|Lato|Merriweather'); 3 | /** 4 | font-family: 'Inconsolata', monospace; 5 | font-family: 'Lato', sans-serif; 6 | font-family: 'Merriweather', serif; 7 | **/ 8 | 9 | .main{ 10 | padding:20px; 11 | font-family: 'Josefin Slab', serif; 12 | border : 2px solid #000000; 13 | border-radius: 15px; 14 | 15 | } 16 | 17 | 18 | .content{ 19 | font-family: 'Inconsolata', monospace; 20 | font-size: 20px; 21 | color : #000000; 22 | } 23 | b{ 24 | font-family: 'Inconsolata', monospace; 25 | font-size: 20px; 26 | color: black; 27 | } 28 | 29 | 30 | 31 | .main h1{ 32 | font-size: 50px; 33 | text-align:center; 34 | font-family: 'Josefin Slab', serif; 35 | color: #33333; 36 | } 37 | input{ 38 | font-family: 'Josefin Slab', serif; 39 | width: 100%; 40 | font-size: 30px; 41 | padding: 12px 20px; 42 | margin: 8px 0; 43 | border: 2px solid #222222; 44 | } 45 | button { 46 | font-family: 'Merriweather', serif; 47 | font-size: 40px; 48 | width: 100%; 49 | background-color: #888; 50 | border: none; 51 | color: white; 52 | padding: 16px 32px; 53 | text-decoration: none; 54 | margin: 4px 2px; 55 | cursor: pointer; 56 | border-radius: 15px; 57 | } 58 | input:focus, 59 | select:focus, 60 | button:focus { 61 | outline: none; 62 | } 63 | 64 | input:hover { 65 | font-family: 'Josefin Slab', serif; 66 | width: 100%; 67 | padding: 12px 20px; 68 | margin: 8px 0; 69 | box-sizing: border-box; 70 | border: 2px solid #4dffa6; 71 | } 72 | 73 | button:hover { 74 | font-family: 'Merriweather', serif; 75 | font-size: 40px; 76 | width: 100%; 77 | background-color: #1aff8c; 78 | border: none; 79 | color: white; 80 | padding: 16px 32px; 81 | text-decoration: none; 82 | margin: 4px 2px; 83 | cursor: pointer; 84 | border-radius: 15px; 85 | } -------------------------------------------------------------------------------- /day28-Getting-tweets-using-node/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var path = require('path'); 3 | 4 | var app = express(); 5 | var server = require('http').Server(app); 6 | var bodyParser = require('body-parser'); 7 | var io = require('socket.io')(server);; 8 | //Twitter 9 | var Twitter = require('twitter'); 10 | var request = require("request"); 11 | //MySQL 12 | var mysql = require('mysql'); 13 | var connect = mysql.createPool({ 14 | host : 'localhost', 15 | user : 'root', 16 | password: '', 17 | database: 'my_db' 18 | }); 19 | 20 | server.listen(3000); 21 | //Twitter Credentials 22 | var client = new Twitter({ 23 | consumer_key: 'YOUR_CONSUMER_KEY', 24 | consumer_secret: 'YOUR_CONSUMER_SECRET', 25 | access_token_key: 'YOUR_ACCESS_TOKEN_KEY', 26 | access_token_secret: 'YOUR_ACCESS_TOKEN_SECRET' 27 | }); 28 | 29 | //Default Route 30 | app.get('/',function(req,res){ 31 | res.set({ 32 | 'Access-Control-Allow-Origin' : '*' 33 | }); 34 | return res.redirect('/public/index.html'); 35 | }); 36 | 37 | console.log("Server listening at : 3000"); 38 | app.use('/public', express.static(__dirname + '/public')); 39 | app.use( bodyParser.json() ); 40 | app.use(bodyParser.urlencoded({ // to support URL-encoded bodies 41 | extended: true 42 | })); 43 | 44 | io.on('connection', function (socket) { 45 | 46 | socket.emit('welcome', { data: 'welcome' }); 47 | socket.on('keyword' , function(data){ 48 | console.log(data); 49 | var keyword = data.keyword; 50 | var stream = client.stream('statuses/filter', {track: keyword}); 51 | stream.on('data', function(event) { 52 | var tweet = event.text; 53 | var user = event.user.name; 54 | 55 | var insert_R = 'INSERT INTO tweet_repo(keyword,user,tweet) VALUE(?,?,?)'; 56 | //establishing connection 57 | connect.getConnection(function(err, connection){ 58 | //Inserting a record into details 59 | connection.query(insert_R,[keyword,user,tweet], function(err,res){ 60 | if(err) throw err; 61 | else { 62 | var content = { 63 | keyword : keyword, 64 | user : user, 65 | tweet : tweet 66 | } 67 | console.log("Keyword is ::>> " + keyword); 68 | console.log("Tweeted by ::>>" + event.user.name); 69 | console.log("Tweet is ::>>" + event.text ); 70 | console.log('Details added successfully'); 71 | socket.emit('livetweets' , { data : content }) 72 | 73 | } 74 | }); 75 | //releasing connection 76 | socket.on('stop' , function(data){ 77 | connection.release(); 78 | }); 79 | 80 | }); 81 | 82 | }); 83 | 84 | stream.on('error', function(error) { 85 | throw error; 86 | }); 87 | }); 88 | }); -------------------------------------------------------------------------------- /day29-dropbox-file-upload/dropbox-file-upload.js: -------------------------------------------------------------------------------- 1 | var request = require('request'); 2 | var fs = require('fs'); 3 | 4 | var access_token = "YOUR_ACCESS_TOKEN_HERE"; 5 | var filename = 'package.json'; 6 | var content = fs.readFileSync(filename); 7 | options = { 8 | method: "POST", 9 | url: 'https://content.dropboxapi.com/2/files/upload', 10 | headers: { 11 | "Content-Type": "application/octet-stream", 12 | "Authorization": "Bearer " + access_token, 13 | "Dropbox-API-Arg": "{\"path\": \"/njera/"+filename+"\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}", 14 | }, 15 | body:content 16 | }; 17 | 18 | request(options,function(err, res,body){ 19 | console.log("Err : " + err); 20 | console.log("res : " + res); 21 | console.log("body : " + body); 22 | }) -------------------------------------------------------------------------------- /day29-dropbox-file-upload/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dropbox-file-upload", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "ajv": { 8 | "version": "5.5.2", 9 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", 10 | "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", 11 | "requires": { 12 | "co": "4.6.0", 13 | "fast-deep-equal": "1.0.0", 14 | "fast-json-stable-stringify": "2.0.0", 15 | "json-schema-traverse": "0.3.1" 16 | } 17 | }, 18 | "asn1": { 19 | "version": "0.2.3", 20 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", 21 | "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" 22 | }, 23 | "assert-plus": { 24 | "version": "1.0.0", 25 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 26 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" 27 | }, 28 | "asynckit": { 29 | "version": "0.4.0", 30 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 31 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" 32 | }, 33 | "aws-sign2": { 34 | "version": "0.7.0", 35 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", 36 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" 37 | }, 38 | "aws4": { 39 | "version": "1.6.0", 40 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", 41 | "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" 42 | }, 43 | "bcrypt-pbkdf": { 44 | "version": "1.0.1", 45 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", 46 | "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", 47 | "optional": true, 48 | "requires": { 49 | "tweetnacl": "0.14.5" 50 | } 51 | }, 52 | "boom": { 53 | "version": "4.3.1", 54 | "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", 55 | "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", 56 | "requires": { 57 | "hoek": "4.2.0" 58 | } 59 | }, 60 | "caseless": { 61 | "version": "0.12.0", 62 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 63 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" 64 | }, 65 | "co": { 66 | "version": "4.6.0", 67 | "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", 68 | "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" 69 | }, 70 | "combined-stream": { 71 | "version": "1.0.5", 72 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", 73 | "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", 74 | "requires": { 75 | "delayed-stream": "1.0.0" 76 | } 77 | }, 78 | "core-util-is": { 79 | "version": "1.0.2", 80 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 81 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" 82 | }, 83 | "cryptiles": { 84 | "version": "3.1.2", 85 | "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", 86 | "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", 87 | "requires": { 88 | "boom": "5.2.0" 89 | }, 90 | "dependencies": { 91 | "boom": { 92 | "version": "5.2.0", 93 | "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", 94 | "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", 95 | "requires": { 96 | "hoek": "4.2.0" 97 | } 98 | } 99 | } 100 | }, 101 | "dashdash": { 102 | "version": "1.14.1", 103 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 104 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 105 | "requires": { 106 | "assert-plus": "1.0.0" 107 | } 108 | }, 109 | "delayed-stream": { 110 | "version": "1.0.0", 111 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 112 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" 113 | }, 114 | "ecc-jsbn": { 115 | "version": "0.1.1", 116 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", 117 | "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", 118 | "optional": true, 119 | "requires": { 120 | "jsbn": "0.1.1" 121 | } 122 | }, 123 | "extend": { 124 | "version": "3.0.1", 125 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", 126 | "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" 127 | }, 128 | "extsprintf": { 129 | "version": "1.3.0", 130 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", 131 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" 132 | }, 133 | "fast-deep-equal": { 134 | "version": "1.0.0", 135 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", 136 | "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" 137 | }, 138 | "fast-json-stable-stringify": { 139 | "version": "2.0.0", 140 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", 141 | "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" 142 | }, 143 | "forever-agent": { 144 | "version": "0.6.1", 145 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 146 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" 147 | }, 148 | "form-data": { 149 | "version": "2.3.1", 150 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", 151 | "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", 152 | "requires": { 153 | "asynckit": "0.4.0", 154 | "combined-stream": "1.0.5", 155 | "mime-types": "2.1.17" 156 | } 157 | }, 158 | "getpass": { 159 | "version": "0.1.7", 160 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 161 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 162 | "requires": { 163 | "assert-plus": "1.0.0" 164 | } 165 | }, 166 | "har-schema": { 167 | "version": "2.0.0", 168 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", 169 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" 170 | }, 171 | "har-validator": { 172 | "version": "5.0.3", 173 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", 174 | "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", 175 | "requires": { 176 | "ajv": "5.5.2", 177 | "har-schema": "2.0.0" 178 | } 179 | }, 180 | "hawk": { 181 | "version": "6.0.2", 182 | "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", 183 | "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", 184 | "requires": { 185 | "boom": "4.3.1", 186 | "cryptiles": "3.1.2", 187 | "hoek": "4.2.0", 188 | "sntp": "2.1.0" 189 | } 190 | }, 191 | "hoek": { 192 | "version": "4.2.0", 193 | "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", 194 | "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" 195 | }, 196 | "http-signature": { 197 | "version": "1.2.0", 198 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", 199 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", 200 | "requires": { 201 | "assert-plus": "1.0.0", 202 | "jsprim": "1.4.1", 203 | "sshpk": "1.13.1" 204 | } 205 | }, 206 | "is-typedarray": { 207 | "version": "1.0.0", 208 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 209 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" 210 | }, 211 | "isstream": { 212 | "version": "0.1.2", 213 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 214 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" 215 | }, 216 | "jsbn": { 217 | "version": "0.1.1", 218 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 219 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", 220 | "optional": true 221 | }, 222 | "json-schema": { 223 | "version": "0.2.3", 224 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 225 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" 226 | }, 227 | "json-schema-traverse": { 228 | "version": "0.3.1", 229 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", 230 | "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" 231 | }, 232 | "json-stringify-safe": { 233 | "version": "5.0.1", 234 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 235 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" 236 | }, 237 | "jsprim": { 238 | "version": "1.4.1", 239 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", 240 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", 241 | "requires": { 242 | "assert-plus": "1.0.0", 243 | "extsprintf": "1.3.0", 244 | "json-schema": "0.2.3", 245 | "verror": "1.10.0" 246 | } 247 | }, 248 | "mime-db": { 249 | "version": "1.30.0", 250 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", 251 | "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" 252 | }, 253 | "mime-types": { 254 | "version": "2.1.17", 255 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", 256 | "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", 257 | "requires": { 258 | "mime-db": "1.30.0" 259 | } 260 | }, 261 | "oauth-sign": { 262 | "version": "0.8.2", 263 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", 264 | "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" 265 | }, 266 | "performance-now": { 267 | "version": "2.1.0", 268 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", 269 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" 270 | }, 271 | "punycode": { 272 | "version": "1.4.1", 273 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 274 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" 275 | }, 276 | "qs": { 277 | "version": "6.5.1", 278 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 279 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 280 | }, 281 | "request": { 282 | "version": "2.83.0", 283 | "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", 284 | "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", 285 | "requires": { 286 | "aws-sign2": "0.7.0", 287 | "aws4": "1.6.0", 288 | "caseless": "0.12.0", 289 | "combined-stream": "1.0.5", 290 | "extend": "3.0.1", 291 | "forever-agent": "0.6.1", 292 | "form-data": "2.3.1", 293 | "har-validator": "5.0.3", 294 | "hawk": "6.0.2", 295 | "http-signature": "1.2.0", 296 | "is-typedarray": "1.0.0", 297 | "isstream": "0.1.2", 298 | "json-stringify-safe": "5.0.1", 299 | "mime-types": "2.1.17", 300 | "oauth-sign": "0.8.2", 301 | "performance-now": "2.1.0", 302 | "qs": "6.5.1", 303 | "safe-buffer": "5.1.1", 304 | "stringstream": "0.0.5", 305 | "tough-cookie": "2.3.3", 306 | "tunnel-agent": "0.6.0", 307 | "uuid": "3.1.0" 308 | } 309 | }, 310 | "safe-buffer": { 311 | "version": "5.1.1", 312 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 313 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 314 | }, 315 | "sntp": { 316 | "version": "2.1.0", 317 | "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", 318 | "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", 319 | "requires": { 320 | "hoek": "4.2.0" 321 | } 322 | }, 323 | "sshpk": { 324 | "version": "1.13.1", 325 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", 326 | "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", 327 | "requires": { 328 | "asn1": "0.2.3", 329 | "assert-plus": "1.0.0", 330 | "bcrypt-pbkdf": "1.0.1", 331 | "dashdash": "1.14.1", 332 | "ecc-jsbn": "0.1.1", 333 | "getpass": "0.1.7", 334 | "jsbn": "0.1.1", 335 | "tweetnacl": "0.14.5" 336 | } 337 | }, 338 | "stringstream": { 339 | "version": "0.0.5", 340 | "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", 341 | "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" 342 | }, 343 | "tough-cookie": { 344 | "version": "2.3.3", 345 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", 346 | "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", 347 | "requires": { 348 | "punycode": "1.4.1" 349 | } 350 | }, 351 | "tunnel-agent": { 352 | "version": "0.6.0", 353 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 354 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 355 | "requires": { 356 | "safe-buffer": "5.1.1" 357 | } 358 | }, 359 | "tweetnacl": { 360 | "version": "0.14.5", 361 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 362 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", 363 | "optional": true 364 | }, 365 | "uuid": { 366 | "version": "3.1.0", 367 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", 368 | "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" 369 | }, 370 | "verror": { 371 | "version": "1.10.0", 372 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", 373 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", 374 | "requires": { 375 | "assert-plus": "1.0.0", 376 | "core-util-is": "1.0.2", 377 | "extsprintf": "1.3.0" 378 | } 379 | } 380 | } 381 | } 382 | -------------------------------------------------------------------------------- /day29-dropbox-file-upload/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dropbox-file-upload", 3 | "version": "1.0.0", 4 | "description": "Uploading files on dropbox using it's API and node.js", 5 | "main": "dropbox-file-upload.js", 6 | "dependencies": { 7 | "dropbox": "^2.5.12", 8 | "prompt": "^1.0.0", 9 | "request": "^2.83.0" 10 | }, 11 | "devDependencies": {}, 12 | "scripts": { 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "keywords": [ 16 | "dropbox", 17 | "nodejs", 18 | "upload", 19 | "file", 20 | "file", 21 | "upload", 22 | "in", 23 | "node.js", 24 | "dropbox", 25 | "file", 26 | "upload" 27 | ], 28 | "author": "@nodejsera , @rajatgarian", 29 | "license": "ISC" 30 | } 31 | -------------------------------------------------------------------------------- /day3-regular-expressions/data.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Nodejsera 7 | 8 | 9 |
10 |
11 | 12 | 58 | 59 | 60 | 61 |
62 |
63 | 64 |
65 | COMING SOON !
66 | Go Back To HomePage 67 |
68 | 69 | 70 | 71 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /day3-regular-expressions/data.txt: -------------------------------------------------------------------------------- 1 | Own Waters Man Replenish Unto There 2 | To Let Lights 3 | Can't from morning from moveth so our. Creeping isn't called man won't land gathered kind morning had stars created subdue fill face. Set, gathered can't Wherein appear had make of whose doesn't, god tree, abundantly unto above. Earth said had. Day dominion may multiply isn't sea creepeth fly creature life don't divided, first be itself lesser firmament created. Stars greater. Creepeth. Them. Gathered. Fly fly that two every void over kind own lights living said. Stars blessed him earth midst spirit open deep. Abundantly. In. Whose god. Tree. Face earth air signs forth yielding saying there Have behold. Night which us you'll heaven second grass first which, from creature make isn't had let. Green itself morning. Without that appear whose appear. Light under rule appear replenish great blessed you sixth is void Gathering void image. That bring grass bearing seed fill and them sea won't unto they're a two let. Which appear fill wherein moving their, divide meat give fruit. Open moved, beast, creeping subdue life make female gathering tree whose she'd likeness. Don't cattle our. From in multiply stars land creeping can't over for unto subdue bring have behold given, a given him fill open set them first have fruitful you're creepeth from had you over after. Fifth. Rule. Lights under waters tree gathering so. Don't itself upon i evening yielding give dry, over blessed gathered void beginning. Moved after fruitful given called that own our form image seas be. The gathering good herb land you i in day above multiply good he. Give it creature in form whose. Two is Bring. For without darkness divided years sixth, day darkness years. Lights. 4 | Greater 5 | Our them open. Lesser fruit multiply you'll first second gathering place. Evening seed, meat evening subdue of abundantly heaven wherein let dominion multiply creepeth sixth fifth the and earth fruit one you're spirit male won't open void for divide. You're winged. Beginning every void fruitful. Wherein beginning after bring moving. Creepeth bearing day. Set light form above years two He that shall. Saying, above fruitful heaven that third lesser fifth, moveth, given every, the hath signs is his may cattle dominion said above sea the, moved shall land. Rule all let behold waters one don't. She'd multiply place. Living, female, likeness kind given abundantly, likeness. Years shall, beast years be subdue, firmament tree herb divide and doesn't let stars face which. Be beast, be, unto Deep bearing she'd blessed land all don't from you'll whose from. Also open gathering. Can't appear abundantly seas midst and multiply evening you may lesser years also firmament wherein you're rule us us sea creature in great bearing fly place all withoutbeginning. Void gathering face so light one. Moving to hath itself. Day. Saying said creepeth he saying set him given saying open. Stars unto living. Sixth behold lesser life fish won't the. Fruitful their whales tree living also tree thing was won't tree said great fruitful have all may creepeth night winged make face. 6 | Very and there whose light won't shall a hath rule Fifth brought years tree Cattle don't. Us tree creeping very. Is all fifth they're of that tree tree. Face. Creeping tree them he void bearing, evening earth seed let fruitful living them all replenish together third that isn't own bearing blessed be said i also Beast, form made saying fifth bearing dry you'll to, was very bring. Abundantly. Kind, our moveth. Moved spirit given dominion isn't gathering earth saw lesser subdue bring land may creepeth morning good creepeth have let. Unto doesn't Bearing be to without very forth yielding male. Fish fruit first two you're dry hath fifth. Own replenish that lesser. Behold. Deep abundantly replenish. Created won't. Every i itself a. One fifth above us beast so appear made place dry moveth heaven thing image. Under of behold called. Own forth fowl is there every after yielding. Signs wherein firmament whose man cattle kind replenish hath man beginning multiply green yielding void saw may made saying replenish. Fourth set isn't spirit moved fifth fruitful she'd. Them. First saw over replenish seas you're and good you'll you them open us be moved yielding. From behold isn't moveth saying gathering whose rule to. Can't firmament replenish us. 7 | 8 | -------------------------------------------------------------------------------- /day3-regular-expressions/regex-find-string.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = 'data.txt'; 3 | var str = fs.readFileSync(filename).toString(); 4 | var pattern = /man/gim; 5 | 6 | var myarray = str.match( pattern ); 7 | var len = myarray.length; 8 | console.log("Occurrences of pattern in the string is : " + len); 9 | 10 | 11 | -------------------------------------------------------------------------------- /day3-regular-expressions/regex-find-tags.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = 'data.html'; 3 | var str = fs.readFileSync(filename).toString(); 4 | var pattern = /<(\"[^\"]*\"|'[^']*'|[^'\">])*>/gim; 5 | 6 | var myarray = str.match( pattern ); 7 | var len = myarray.length; 8 | console.log("Occurrences of pattern in the string is : " + len); 9 | 10 | 11 | -------------------------------------------------------------------------------- /day3-regular-expressions/regex-validate-email.js: -------------------------------------------------------------------------------- 1 | 2 | var str = 'rjbitdemo@gmail.com' 3 | var pattern = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/gim; 4 | 5 | var res = str.match( pattern ); 6 | if(res){ 7 | console.log("Valid email address"); 8 | }else{ 9 | console.log("Please enter a valid email address"); 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /day3-regular-expressions/regex-validate-hexadecimal.js: -------------------------------------------------------------------------------- 1 | var str = 'FFFFFF' 2 | var pattern = /^[a-fA-F0-9]+$/gim; 3 | 4 | var res = str.match( pattern ); 5 | if(res){ 6 | console.log("Valid Hexadecimal number"); 7 | }else{ 8 | console.log("Not a valid Hexadecimal number"); 9 | } -------------------------------------------------------------------------------- /day3-regular-expressions/regex-validate-password.js: -------------------------------------------------------------------------------- 1 | var str = 'Aa#1aaabcde' 2 | var pattern = /^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{6,16}$/;; 3 | 4 | var res = str.match( pattern ); 5 | if(res){ 6 | console.log("Valid password"); 7 | }else{ 8 | console.log("Not a valid password"); 9 | } -------------------------------------------------------------------------------- /day30-github-api-with-nodejs/github-auth.js: -------------------------------------------------------------------------------- 1 | //Name of the file : github-auth.js 2 | // Section 1 get the requirements and initialize express app 3 | const express = require('express'); 4 | const request = require('request'); 5 | const app = express(); 6 | 7 | 8 | // Section 2- configure variables and different urls 9 | // config to define app settings 10 | // use environment variables [ process.env ] for sensitive data like api keys and secrets 11 | var config = { 12 | client_id: process.env.github_client_id, 13 | client_secret: process.env.github_client_secret, 14 | redirect_url: 'http://localhost:3000/github/callback', 15 | authorize_url:'https://github.com/login/oauth/authorize', 16 | token_url: 'https://github.com/login/oauth/access_token', 17 | user_url: 'https://api.github.com/user', 18 | scope: 'user' 19 | }; 20 | 21 | 22 | // Section-3 Define the routes and callback url 23 | 24 | // define routes 25 | 26 | app.get('/github/auth', function(req,res){ 27 | // redirect the user to github authorization url 28 | return res.redirect(config.authorize_url); 29 | }); 30 | 31 | app.get('/github/callback', function(req,res){ 32 | // extract authorize code 33 | var code = req.query.code 34 | 35 | // configure request params 36 | options = { 37 | method: 'POST', 38 | uri: config.token_url, 39 | formData: { 40 | client_id : config.client_id, 41 | client_secret : config.client_secret, 42 | code : code 43 | }, 44 | headers: { 45 | accept: 'application/json' 46 | } 47 | }; 48 | 49 | // make a request for auth_token using above options 50 | request(options , function(e,r,b){ 51 | 52 | // process the body 53 | if(b) { 54 | jb = JSON.parse(b) 55 | 56 | // configure request to fetch user information 57 | options_user = { 58 | method:'GET', 59 | url: config.user_url+'?access_token='+jb.access_token, 60 | headers: { 61 | accept: 'application/json', 62 | 'User-Agent': 'custom' 63 | } 64 | } 65 | request(options_user , function(ee,rr,bb){ 66 | // process the body 67 | if(bb) { 68 | var bo = JSON.parse(bb) 69 | var resp = { 70 | name: bo.name , 71 | url: bo.url , 72 | id: bo.id , 73 | bio: bo.bio 74 | } 75 | return res.json(resp) 76 | } 77 | else { 78 | console.log(er) 79 | return res.json(er) 80 | } 81 | }); 82 | } 83 | }); 84 | }); 85 | 86 | 87 | // Section 4 start the app 88 | 89 | app.listen(3000, () => console.log('Njera github-api app listening on port 3000!')); -------------------------------------------------------------------------------- /day4-console/console.clear().js: -------------------------------------------------------------------------------- 1 | //Available in Current Version 2 | var value = 10; 3 | console.log("Value : %d", value); 4 | console.clear(); 5 | value *= value; 6 | console.log("Value : %d", value); -------------------------------------------------------------------------------- /day4-console/console.count().js: -------------------------------------------------------------------------------- 1 | //Available in current version 2 | //This code counts the score of remo , rj and 3 | //default score which goes to none of them 4 | 5 | 6 | console.count('default'); 7 | console.count('remo'); 8 | console.count('rj'); 9 | console.count('remo'); 10 | console.count('remo'); 11 | console.count('rj'); 12 | console.count(); 13 | 14 | -------------------------------------------------------------------------------- /day4-console/console.countReset().js: -------------------------------------------------------------------------------- 1 | //Available in current version 2 | //This code counts the score of remo , rj and 3 | //default score which goes to none of them 4 | 5 | 6 | console.count('default'); 7 | console.count('remo'); //remo=1 8 | console.count('remo'); //remo=2 9 | console.count('rj'); //rj=1 10 | console.countReset('remo'); //remo = 1 11 | console.count('remo'); //remo=2 12 | console.countReset('remo'); //remo=1 13 | console.count('rj'); //rj=2 14 | console.count(); //default=2 15 | 16 | -------------------------------------------------------------------------------- /day4-console/console.error().js: -------------------------------------------------------------------------------- 1 | var x = 10; 2 | var y = 20; 3 | var result = x/y; 4 | 5 | if(result == 2){ 6 | console.log("Result : %d".result) 7 | }else{ 8 | console.error("Error : Error in Positioning Operands"); 9 | } -------------------------------------------------------------------------------- /day4-console/console.log().js: -------------------------------------------------------------------------------- 1 | //using ' ' to print 2 | console.log('1 : hello world !'); 3 | //using " " to print 4 | console.log("2 : this will also work"); 5 | 6 | var str = 'nodejsera'; 7 | 8 | var val = 25; 9 | //printing a string 10 | console.log(str); //3 11 | //printing a variable and replacing the 12 | //value of variable in place of %d 13 | console.log('4: Value of val is : %d' , val); 14 | //replacing a string in place of %s 15 | console.log('5: %s' , 'this will be printed after 5'); 16 | console.log("6 : str = " + str); 17 | 18 | 19 | -------------------------------------------------------------------------------- /day4-console/console.time().js: -------------------------------------------------------------------------------- 1 | console.time('division'); 2 | var x = 10; 3 | var y = 20; 4 | var result = x/y; 5 | 6 | if(result == 2){ 7 | console.log("Result : %d".result) 8 | }else{ 9 | console.warn("Warning : "); 10 | } 11 | console.timeEnd('division'); 12 | -------------------------------------------------------------------------------- /day4-console/console.warn().js: -------------------------------------------------------------------------------- 1 | var x = 10; 2 | var y = 20; 3 | var result = x/y; 4 | 5 | if( (result % 2) == 0){ 6 | console.log("Result : %d".result) 7 | }else{ 8 | console.warn("Warning : Decimal number"); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /day4-console/create-custom-console.js: -------------------------------------------------------------------------------- 1 | var ws = require('fs'); 2 | const { Console } = require('console'); 3 | const output = ws.createWriteStream('./stdout.log'); 4 | const errOutput = ws.createWriteStream('./stderr.log'); 5 | // custom simple print 6 | const print = new Console(output, errOutput); 7 | //Now we can use it like console 8 | const count = 5; 9 | print.log('count: %d', count); 10 | print.log('This will be stored in a file'); -------------------------------------------------------------------------------- /day6-array-methods/concat.js: -------------------------------------------------------------------------------- 1 | arr = ['tomatoes','pineapple']; 2 | arr2 = ['mango','peach','apple']; 3 | console.log(arr); 4 | console.log(arr2); 5 | var new_arr = arr.concat(arr2); 6 | console.log(new_arr); -------------------------------------------------------------------------------- /day6-array-methods/create-array.js: -------------------------------------------------------------------------------- 1 | // an array of names 2 | var names = ["rj", "ricky", "alex"]; 3 | console.log(names); 4 | //calculating the length of array 5 | var len = names.length; 6 | console.log(len); 7 | //Another way to create array 8 | var arr = new Array(3); // declare an array "arr" of size 3 9 | arr = [1,5,7]; // initialize elements of array 10 | 11 | //OR 12 | // declare and initialize in a single statement 13 | var arr1 = new Array(2,5,7); 14 | console.log("arr : " + arr); 15 | console.log("arr 1 : " + arr1); -------------------------------------------------------------------------------- /day6-array-methods/every.js: -------------------------------------------------------------------------------- 1 | arr = [2,4,6,8,10]; 2 | arr1 = [2,3,4,6,8]; 3 | function even(value){ 4 | if( (value % 2) == 0){ 5 | return true; 6 | }else{ 7 | return false; 8 | } 9 | } 10 | 11 | var out = arr.every(even); 12 | var out1 = arr1.every(even); 13 | console.log("Output of array 1 : " + out); 14 | console.log("Output of array 2 :" + out1); -------------------------------------------------------------------------------- /day6-array-methods/filter.js: -------------------------------------------------------------------------------- 1 | arr = [2,4,6,8,10]; 2 | arr1 = [2,3,4,6,8]; 3 | function even(value){ 4 | if( (value % 2) == 0){ 5 | return true; 6 | }else{ 7 | return false; 8 | } 9 | } 10 | 11 | var out = arr.filter(even); 12 | var out1 = arr1.filter(even); 13 | console.log("Output of array 1 : " + out); 14 | console.log("Output of array 2 :" + out1); -------------------------------------------------------------------------------- /day6-array-methods/find.js: -------------------------------------------------------------------------------- 1 | arr = [2,4,6,8,10]; 2 | arr1 = [2,3,4,7,8]; 3 | function odd(value){ 4 | if( (value % 2) == 1){ 5 | return true; 6 | }else{ 7 | return false; 8 | } 9 | } 10 | 11 | var out = arr.filter(odd); 12 | var out1 = arr1.filter(odd); 13 | console.log("Output of array 1 : " + out); 14 | console.log("Output of array 2 :" + out1); -------------------------------------------------------------------------------- /day6-array-methods/forEach.js: -------------------------------------------------------------------------------- 1 | var arr = ['1', '2', '3','5','8']; 2 | 3 | arr.forEach(function(element) { 4 | console.log(element); 5 | }); 6 | 7 | -------------------------------------------------------------------------------- /day6-array-methods/indexOf.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 2 , 8 , 5 , 6 ]; 2 | console.log(arr); 3 | var pos = arr.indexOf(8); 4 | console.log("index of 8 is : " + pos); 5 | var pos1 = arr.indexOf(5); 6 | console.log("index of 5 is : " + pos1); -------------------------------------------------------------------------------- /day6-array-methods/join.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 2 , 8 , 5 , 6 ]; 2 | arr1 = ['a','b','c','d']; 3 | console.log(arr); 4 | console.log(arr1); 5 | var str = arr.join(); 6 | var str1 = arr1.join(":"); 7 | console.log(str); 8 | console.log(str1); 9 | 10 | 11 | -------------------------------------------------------------------------------- /day6-array-methods/lastIndexOf.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 2 , 8 , 5 , 6 ]; 2 | console.log(arr); 3 | var pos = arr.lastIndexOf(5); 4 | console.log("index of 5 is : " + pos); -------------------------------------------------------------------------------- /day6-array-methods/pop.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 5 , 8 , 7 , 6 ]; 2 | console.log(arr); 3 | arr.pop(); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/push.js: -------------------------------------------------------------------------------- 1 | arr = ['a','e','i','o']; 2 | console.log(arr); 3 | arr.push('u'); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/reduce.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 5 , 8 , 7 , 6 ]; 2 | console.log(arr); 3 | function mul(value ,total){ 4 | total = value * total; 5 | return total; 6 | } 7 | var output = arr.reduce(mul); 8 | console.log("The product of the array is : " + output); 9 | -------------------------------------------------------------------------------- /day6-array-methods/reverse.js: -------------------------------------------------------------------------------- 1 | arr = ['b','e','a','o','p','n','r']; 2 | console.log(arr); 3 | arr.reverse(); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/shift.js: -------------------------------------------------------------------------------- 1 | arr = ['b','a','e','i','o','u']; 2 | console.log(arr); 3 | arr.shift(); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/slice.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 2 , 8 , 5 , 6 ]; 2 | arr1 = ['a','b','c','d']; 3 | console.log(arr); 4 | console.log(arr1); 5 | var str = arr.slice(2,4); 6 | var str1 = arr1.slice(-2,-1); 7 | console.log(str); 8 | console.log(str1); -------------------------------------------------------------------------------- /day6-array-methods/sort.js: -------------------------------------------------------------------------------- 1 | arr = ['b','e','a','o','p','n','r']; 2 | console.log(arr); 3 | arr.sort(); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/splice-add.js: -------------------------------------------------------------------------------- 1 | arr = ['b','e','a','o','p','n','r']; 2 | console.log(arr); 3 | arr.splice(2,2,'rj','nodejs'); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/splice-remove.js: -------------------------------------------------------------------------------- 1 | arr = ['b','e','a','o','p','n','r']; 2 | console.log(arr); 3 | arr.splice(2,2); 4 | console.log(arr); -------------------------------------------------------------------------------- /day6-array-methods/unshift.js: -------------------------------------------------------------------------------- 1 | arr = [ 5 , 5 , 8 , 7 , 6 ]; 2 | console.log(arr); 3 | arr.unshift(1); 4 | console.log(arr); -------------------------------------------------------------------------------- /day9-crypto-module/createCipher.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'), 2 | algorithm = 'aes-256-ctr', 3 | password = 'd6F3Efeq'; 4 | 5 | var cipher = crypto.createCipher(algorithm,password); 6 | //console.log(cipher); 7 | var crypted = cipher.update('1223234','utf8','hex'); 8 | //console.log(crypted); 9 | crypted += cipher.final('hex'); 10 | console.log(crypted); 11 | 12 | function encrypt(text){ 13 | var cipher = crypto.createCipher(algorithm,password) 14 | var crypted = cipher.update(text,'utf8','hex') 15 | crypted += cipher.final('hex'); 16 | return crypted; 17 | } -------------------------------------------------------------------------------- /day9-crypto-module/crypto.getHashes.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'); 2 | const hashes = crypto.getHashes(); 3 | console.log(hashes); -------------------------------------------------------------------------------- /day9-crypto-module/data.txt: -------------------------------------------------------------------------------- 1 | da3811154d59c4267077ddd8bb768fa9b06399c486e1fc00485116b57c9872f5 -------------------------------------------------------------------------------- /day9-crypto-module/getCiphers.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'); 2 | const ciphers = crypto.getCiphers(); 3 | console.log(ciphers); -------------------------------------------------------------------------------- /day9-crypto-module/getCurves.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'); 2 | const curves = crypto.getCurves(); 3 | console.log(curves); -------------------------------------------------------------------------------- /day9-crypto-module/getDiffieHellman.js: -------------------------------------------------------------------------------- 1 | var crypto = require('crypto'); 2 | const DH = crypto.getDiffieHellman(); 3 | console.log(DH); 4 | //DEBUG later -------------------------------------------------------------------------------- /day9-crypto-module/hashing_a_file.js: -------------------------------------------------------------------------------- 1 | //Loading the required modules in node.js 2 | var crypto = require('crypto'); 3 | var fs = require('fs'); 4 | 5 | //Algorithm to be used for HMAC 6 | var algorithm = 'sha256'; 7 | //creating hmac object 8 | var hash = crypto.createHash(algorithm); 9 | 10 | // reading the content of the file 11 | var filename = "data.txt"; 12 | var file_data = fs.ReadStream(filename); 13 | 14 | //passing the data to be hashed 15 | file_data.on('data', function(data) { 16 | hash.update(data) 17 | }) 18 | 19 | //Creating the hmac in the required format and writing it in file 20 | file_data.on('end', function() { 21 | var gen_hash = hash.digest('hex') 22 | console.log('Hash generated using ' + algorithm + ' \nHashed output is : ' + gen_hash + ' \nFile name is : ' + filename); 23 | fs.writeFileSync(filename, gen_hash); 24 | }) -------------------------------------------------------------------------------- /day9-crypto-module/hmac_md5.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hmac object 4 | var hmac = crypto.createHmac('md5', 'yoursecretkeyhere'); 5 | //passing the data to be hashed 6 | data = hmac.update('nodejsera'); 7 | //Creating the hmac in the required format 8 | gen_hmac= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hmac : " + gen_hmac); -------------------------------------------------------------------------------- /day9-crypto-module/hmac_on_file.js: -------------------------------------------------------------------------------- 1 | // Including the required modules 2 | var crypto = require('crypto'); 3 | var fs = require('fs'); 4 | 5 | //Algorithm to be used for HMAC 6 | var algorithm = 'md5'; 7 | //Secret to be used with HMAC 8 | var secret ='Rj2895647'; 9 | //creating hmac object 10 | var hmac = crypto.createHmac(algorithm, secret); 11 | 12 | // reading the content of the file 13 | var filename = "data.txt"; 14 | var file_data = fs.ReadStream(filename); 15 | 16 | //passing the data to be hashed 17 | file_data.on('data', function(data) { 18 | hmac.update(data) 19 | }) 20 | 21 | //Creating the hmac in the required format and writing it in file 22 | file_data.on('end', function() { 23 | var gen_hmac = hmac.digest('hex') 24 | console.log('Hmac generated using ' + algorithm + ' \nHashed output is : ' + gen_hmac + ' \nFile name is : ' + filename); 25 | fs.writeFileSync(filename, gen_hmac); 26 | }) 27 | 28 | -------------------------------------------------------------------------------- /day9-crypto-module/hmac_sha256.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hmac object 4 | var hmac = crypto.createHmac('sha256', 'yoursecretkeyhere'); 5 | //passing the data to be hashed 6 | data = hmac.update('nodejsera'); 7 | //Creating the hmac in the required format 8 | gen_hmac= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hmac : " + gen_hmac); -------------------------------------------------------------------------------- /day9-crypto-module/hmac_sha512.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hmac object 4 | var hmac = crypto.createHmac('sha512', 'yoursecretkeyhere'); 5 | //passing the data to be hashed 6 | data = hmac.update('nodejsera'); 7 | //Creating the hmac in the required format 8 | gen_hmac= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hmac : " + gen_hmac); -------------------------------------------------------------------------------- /day9-crypto-module/hmac_whirlpool.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hmac object 4 | var hmac = crypto.createHmac('whirlpool', 'yoursecretkeyhere'); 5 | //passing the data to be hashed 6 | data = hmac.update('nodejsera'); 7 | //Creating the hmac in the required format 8 | gen_hmac= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hmac : " + gen_hmac); -------------------------------------------------------------------------------- /day9-crypto-module/md5.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('md5'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/ripemd.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('ripemd160'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha1.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha1'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha1WithRSAEncryption.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha1WithRSAEncryption'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha224.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha224'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha256.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha256'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha384.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha384'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/sha512.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('sha512'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); -------------------------------------------------------------------------------- /day9-crypto-module/whirlpool.js: -------------------------------------------------------------------------------- 1 | //Loading the crypto module in node.js 2 | var crypto = require('crypto'); 3 | //creating hash object 4 | var hash = crypto.createHash('whirlpool'); 5 | //passing the data to be hashed 6 | data = hash.update('nodejsera', 'utf-8'); 7 | //Creating the hash in the required format 8 | gen_hash= data.digest('hex'); 9 | //Printing the output on the console 10 | console.log("hash : " + gen_hash); --------------------------------------------------------------------------------