From 086bf453bf9728c9fd0c5e5d56d52ce025718c84 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 10:53:03 -0400 Subject: [PATCH 01/32] setting up project --- .gitignore | 2 + index.js | 124 ++++ models/index.js | 0 models/user.js | 20 + package-lock.json | 1767 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 + 6 files changed, 1948 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 models/index.js create mode 100644 models/user.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fb7b616 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +.env \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..da1de39 --- /dev/null +++ b/index.js @@ -0,0 +1,124 @@ +const express = require("express"); +const path = require("path"); +const logger = require("morgan"); +const bodyParser = require("body-parser"); +const exphbs = require("express-handlebars"); +const session = require("express-session"); +const passport = require("passport"); + +// const { User } = require("./models"); +// const FacebookStrategy = require("passport-facebook"); +// const LocalStrategy = require('passport-local').Strategy + +// const { facebookTools, linkedinTools } = require("./auth"); + +const app = express(); +if (process.env.NODE_ENV !== "production") { + require("dotenv").config(); +} + +const mongoose = require("mongoose"); +const Promise = require("bluebird"); + +// express session +app.use( + session({ + secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", + resave: false, + saveUninitialized: true, + cookie: { + maxAge: 24 * 60 * 60 + } + }) +); + +// bluebird mongoose +mongoose.Promise = Promise; + +// connect to mongoose +const beginConnection = mongoose.connect(process.env.DB_URL, { + useMongoClient: true +}); + +beginConnection + .then(db => { + console.log("DB CONNECTION SUCCESS"); + }) + .catch(err => { + console.error(err); + }); + +// handlebars view +app.set("views", path.join(__dirname, "views")); + +// hbs +app.engine("handlebars", exphbs({ defaultLayout: "main" })); +app.set("view engine", "handlebars"); + +// middleware +app.use(logger("dev")); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ extended: true })); +app.use(express.static(path.join(__dirname, "public"))); + +// +app.use(passport.initialize()); +app.use(passport.session()); + +// facebookTools.utilizePassport(passport, User); +// linkedinTools.utilizePassport(passport, User); + +// passport.serializeUser(function(user, done) { +// done(null, user.id); +// }); + +// passport.deserializeUser(function(id, done) { +// User.findById(id, function(err, user) { +// done(err, user); +// }); +// }); + +// routes +// app.use("/", require("./routes/index")); +// app.use("/landing", require("./routes/landing")); + +// Facebook Routes +// app.get( +// "/auth/facebook", +// passport.authenticate("facebook", { +// authType: "rerequest", +// scope: ["public_profile"] +// }) +// ); + +// app.get( +// "/auth/facebook/callback", +// passport.authenticate("facebook", { failureRedirect: "/login" }), +// function(req, res) { +// // Successful authentication, redirect home. +// res.redirect("/landing"); // test +// } +// ); + +// Linkedin routes +// app.get( +// "/auth/linkedin", +// passport.authenticate("linkedin", { +// authType: "rerequest", +// scope: ['r_basicprofile', 'r_emailaddress'] +// }) +// ); + +// app.get( +// "/auth/linkedin/callback", +// passport.authenticate("linkedin", { failureRedirect: "/login" }), +// function(req, res) { +// // Successful authentication, redirect home. +// res.redirect("/landing"); // test +// } +// ); + +// listen to server +app.listen(3000, () => { + console.log(`Listening at port 3000`); +}); diff --git a/models/index.js b/models/index.js new file mode 100644 index 0000000..e69de29 diff --git a/models/user.js b/models/user.js new file mode 100644 index 0000000..04c9348 --- /dev/null +++ b/models/user.js @@ -0,0 +1,20 @@ +const mongoose = require("mongoose"); +const bcrypt = require("bcrypt"); +const Schema = mongoose.Schema; + +// email, firstname, lastname, ids for each service + +// more id's per service +const UserSchema = mongoose.Schema({ + username: { type: String, required: true, unique: true }, + password: { type: String, required: true }, + fname: { type: String, required: true }, + lname: { type: String, required: true }, + shortid: { type: String, required: true, unique: true }, + timestamp: { type: Date, default: Date.now }, + parent: { type: Schema.Types.ObjectId, ref: "User", default: null }, + children: [{ type: Schema.Types.ObjectId, ref: "User" }], + points: { type: Number, default: 0 } +}); + +module.exports = mongoose.model("User", UserSchema); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..adfab6c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1767 @@ +{ + "name": "project_ponz", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", + "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=" + }, + "accepts": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", + "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", + "requires": { + "mime-types": "2.1.16", + "negotiator": "0.6.1" + } + }, + "ajv": { + "version": "4.11.8", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "aproba": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.2.tgz", + "integrity": "sha512-ZpYajIfO0j2cOFTO955KUMIKNmj6zhX8kVztMAxFsDaMwz+9Z9SV0uou2pC9HJqcfpffOsjnbrDMvkNy+9RXPw==" + }, + "are-we-there-yet": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", + "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.3" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" + }, + "assert-plus": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=" + }, + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "aws-sign2": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=" + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "basic-auth": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.1.0.tgz", + "integrity": "sha1-RSIe5Cn37h5QNb4/UVM/HN/SmIQ=" + }, + "bcrypt": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-1.0.2.tgz", + "integrity": "sha1-0F/F0iMXPg4o7DgcDwDMJf+vJzY=", + "requires": { + "bindings": "1.2.1", + "nan": "2.5.0", + "node-pre-gyp": "0.6.32" + } + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "bindings": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", + "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" + }, + "block-stream": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", + "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", + "requires": { + "inherits": "2.0.3" + } + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=" + }, + "body-parser": { + "version": "1.17.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.17.2.tgz", + "integrity": "sha1-+IkqvI+eYn1Crtr7yma/WrmRBO4=", + "requires": { + "bytes": "2.4.0", + "content-type": "1.0.2", + "debug": "2.6.7", + "depd": "1.1.1", + "http-errors": "1.6.2", + "iconv-lite": "0.4.15", + "on-finished": "2.3.0", + "qs": "6.4.0", + "raw-body": "2.2.0", + "type-is": "1.6.15" + }, + "dependencies": { + "debug": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz", + "integrity": "sha1-krrR9tBbu2u6Isyoi80OyJTChh4=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "boom": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "bson": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz", + "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw=" + }, + "buffer-shims": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", + "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" + }, + "bytes": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", + "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=" + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "optional": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "optional": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "optional": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "optional": true + } + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", + "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "crc": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", + "integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=" + }, + "cryptiles": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "requires": { + "ms": "0.7.1" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "optional": true + }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=" + }, + "define-properties": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", + "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", + "requires": { + "foreach": "2.0.5", + "object-keys": "1.0.11" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" + }, + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "dotenv": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", + "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", + "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" + }, + "es6-promise": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", + "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.0.tgz", + "integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE=" + }, + "express": { + "version": "4.15.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.15.4.tgz", + "integrity": "sha1-Ay4iU0ic+PzgJma+yj0R7XotrtE=", + "requires": { + "accepts": "1.3.3", + "array-flatten": "1.1.1", + "content-disposition": "0.5.2", + "content-type": "1.0.2", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.8", + "depd": "1.1.1", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.0", + "finalhandler": "1.0.4", + "fresh": "0.5.0", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.1", + "path-to-regexp": "0.1.7", + "proxy-addr": "1.1.5", + "qs": "6.5.0", + "range-parser": "1.2.0", + "send": "0.15.4", + "serve-static": "1.12.4", + "setprototypeof": "1.0.3", + "statuses": "1.3.1", + "type-is": "1.6.15", + "utils-merge": "1.0.0", + "vary": "1.1.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "qs": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.0.tgz", + "integrity": "sha512-fjVFjW9yhqMhVGwRExCXLhJKrLlkYSaxNWdyc9rmHlrVZbk35YHH312dFd7191uQeXkI3mKLZTIbSvIeFwFemg==" + } + } + }, + "express-flash-messages": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/express-flash-messages/-/express-flash-messages-0.1.1.tgz", + "integrity": "sha1-QCDOUXjDuzZjlN6QZiILwnBb1vI=" + }, + "express-handlebars": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/express-handlebars/-/express-handlebars-3.0.0.tgz", + "integrity": "sha1-gKBwu4GbCeSvLKbQeA91zgXnXC8=", + "requires": { + "glob": "6.0.4", + "graceful-fs": "4.1.11", + "handlebars": "4.0.10", + "object.assign": "4.0.4", + "promise": "7.3.1" + }, + "dependencies": { + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "express-session": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/express-session/-/express-session-1.15.5.tgz", + "integrity": "sha512-BBVy6E/XqjB507wqe5T+7Ia2N/gtur/dT/fKmvGGKQqUrzI4dcBPGJgV4t2ciX7FoxZPhZcKTDTmb4+5nCyQOw==", + "requires": { + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "crc": "3.4.4", + "debug": "2.6.8", + "depd": "1.1.1", + "on-headers": "1.0.1", + "parseurl": "1.3.1", + "uid-safe": "2.1.5", + "utils-merge": "1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=" + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" + }, + "finalhandler": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.0.4.tgz", + "integrity": "sha512-16l/r8RgzlXKmFOhZpHBztvye+lAhC5SU7hXavnerC9UfZqZxxXl3BzL8MhffPT3kF61lj9Oav2LKEzh0ei7tg==", + "requires": { + "debug": "2.6.8", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.1", + "statuses": "1.3.1", + "unpipe": "1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" + }, + "form-data": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.16" + } + }, + "forwarded": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz", + "integrity": "sha1-Ge+YdMSuHCl7zweP3mOgm2aoQ2M=" + }, + "fresh": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz", + "integrity": "sha1-9HTKXmqSRtb9jglTz6m5yAWvp44=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "fstream": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", + "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.5.4" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", + "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "function-bind": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.0.tgz", + "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=" + }, + "gauge": { + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", + "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", + "requires": { + "aproba": "1.1.2", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "handlebars": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", + "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", + "requires": { + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" + } + }, + "har-schema": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", + "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=" + }, + "har-validator": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=" + }, + "hawk": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=" + }, + "hooks-fixed": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hooks-fixed/-/hooks-fixed-2.0.0.tgz", + "integrity": "sha1-oB2JTVKsf2WZu7H2PfycQR33DLo=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.3.1" + } + }, + "http-signature": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "iconv-lite": { + "version": "0.4.15", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", + "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=" + }, + "ipaddr.js": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.4.0.tgz", + "integrity": "sha1-KWrKh4qCGBbluF0KKFqZvP9FgvA=" + }, + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=" + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "kareem": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-1.5.0.tgz", + "integrity": "sha1-4+QQHZ3P3imXadr0tNtk2JXRdEg=" + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.5" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "optional": true + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", + "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=" + }, + "mime-db": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.29.0.tgz", + "integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg=" + }, + "mime-types": { + "version": "2.1.16", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz", + "integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=", + "requires": { + "mime-db": "1.29.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "requires": { + "minimist": "0.0.8" + } + }, + "mongodb": { + "version": "2.2.31", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.31.tgz", + "integrity": "sha1-GUBEXGYeGSF7s7+CRdmFSq71SNs=", + "requires": { + "es6-promise": "3.2.1", + "mongodb-core": "2.1.15", + "readable-stream": "2.2.7" + }, + "dependencies": { + "readable-stream": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz", + "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=", + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + } + } + }, + "mongodb-core": { + "version": "2.1.15", + "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.15.tgz", + "integrity": "sha1-hB9TuH//9MdFgYnDXIroJ+EWl2Q=", + "requires": { + "bson": "1.0.4", + "require_optional": "1.0.1" + } + }, + "mongoose": { + "version": "4.11.7", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-4.11.7.tgz", + "integrity": "sha512-tRYcThB+qx8yzVdG7rY8mlBUrF5CEJADl4Vlp3MMI9vVpgyFtOJfC2/IZiGmNFNThJjNIESBUxgoFrCRVDcLCw==", + "requires": { + "async": "2.1.4", + "bson": "1.0.4", + "hooks-fixed": "2.0.0", + "kareem": "1.5.0", + "mongodb": "2.2.31", + "mpath": "0.3.0", + "mpromise": "0.5.5", + "mquery": "2.3.1", + "ms": "2.0.0", + "muri": "1.2.2", + "regexp-clone": "0.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "async": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz", + "integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=", + "requires": { + "lodash": "4.17.4" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "morgan": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.8.2.tgz", + "integrity": "sha1-eErHc05KRTqcbm6GgKkyknXItoc=", + "requires": { + "basic-auth": "1.1.0", + "debug": "2.6.8", + "depd": "1.1.1", + "on-finished": "2.3.0", + "on-headers": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "mpath": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.3.0.tgz", + "integrity": "sha1-elj3iem1/TyUUgY0FXlg8mvV70Q=" + }, + "mpromise": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mpromise/-/mpromise-0.5.5.tgz", + "integrity": "sha1-9bJCWddjrMIlewoMjG2Gb9UXMuY=" + }, + "mquery": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-2.3.1.tgz", + "integrity": "sha1-mrNnSXFIAP8LtTpoHOS8TV8HyHs=", + "requires": { + "bluebird": "2.10.2", + "debug": "2.6.8", + "regexp-clone": "0.0.1", + "sliced": "0.0.5" + }, + "dependencies": { + "bluebird": { + "version": "2.10.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz", + "integrity": "sha1-AkpVFylTCIV/FPkfEQb8O1VfRGs=" + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "sliced": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz", + "integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8=" + } + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=" + }, + "muri": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/muri/-/muri-1.2.2.tgz", + "integrity": "sha1-YxmBMmUNsIoEzHnM0A3Tia/SYxw=" + }, + "nan": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.5.0.tgz", + "integrity": "sha1-qo8eNFMdgH6eJ3VbI0tKbsDBUqg=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "node-pre-gyp": { + "version": "0.6.32", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.32.tgz", + "integrity": "sha1-/EUrN25zGbPSVfXzSFPvb9j+H9U=", + "requires": { + "mkdirp": "0.5.1", + "nopt": "3.0.6", + "npmlog": "4.1.2", + "rc": "1.1.7", + "request": "2.81.0", + "rimraf": "2.5.4", + "semver": "5.3.0", + "tar": "2.2.1", + "tar-pack": "3.3.0" + } + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1.1.0" + } + }, + "npmlog": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", + "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "object-keys": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", + "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=" + }, + "object.assign": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.0.4.tgz", + "integrity": "sha1-scnMBE7xuf5jYG/BQau7MuFHMMw=", + "requires": { + "define-properties": "1.1.2", + "function-bind": "1.1.0", + "object-keys": "1.0.11" + } + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "on-headers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", + "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "requires": { + "minimist": "0.0.8", + "wordwrap": "0.0.3" + } + }, + "parseurl": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", + "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=" + }, + "passport": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.4.0.tgz", + "integrity": "sha1-xQlWkTR71a07XhgCOMORTRbwWBE=", + "requires": { + "passport-strategy": "1.0.0", + "pause": "0.0.1" + } + }, + "passport-local": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz", + "integrity": "sha1-H+YyaMkudWBmJkN+O5BmYsFbpu4=", + "requires": { + "passport-strategy": "1.0.0" + } + }, + "passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10=" + }, + "performance-now": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=" + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=" + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "2.0.6" + } + }, + "proxy-addr": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.5.tgz", + "integrity": "sha1-ccDuOxAt4/IC87ZPYI0XP8uhqRg=", + "requires": { + "forwarded": "0.1.0", + "ipaddr.js": "1.4.0" + } + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" + }, + "qs": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=" + }, + "random-bytes": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz", + "integrity": "sha1-T2ih3Arli9P7lYSMMDJNt11kNgs=" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz", + "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=", + "requires": { + "bytes": "2.4.0", + "iconv-lite": "0.4.15", + "unpipe": "1.0.0" + } + }, + "rc": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.1.7.tgz", + "integrity": "sha1-xepWS7B6/5/TpbMukGwdOmWUD+o=", + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "regexp-clone": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", + "integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk=" + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + }, + "request": { + "version": "2.81.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.16", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "require_optional": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", + "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", + "requires": { + "resolve-from": "2.0.0", + "semver": "5.3.0" + } + }, + "resolve-from": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", + "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "optional": true, + "requires": { + "align-text": "0.1.4" + } + }, + "rimraf": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", + "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" + }, + "semver": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=" + }, + "send": { + "version": "0.15.4", + "resolved": "https://registry.npmjs.org/send/-/send-0.15.4.tgz", + "integrity": "sha1-mF+qPihLAnPHkzZKNcZze9k5Bbk=", + "requires": { + "debug": "2.6.8", + "depd": "1.1.1", + "destroy": "1.0.4", + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "etag": "1.8.0", + "fresh": "0.5.0", + "http-errors": "1.6.2", + "mime": "1.3.4", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.3.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "serve-static": { + "version": "1.12.4", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.12.4.tgz", + "integrity": "sha1-m2qpjutyU8Tu3Ewfb9vKYJkBqWE=", + "requires": { + "encodeurl": "1.0.1", + "escape-html": "1.0.3", + "parseurl": "1.3.1", + "send": "0.15.4" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + }, + "shortid": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.8.tgz", + "integrity": "sha1-AzsRfWoul1gE9vCWnb59PQs1UTE=" + }, + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "sntp": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", + "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", + "requires": { + "hoek": "2.16.3" + } + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "requires": { + "amdefine": "1.0.1" + } + }, + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "statuses": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", + "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + }, + "tar": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", + "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.3.0.tgz", + "integrity": "sha1-MJMYFkGPVa/E0hd1r91nIM7kXa4=", + "requires": { + "debug": "2.2.0", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.3.3", + "readable-stream": "2.1.5", + "rimraf": "2.5.4", + "tar": "2.2.1", + "uid-number": "0.0.6" + }, + "dependencies": { + "once": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", + "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", + "requires": { + "wrappy": "1.0.2" + } + }, + "readable-stream": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.1.5.tgz", + "integrity": "sha1-ZvqLcg4UOLNkaB8q0aY8YYRIydA=", + "requires": { + "buffer-shims": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "string_decoder": "0.10.31", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + } + } + }, + "tough-cookie": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "optional": true + }, + "type-is": { + "version": "1.6.15", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", + "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", + "requires": { + "media-typer": "0.3.0", + "mime-types": "2.1.16" + } + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "optional": true, + "requires": { + "source-map": "0.5.6", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "optional": true + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", + "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=" + }, + "uid-safe": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz", + "integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==", + "requires": { + "random-bytes": "1.0.0" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "utils-merge": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", + "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=" + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, + "vary": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", + "integrity": "sha1-Z1Neu2lMHVIldFeYRmUyP1h+jTc=" + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" + } + } + }, + "wide-align": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", + "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", + "requires": { + "string-width": "1.0.2" + } + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "optional": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "optional": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ffacbb4 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "project_ponz", + "version": "1.0.0", + "description": "Building Ponz.io, with its endearingly upside-down-triangle-shaped business model.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/bsoung/project_ponz.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/bsoung/project_ponz/issues" + }, + "homepage": "https://github.com/bsoung/project_ponz#readme", + "dependencies": { + "bcrypt": "^1.0.2", + "bluebird": "^3.5.0", + "body-parser": "^1.17.2", + "dotenv": "^4.0.0", + "express": "^4.15.4", + "express-flash-messages": "^0.1.1", + "express-handlebars": "^3.0.0", + "express-session": "^1.15.5", + "mongoose": "^4.11.7", + "morgan": "^1.8.2", + "passport": "^0.4.0", + "passport-local": "^1.0.0", + "shortid": "^2.2.8" + } +} From 3c07cbc19fd65f27156905af58a375415849a6ce Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 10:19:58 -0500 Subject: [PATCH 02/32] making hbs stuff --- index.js | 40 +++++++++++++++++++++++++++++++++++ models/user.js | 8 +++++++ views/layouts/main.handlebars | 19 +++++++++++++++++ views/submission.hbs | 0 4 files changed, 67 insertions(+) create mode 100644 views/layouts/main.handlebars create mode 100644 views/submission.hbs diff --git a/index.js b/index.js index da1de39..9b4f90e 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,20 @@ const passport = require("passport"); // const { facebookTools, linkedinTools } = require("./auth"); +// bluebird mongoose +mongoose.Promise = Promise; + +// connect to mongoose +const beginConnection = mongoose.connect(process.env.DB_URL, {useMongoClient: true}); + +beginConnection.then(db => { + + console.log("DB CONNECTION SUCCESS"); +}).catch(err => { + console.error(err); +}); + + const app = express(); if (process.env.NODE_ENV !== "production") { require("dotenv").config(); @@ -67,6 +81,32 @@ app.use(passport.session()); // facebookTools.utilizePassport(passport, User); // linkedinTools.utilizePassport(passport, User); +passport.use(new LocalStrategy( + (username, password, done) => { + let user = findUser(username); + if(!user) return done(null, false); + + bcrypt.compareSync(password, user.password, (err, isValid) => { + if(err) return done(err); + if(!isValid) return done(null, false); + return done(null, user); + }) + } +)) + + +async function findUser(username) { + let user; + try { + user = await findOne({ + username: username + }) + } + catch(error) { + console.error(error) + } + return user; +} // passport.serializeUser(function(user, done) { // done(null, user.id); diff --git a/models/user.js b/models/user.js index 04c9348..552af47 100644 --- a/models/user.js +++ b/models/user.js @@ -17,4 +17,12 @@ const UserSchema = mongoose.Schema({ points: { type: Number, default: 0 } }); +UserSchema.pre("save", async (next) => { + let user = this; + let hash = await bcrypt.hashSync(user.password, 12); + user.password = hash; + next(); +}) + + module.exports = mongoose.model("User", UserSchema); diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars new file mode 100644 index 0000000..5ad8da4 --- /dev/null +++ b/views/layouts/main.handlebars @@ -0,0 +1,19 @@ + + + + + + + + + + +
+ + + + diff --git a/views/submission.hbs b/views/submission.hbs new file mode 100644 index 0000000..e69de29 From 0e88214c3bd3a8de6b4206602288fe391f8854ce Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 11:48:13 -0400 Subject: [PATCH 03/32] creating and registering users --- controllers/UserController.js | 81 +++++++++++++++++++++++++ controllers/index.js | 3 + index.js | 104 +++++++++++++++------------------ package.json | 1 + routes/api.js | 54 +++++++++++++++++ routes/index.js | 8 +++ views/landing/index.handlebars | 40 +++++++++++++ 7 files changed, 234 insertions(+), 57 deletions(-) create mode 100644 controllers/UserController.js create mode 100644 controllers/index.js create mode 100644 routes/api.js create mode 100644 routes/index.js create mode 100644 views/landing/index.handlebars diff --git a/controllers/UserController.js b/controllers/UserController.js new file mode 100644 index 0000000..81c4f20 --- /dev/null +++ b/controllers/UserController.js @@ -0,0 +1,81 @@ +const User = require("./../models/sequelize").User; + +module.exports = { + index: async (req, res) => { + try { + const users = await User.findAll({ order: ["id"] }); + + return res.json({ + confirmation: "success", + result: users + }); + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + }, + + view: async (req, res) => { + const id = req.params.id; + + try { + const user = await User.findById(id, { + include: [{ model: Profile }] + }); + + return res.json({ + confirmation: "success", + result: user + }); + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + }, + + createUser: async (req, res) => { + // check if user exists + try { + let existingUser = await User.find({ + where: { + $or: { + username: req.body.username, + email: req.body.email + } + } + }); + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + + if (existingUser) { + return res.json({ + confirmation: "fail", + message: "user already exists" + }); + } + + // if no user, create the user + try { + let user = await User.create(req.body); + + return res.json({ + confirmation: "success", + user: user, + profile: profile + }); + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + } +}; diff --git a/controllers/index.js b/controllers/index.js new file mode 100644 index 0000000..114205b --- /dev/null +++ b/controllers/index.js @@ -0,0 +1,3 @@ +module.exports = { + users: require("./UserController") +}; diff --git a/index.js b/index.js index 9b4f90e..b5ef78e 100644 --- a/index.js +++ b/index.js @@ -6,45 +6,18 @@ const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); -// const { User } = require("./models"); -// const FacebookStrategy = require("passport-facebook"); -// const LocalStrategy = require('passport-local').Strategy - -// const { facebookTools, linkedinTools } = require("./auth"); - -// bluebird mongoose -mongoose.Promise = Promise; - -// connect to mongoose -const beginConnection = mongoose.connect(process.env.DB_URL, {useMongoClient: true}); - -beginConnection.then(db => { - - console.log("DB CONNECTION SUCCESS"); -}).catch(err => { - console.error(err); -}); +const mongoose = require("mongoose"); +const Promise = require("bluebird"); +const { User } = require("./models"); +const bcrypt = require("bcrypt"); +const LocalStrategy = require("passport-local").Strategy; -const app = express(); if (process.env.NODE_ENV !== "production") { require("dotenv").config(); } -const mongoose = require("mongoose"); -const Promise = require("bluebird"); - -// express session -app.use( - session({ - secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", - resave: false, - saveUninitialized: true, - cookie: { - maxAge: 24 * 60 * 60 - } - }) -); +// const { loginTool } = require("./auth"); // bluebird mongoose mongoose.Promise = Promise; @@ -62,6 +35,20 @@ beginConnection console.error(err); }); +const app = express(); + +// express session +app.use( + session({ + secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", + resave: false, + saveUninitialized: true, + cookie: { + maxAge: 24 * 60 * 60 + } + }) +); + // handlebars view app.set("views", path.join(__dirname, "views")); @@ -81,31 +68,29 @@ app.use(passport.session()); // facebookTools.utilizePassport(passport, User); // linkedinTools.utilizePassport(passport, User); -passport.use(new LocalStrategy( - (username, password, done) => { - let user = findUser(username); - if(!user) return done(null, false); - - bcrypt.compareSync(password, user.password, (err, isValid) => { - if(err) return done(err); - if(!isValid) return done(null, false); - return done(null, user); - }) - } -)) - +passport.use( + new LocalStrategy((username, password, done) => { + let user = findUser(username); + if (!user) return done(null, false); + + bcrypt.compareSync(password, user.password, (err, isValid) => { + if (err) return done(err); + if (!isValid) return done(null, false); + return done(null, user); + }); + }) +); async function findUser(username) { - let user; - try { - user = await findOne({ - username: username - }) - } - catch(error) { - console.error(error) - } - return user; + let user; + try { + user = await User.findOne({ + username: username + }); + } catch (error) { + console.error(error); + } + return user; } // passport.serializeUser(function(user, done) { @@ -119,7 +104,12 @@ async function findUser(username) { // }); // routes -// app.use("/", require("./routes/index")); +app.use("/", require("./routes/index")); +app.use("/api", require("./routes/api")); + +// post to /api/users => json data of all users +// front end, ajax.egt(api/users) = data, parse it + // app.use("/landing", require("./routes/landing")); // Facebook Routes diff --git a/package.json b/package.json index ffacbb4..8dc165f 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Building Ponz.io, with its endearingly upside-down-triangle-shaped business model.", "main": "index.js", "scripts": { + "start": "which nodemon > /dev/null && nodemon index.js || node index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/routes/api.js b/routes/api.js new file mode 100644 index 0000000..ef151ba --- /dev/null +++ b/routes/api.js @@ -0,0 +1,54 @@ +const router = require("express").Router(); +const controllers = require("../controllers"); + +router.get("/:resource", (req, res, next) => { + const resource = req.params.resource; + + const controller = controllers[resource]; + if (controller == null) { + res.json({ + confirmation: "fail", + resource: "invalid resource" + }); + + return; + } + + controller.index(req, res); +}); + +router.get("/:resource/:id", (req, res, next) => { + const resource = req.params.resource; + + const controller = controllers[resource]; + + if (controller == null) { + res.json({ + confirmation: "fail", + resource: "invalid resource" + }); + + return; + } + + controller.view(req, res); +}); + +router.post("/:resource", (req, res, next) => { + const resource = req.params.resource; + + const controller = controllers[resource]; + + if (controller == null) { + res.json({ + confirmation: "fail", + resource: "invalid resource" + }); + + return; + } + + controller.createUser(req, res); +}); + +module.exports = router; diff --git a/routes/index.js b/routes/index.js new file mode 100644 index 0000000..61cae88 --- /dev/null +++ b/routes/index.js @@ -0,0 +1,8 @@ +const router = require("express").Router(); +const { users } = require("../controllers"); + +router.get("/", (req, res) => { + res.render("landing/index"); +}); + +module.exports = router; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars new file mode 100644 index 0000000..8ff4ac6 --- /dev/null +++ b/views/landing/index.handlebars @@ -0,0 +1,40 @@ +

Register

+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +

Login

+
+
+ + +
+ +
+ + +
+ + +
+ From cdeaa8ca9df428d6806107783e1088d76773ef23 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 11:14:41 -0500 Subject: [PATCH 04/32] added a ponz user to database --- controllers/UserController.js | 54 +++++++++++++++------------------- models/index.js | 3 ++ models/user.js | 2 +- views/landing/index.handlebars | 17 +++++------ 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 81c4f20..d82d036 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -1,4 +1,5 @@ -const User = require("./../models/sequelize").User; +const { User } = require("../models"); +const shortid = require("shortid"); module.exports = { index: async (req, res) => { @@ -21,9 +22,7 @@ module.exports = { const id = req.params.id; try { - const user = await User.findById(id, { - include: [{ model: Profile }] - }); + const user = await User.findById(id); return res.json({ confirmation: "success", @@ -39,39 +38,34 @@ module.exports = { createUser: async (req, res) => { // check if user exists - try { - let existingUser = await User.find({ - where: { - $or: { - username: req.body.username, - email: req.body.email - } - } - }); - } catch (e) { - return res.json({ - confirmation: "fail", - message: e.message - }); - } - - if (existingUser) { - return res.json({ - confirmation: "fail", - message: "user already exists" - }); - } - + // try { + // let existingUser = await User.find({ + // username: req.body.username + // }); + // if (existingUser) { + // return res.json({ + // confirmation: "fail", + // message: "user already exists" + // }); + // } + // } catch (e) { + // return res.json({ + // confirmation: "fail", + // message: e.message + // }); + // } + // console.log("Made it here"); // if no user, create the user try { + req.body.shortid = shortid.generate(); let user = await User.create(req.body); - + console.log("made it to the line 63"); return res.json({ confirmation: "success", - user: user, - profile: profile + user: user }); } catch (e) { + console.error(e.stack); return res.json({ confirmation: "fail", message: e.message diff --git a/models/index.js b/models/index.js index e69de29..a0d5e7a 100644 --- a/models/index.js +++ b/models/index.js @@ -0,0 +1,3 @@ +module.exports = { + User: require("./user") +} diff --git a/models/user.js b/models/user.js index 552af47..533f0e3 100644 --- a/models/user.js +++ b/models/user.js @@ -17,7 +17,7 @@ const UserSchema = mongoose.Schema({ points: { type: Number, default: 0 } }); -UserSchema.pre("save", async (next) => { +UserSchema.pre("save", async function(next) { let user = this; let hash = await bcrypt.hashSync(user.password, 12); user.password = hash; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index 8ff4ac6..a75d127 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -1,35 +1,35 @@

Register

-
+
- +
- +
- +
- +
- +

Login

-
+
- +
@@ -37,4 +37,3 @@ - From ff34fb678ebf5a019b7c288bb7611efe396d5ead Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 12:40:46 -0400 Subject: [PATCH 05/32] doing local passport --- auth/passport.js | 21 +++++++++++++++ controllers/UserController.js | 41 ++++++++++++++++-------------- index.js | 48 ++++++++++++++++------------------- 3 files changed, 65 insertions(+), 45 deletions(-) create mode 100644 auth/passport.js diff --git a/auth/passport.js b/auth/passport.js new file mode 100644 index 0000000..9612ee2 --- /dev/null +++ b/auth/passport.js @@ -0,0 +1,21 @@ +const LocalStrategy = require("passport-local").Strategy; +const { User } = require("../models"); + +module.exports = function(passport) => { + passport.serializeUser(function(user, done) { + done(null, user.id); + }); + + passport.deserializeUser(function(id, done) { + User.findById(id, function(err, user) { + done(err, user); + }); + }); + + passport.use('local-signup', new LocalStrategy({ + usernameField: 'username', + passwordField: 'password', + passReqToCallback: true + }, async function(req, username, password, done) { + let user = await User.findOne({ username: username }); + })) diff --git a/controllers/UserController.js b/controllers/UserController.js index d82d036..e6b768f 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -38,28 +38,31 @@ module.exports = { createUser: async (req, res) => { // check if user exists - // try { - // let existingUser = await User.find({ - // username: req.body.username - // }); - // if (existingUser) { - // return res.json({ - // confirmation: "fail", - // message: "user already exists" - // }); - // } - // } catch (e) { - // return res.json({ - // confirmation: "fail", - // message: e.message - // }); - // } - // console.log("Made it here"); - // if no user, create the user + let existingUser; + console.log("checking here/???"); + try { + existingUser = await User.find({ + username: req.body.username + }); + + if (existingUser) { + return res.json({ + confirmation: "fail", + message: "user already exists" + }); + } + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + + // create our user with random id try { req.body.shortid = shortid.generate(); let user = await User.create(req.body); - console.log("made it to the line 63"); + console.log("made it to the line 63"); return res.json({ confirmation: "success", user: user diff --git a/index.js b/index.js index b5ef78e..b908a8f 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,8 @@ const { User } = require("./models"); const bcrypt = require("bcrypt"); const LocalStrategy = require("passport-local").Strategy; +const app = express(); + if (process.env.NODE_ENV !== "production") { require("dotenv").config(); } @@ -35,8 +37,6 @@ beginConnection console.error(err); }); -const app = express(); - // express session app.use( session({ @@ -68,6 +68,7 @@ app.use(passport.session()); // facebookTools.utilizePassport(passport, User); // linkedinTools.utilizePassport(passport, User); + passport.use( new LocalStrategy((username, password, done) => { let user = findUser(username); @@ -93,6 +94,14 @@ async function findUser(username) { return user; } +function isLoggedIn(req, res, next) { + // if user is authenticated in the session, carry on + if (req.isAuthenticated()) return next(); + + // if they aren't redirect them to the home page + res.redirect("/"); +} + // passport.serializeUser(function(user, done) { // done(null, user.id); // }); @@ -104,17 +113,22 @@ async function findUser(username) { // }); // routes -app.use("/", require("./routes/index")); +// app.use("/", require("./routes/index")); app.use("/api", require("./routes/api")); -// post to /api/users => json data of all users -// front end, ajax.egt(api/users) = data, parse it +app.get("/", (req, res) => { + res.render("landing/index"); +}); + +app.get("/ponzvert", isLoggedIn, (req, res) => { + res.send("the main page!"); +}); -// app.use("/landing", require("./routes/landing")); +// auth routes +app.get("/auth/user"); -// Facebook Routes // app.get( -// "/auth/facebook", +// "/auth/user", // passport.authenticate("facebook", { // authType: "rerequest", // scope: ["public_profile"] @@ -130,24 +144,6 @@ app.use("/api", require("./routes/api")); // } // ); -// Linkedin routes -// app.get( -// "/auth/linkedin", -// passport.authenticate("linkedin", { -// authType: "rerequest", -// scope: ['r_basicprofile', 'r_emailaddress'] -// }) -// ); - -// app.get( -// "/auth/linkedin/callback", -// passport.authenticate("linkedin", { failureRedirect: "/login" }), -// function(req, res) { -// // Successful authentication, redirect home. -// res.redirect("/landing"); // test -// } -// ); - // listen to server app.listen(3000, () => { console.log(`Listening at port 3000`); From c74c3ae9cca0bdfbf3c9da3ed954431c6a5fca85 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 12:09:34 -0500 Subject: [PATCH 06/32] messing with routes --- auth/passport.js | 32 ++++++++--- index.js | 129 ++++++++++++++++++++------------------------ middleware/index.js | 3 ++ middleware/login.js | 7 +++ 4 files changed, 92 insertions(+), 79 deletions(-) create mode 100644 middleware/index.js create mode 100644 middleware/login.js diff --git a/auth/passport.js b/auth/passport.js index 9612ee2..2079b8f 100644 --- a/auth/passport.js +++ b/auth/passport.js @@ -1,6 +1,7 @@ const LocalStrategy = require("passport-local").Strategy; const { User } = require("../models"); + module.exports = function(passport) => { passport.serializeUser(function(user, done) { done(null, user.id); @@ -12,10 +13,27 @@ module.exports = function(passport) => { }); }); - passport.use('local-signup', new LocalStrategy({ - usernameField: 'username', - passwordField: 'password', - passReqToCallback: true - }, async function(req, username, password, done) { - let user = await User.findOne({ username: username }); - })) + passport.use('local-login', new LocalStrategy({ + // by default, local strategy uses username and password, we will override with email + usernameField : 'username', + passwordField : 'password', + passReqToCallback : true // allows us to pass back the entire request to the callback + }, + function(req, username, password, done) { // callback with email and password from our form + // find a user whose email is the same as the forms email + // we are checking to see if the user trying to login already exists + User.findOne({ username: username }, function(err, user) { + // if there are any errors, return the error before anything else + if (err) + return done(err); + // if no user is found, return the message + if (!user) + return done(null, false, req.flash('loginMessage', 'No user found.')); // req.flash is the way to set flashdata using connect-flash + // if the user is found but the password is wrong + if (!user.validPassword(password)) + return done(null, false, req.flash('loginMessage', 'Oops! Wrong password.')); // create the loginMessage and save it to session as flashdata + // all is well, return successful user + return done(null, user); + }); + })); + } diff --git a/index.js b/index.js index b908a8f..571277c 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,28 @@ const express = require("express"); +const app = express(); const path = require("path"); const logger = require("morgan"); const bodyParser = require("body-parser"); const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); +const flash = require("flash-connect"); + +app.use(passport.initialize()); +app.use(passport.session()); +app.use(flash()); const mongoose = require("mongoose"); const Promise = require("bluebird"); -const { User } = require("./models"); +const {isLoggedIn} = require("./middleware"); -const bcrypt = require("bcrypt"); -const LocalStrategy = require("passport-local").Strategy; +const localAuth = require("auth")(passport); +// const { User } = require("./models"); +// const LocalStrategy = require("passport-local").Strategy; -const app = express(); if (process.env.NODE_ENV !== "production") { - require("dotenv").config(); + require("dotenv").config(); } // const { loginTool } = require("./auth"); @@ -25,82 +31,61 @@ if (process.env.NODE_ENV !== "production") { mongoose.Promise = Promise; // connect to mongoose -const beginConnection = mongoose.connect(process.env.DB_URL, { - useMongoClient: true -}); +const beginConnection = mongoose.connect(process.env.DB_URL, {useMongoClient: true}); -beginConnection - .then(db => { - console.log("DB CONNECTION SUCCESS"); - }) - .catch(err => { - console.error(err); - }); +beginConnection.then(db => { + console.log("DB CONNECTION SUCCESS"); +}).catch(err => { + console.error(err); +}); // express session -app.use( - session({ - secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", - resave: false, - saveUninitialized: true, - cookie: { - maxAge: 24 * 60 * 60 - } - }) -); +app.use(session({ + secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", + resave: false, + saveUninitialized: true, + cookie: { + maxAge: 24 * 60 * 60 + } +})); // handlebars view app.set("views", path.join(__dirname, "views")); // hbs -app.engine("handlebars", exphbs({ defaultLayout: "main" })); +app.engine("handlebars", exphbs({defaultLayout: "main"})); app.set("view engine", "handlebars"); // middleware app.use(logger("dev")); app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({ extended: true })); +app.use(bodyParser.urlencoded({extended: true})); app.use(express.static(path.join(__dirname, "public"))); +// passport.use( +// new LocalStrategy((username, password, done) => { +// let user = findUser(username); +// if (!user) return done(null, false); // -app.use(passport.initialize()); -app.use(passport.session()); - -// facebookTools.utilizePassport(passport, User); -// linkedinTools.utilizePassport(passport, User); - -passport.use( - new LocalStrategy((username, password, done) => { - let user = findUser(username); - if (!user) return done(null, false); - - bcrypt.compareSync(password, user.password, (err, isValid) => { - if (err) return done(err); - if (!isValid) return done(null, false); - return done(null, user); - }); - }) -); - -async function findUser(username) { - let user; - try { - user = await User.findOne({ - username: username - }); - } catch (error) { - console.error(error); - } - return user; -} - -function isLoggedIn(req, res, next) { - // if user is authenticated in the session, carry on - if (req.isAuthenticated()) return next(); +// bcrypt.compareSync(password, user.password, (err, isValid) => { +// if (err) return done(err); +// if (!isValid) return done(null, false); +// return done(null, user); +// }); +// }) +// ); - // if they aren't redirect them to the home page - res.redirect("/"); -} +// async function findUser(username) { +// let user; +// try { +// user = await User.findOne({ +// username: username +// }); +// } catch (error) { +// console.error(error); +// } +// return user; +// } // passport.serializeUser(function(user, done) { // done(null, user.id); @@ -115,17 +100,17 @@ function isLoggedIn(req, res, next) { // routes // app.use("/", require("./routes/index")); app.use("/api", require("./routes/api")); - -app.get("/", (req, res) => { - res.render("landing/index"); -}); +app.use("/", require("./routes/index")) app.get("/ponzvert", isLoggedIn, (req, res) => { - res.send("the main page!"); + res.send("the main page!"); }); -// auth routes -app.get("/auth/user"); +app.post("/login", passport.authenticate("local-login", { + successRedirect: "/ponzvert", + failureRedirect: "/", + failureFlash: true +})) // app.get( // "/auth/user", @@ -146,5 +131,5 @@ app.get("/auth/user"); // listen to server app.listen(3000, () => { - console.log(`Listening at port 3000`); + console.log(`Listening at port 3000`); }); diff --git a/middleware/index.js b/middleware/index.js new file mode 100644 index 0000000..a59d946 --- /dev/null +++ b/middleware/index.js @@ -0,0 +1,3 @@ +module.exports = { + isLoggedIn: require("./login") +} diff --git a/middleware/login.js b/middleware/login.js new file mode 100644 index 0000000..713f3b1 --- /dev/null +++ b/middleware/login.js @@ -0,0 +1,7 @@ +module.exports = function(req, res, next) { + // if user is authenticated in the session, carry on + if (req.isAuthenticated()) return next(); + + // if they aren't redirect them to the home page + res.redirect("/"); +} From 58ba241af521068a829317dd0c3787e6a567aa11 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 13:34:26 -0400 Subject: [PATCH 07/32] local auth working --- auth/passport.js | 73 ++++++++++++++++++------------- index.js | 79 ++++++++++++++++++---------------- middleware/login.js | 3 +- package-lock.json | 5 +++ package.json | 1 + routes/ponzvert.js | 8 ++++ views/landing/index.handlebars | 2 +- 7 files changed, 101 insertions(+), 70 deletions(-) create mode 100644 routes/ponzvert.js diff --git a/auth/passport.js b/auth/passport.js index 2079b8f..ea4ff75 100644 --- a/auth/passport.js +++ b/auth/passport.js @@ -1,39 +1,52 @@ const LocalStrategy = require("passport-local").Strategy; +const bcrypt = require("bcrypt"); const { User } = require("../models"); - -module.exports = function(passport) => { +module.exports = function(passport) { passport.serializeUser(function(user, done) { - done(null, user.id); + done(null, user.id); }); passport.deserializeUser(function(id, done) { - User.findById(id, function(err, user) { - done(err, user); - }); + User.findById(id, function(err, user) { + done(err, user); + }); }); - passport.use('local-login', new LocalStrategy({ - // by default, local strategy uses username and password, we will override with email - usernameField : 'username', - passwordField : 'password', - passReqToCallback : true // allows us to pass back the entire request to the callback - }, - function(req, username, password, done) { // callback with email and password from our form - // find a user whose email is the same as the forms email - // we are checking to see if the user trying to login already exists - User.findOne({ username: username }, function(err, user) { - // if there are any errors, return the error before anything else - if (err) - return done(err); - // if no user is found, return the message - if (!user) - return done(null, false, req.flash('loginMessage', 'No user found.')); // req.flash is the way to set flashdata using connect-flash - // if the user is found but the password is wrong - if (!user.validPassword(password)) - return done(null, false, req.flash('loginMessage', 'Oops! Wrong password.')); // create the loginMessage and save it to session as flashdata - // all is well, return successful user - return done(null, user); - }); - })); - } + passport.use( + "local-login", + new LocalStrategy( + { + // local strategy uses username and password + usernameField: "username", + passwordField: "password", + passReqToCallback: true // allows us to pass back the entire request to the callback + }, + function(req, username, password, done) { + // callback password from our form + // find a user whose username is the same as the forms username + // we are checking to see if the user trying to login already exists + User.findOne({ username: username }, function(err, user) { + // if there are any errors, return the error before anything else + if (err) return done(err); + // if no user is found, return the message + if (!user) + return done( + null, + false, + req.flash("loginMessage", "No user found.") + ); // req.flash is the way to set flashdata using connect-flash + // if the user is found but the password is wrong + if (!bcrypt.compareSync(password, user.password)) + return done( + null, + false, + req.flash("loginMessage", "Oops! Wrong password.") + ); // create the loginMessage and save it to session as flashdata + // all is well, return successful user + return done(null, user); + }); + } + ) + ); +}; diff --git a/index.js b/index.js index 571277c..8785d00 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,15 @@ const bodyParser = require("body-parser"); const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); -const flash = require("flash-connect"); +const flash = require("connect-flash"); + +app.use( + session({ + secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", + resave: true, + saveUninitialized: true + }) +); app.use(passport.initialize()); app.use(passport.session()); @@ -14,15 +22,13 @@ app.use(flash()); const mongoose = require("mongoose"); const Promise = require("bluebird"); -const {isLoggedIn} = require("./middleware"); -const localAuth = require("auth")(passport); +const localAuth = require("./auth/passport")(passport); // const { User } = require("./models"); // const LocalStrategy = require("passport-local").Strategy; - if (process.env.NODE_ENV !== "production") { - require("dotenv").config(); + require("dotenv").config(); } // const { loginTool } = require("./auth"); @@ -31,35 +37,31 @@ if (process.env.NODE_ENV !== "production") { mongoose.Promise = Promise; // connect to mongoose -const beginConnection = mongoose.connect(process.env.DB_URL, {useMongoClient: true}); - -beginConnection.then(db => { - console.log("DB CONNECTION SUCCESS"); -}).catch(err => { - console.error(err); +const beginConnection = mongoose.connect(process.env.DB_URL, { + useMongoClient: true }); +beginConnection + .then(db => { + console.log("DB CONNECTION SUCCESS"); + }) + .catch(err => { + console.error(err); + }); + // express session -app.use(session({ - secret: "123fljwejflkkwjelk23jlkf23fl2k3jl23kfjlk23j329f4", - resave: false, - saveUninitialized: true, - cookie: { - maxAge: 24 * 60 * 60 - } -})); // handlebars view app.set("views", path.join(__dirname, "views")); // hbs -app.engine("handlebars", exphbs({defaultLayout: "main"})); +app.engine("handlebars", exphbs({ defaultLayout: "main" })); app.set("view engine", "handlebars"); // middleware app.use(logger("dev")); app.use(bodyParser.json()); -app.use(bodyParser.urlencoded({extended: true})); +app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static(path.join(__dirname, "public"))); // passport.use( @@ -67,11 +69,12 @@ app.use(express.static(path.join(__dirname, "public"))); // let user = findUser(username); // if (!user) return done(null, false); // -// bcrypt.compareSync(password, user.password, (err, isValid) => { -// if (err) return done(err); -// if (!isValid) return done(null, false); -// return done(null, user); -// }); +// bcrypt.compareSync(password, user.password, (err, isValid) => { +// if (err) return done(err); +// if (!isValid) return done(null, false); +// return done(null, user); +// }); + // }) // ); @@ -100,17 +103,17 @@ app.use(express.static(path.join(__dirname, "public"))); // routes // app.use("/", require("./routes/index")); app.use("/api", require("./routes/api")); -app.use("/", require("./routes/index")) - -app.get("/ponzvert", isLoggedIn, (req, res) => { - res.send("the main page!"); -}); - -app.post("/login", passport.authenticate("local-login", { - successRedirect: "/ponzvert", - failureRedirect: "/", - failureFlash: true -})) +app.use("/ponzvert", require("./routes/ponzvert")); +app.use("/", require("./routes/index")); + +app.post( + "/login", + passport.authenticate("local-login", { + successRedirect: "/ponzvert", + failureRedirect: "/", + failureFlash: true + }) +); // app.get( // "/auth/user", @@ -131,5 +134,5 @@ app.post("/login", passport.authenticate("local-login", { // listen to server app.listen(3000, () => { - console.log(`Listening at port 3000`); + console.log(`Listening at port 3000`); }); diff --git a/middleware/login.js b/middleware/login.js index 713f3b1..149f5ed 100644 --- a/middleware/login.js +++ b/middleware/login.js @@ -1,7 +1,8 @@ module.exports = function(req, res, next) { + console.log("here???"); // if user is authenticated in the session, carry on if (req.isAuthenticated()) return next(); // if they aren't redirect them to the home page res.redirect("/"); -} +}; diff --git a/package-lock.json b/package-lock.json index adfab6c..380de18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -275,6 +275,11 @@ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" }, + "connect-flash": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/connect-flash/-/connect-flash-0.1.1.tgz", + "integrity": "sha1-2GMPJtlaf4UfmVax6MxnMvO2qjA=" + }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", diff --git a/package.json b/package.json index 8dc165f..93e01b5 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "bcrypt": "^1.0.2", "bluebird": "^3.5.0", "body-parser": "^1.17.2", + "connect-flash": "^0.1.1", "dotenv": "^4.0.0", "express": "^4.15.4", "express-flash-messages": "^0.1.1", diff --git a/routes/ponzvert.js b/routes/ponzvert.js new file mode 100644 index 0000000..d6a3af5 --- /dev/null +++ b/routes/ponzvert.js @@ -0,0 +1,8 @@ +const router = require("express").Router(); +const { isLoggedIn } = require("../middleware"); + +router.get("/", isLoggedIn, (req, res) => { + res.send("the main page!"); +}); + +module.exports = router; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index a75d127..19f6653 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -24,7 +24,7 @@

Login

-
+
From 3f996e7764a202625f1a1a3cccce791a8e2c4122 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 14:46:54 -0500 Subject: [PATCH 08/32] can add referrals somewhat, no only parents --- controllers/UserController.js | 43 +++++++++++++++++++++--- index.js | 59 ++------------------------------- models/user.js | 2 +- routes/index.js | 6 +++- routes/logout.js | 8 +++++ routes/ponzvert.js | 7 +++- views/landing/index.handlebars | 4 +++ views/ponzvert/index.handlebars | 14 ++++++++ views/submission.hbs | 0 9 files changed, 79 insertions(+), 64 deletions(-) create mode 100644 routes/logout.js create mode 100644 views/ponzvert/index.handlebars delete mode 100644 views/submission.hbs diff --git a/controllers/UserController.js b/controllers/UserController.js index e6b768f..4f2a860 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -39,9 +39,8 @@ module.exports = { createUser: async (req, res) => { // check if user exists let existingUser; - console.log("checking here/???"); try { - existingUser = await User.find({ + existingUser = await User.findOne({ username: req.body.username }); @@ -60,9 +59,17 @@ module.exports = { // create our user with random id try { - req.body.shortid = shortid.generate(); + // registering for another user + console.log("shortid: ", req.session.shortid) + if(req.session.shortid) { + createChildUser(req, res); + return; + } + + let id = shortid.generate(); + req.body.shortid = id; + let user = await User.create(req.body); - console.log("made it to the line 63"); return res.json({ confirmation: "success", user: user @@ -76,3 +83,31 @@ module.exports = { } } }; + +async function createChildUser(req, res) { + try { + let parentUser = await User.findOne({ shortid: req.session.shortid }) + let id = shortid.generate(); + req.body.shortid = id; + req.body.parent = parentUser; + console.log("ParentUser", parentUser); + + let childUser = await User.create(req.body); + + await User.update({ shortid: req.session.shortid }, + { $push: { children: childUser } } + ) + + // parentUser.children(childUser); + + return res.json({ + confirmation: "success", + user: childUser + }); + } catch(e){ + return res.json({ + confirmation: "fail", + message: e.message + }); + } +} diff --git a/index.js b/index.js index 8785d00..1c1595a 100644 --- a/index.js +++ b/index.js @@ -24,15 +24,11 @@ const mongoose = require("mongoose"); const Promise = require("bluebird"); const localAuth = require("./auth/passport")(passport); -// const { User } = require("./models"); -// const LocalStrategy = require("passport-local").Strategy; if (process.env.NODE_ENV !== "production") { require("dotenv").config(); } -// const { loginTool } = require("./auth"); - // bluebird mongoose mongoose.Promise = Promise; @@ -64,47 +60,11 @@ app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static(path.join(__dirname, "public"))); -// passport.use( -// new LocalStrategy((username, password, done) => { -// let user = findUser(username); -// if (!user) return done(null, false); -// -// bcrypt.compareSync(password, user.password, (err, isValid) => { -// if (err) return done(err); -// if (!isValid) return done(null, false); -// return done(null, user); -// }); - -// }) -// ); - -// async function findUser(username) { -// let user; -// try { -// user = await User.findOne({ -// username: username -// }); -// } catch (error) { -// console.error(error); -// } -// return user; -// } - -// passport.serializeUser(function(user, done) { -// done(null, user.id); -// }); - -// passport.deserializeUser(function(id, done) { -// User.findById(id, function(err, user) { -// done(err, user); -// }); -// }); - // routes -// app.use("/", require("./routes/index")); app.use("/api", require("./routes/api")); app.use("/ponzvert", require("./routes/ponzvert")); app.use("/", require("./routes/index")); +app.use("/logout", require("./routes/logout")); app.post( "/login", @@ -115,22 +75,7 @@ app.post( }) ); -// app.get( -// "/auth/user", -// passport.authenticate("facebook", { -// authType: "rerequest", -// scope: ["public_profile"] -// }) -// ); - -// app.get( -// "/auth/facebook/callback", -// passport.authenticate("facebook", { failureRedirect: "/login" }), -// function(req, res) { -// // Successful authentication, redirect home. -// res.redirect("/landing"); // test -// } -// ); + // listen to server app.listen(3000, () => { diff --git a/models/user.js b/models/user.js index 533f0e3..8887c56 100644 --- a/models/user.js +++ b/models/user.js @@ -10,7 +10,7 @@ const UserSchema = mongoose.Schema({ password: { type: String, required: true }, fname: { type: String, required: true }, lname: { type: String, required: true }, - shortid: { type: String, required: true, unique: true }, + shortid: { type: String, required: true }, timestamp: { type: Date, default: Date.now }, parent: { type: Schema.Types.ObjectId, ref: "User", default: null }, children: [{ type: Schema.Types.ObjectId, ref: "User" }], diff --git a/routes/index.js b/routes/index.js index 61cae88..9d36eb7 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,7 +2,11 @@ const router = require("express").Router(); const { users } = require("../controllers"); router.get("/", (req, res) => { - res.render("landing/index"); + console.log("req.session", req.session); + if(req.isAuthenticated()) { + return res.redirect("/ponzvert"); + } + return res.render("landing/index"); }); module.exports = router; diff --git a/routes/logout.js b/routes/logout.js new file mode 100644 index 0000000..7c634ec --- /dev/null +++ b/routes/logout.js @@ -0,0 +1,8 @@ +const router = require("express").Router(); + +router.get("/", (req, res) => { + req.logout(); + res.redirect("/"); +}) + +module.exports = router; diff --git a/routes/ponzvert.js b/routes/ponzvert.js index d6a3af5..9aee7ff 100644 --- a/routes/ponzvert.js +++ b/routes/ponzvert.js @@ -2,7 +2,12 @@ const router = require("express").Router(); const { isLoggedIn } = require("../middleware"); router.get("/", isLoggedIn, (req, res) => { - res.send("the main page!"); + return res.render("ponzvert/index", { user: req.user }); }); +router.get("/:shortid", (req, res) => { + req.session.shortid = req.params.shortid; + return res.redirect("/"); +}) + module.exports = router; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index 19f6653..1616b56 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -1,5 +1,9 @@

Register

+ {{#if user}} + + {{/if}} +
diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars new file mode 100644 index 0000000..ea78152 --- /dev/null +++ b/views/ponzvert/index.handlebars @@ -0,0 +1,14 @@ + + +

Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

+ +

Ponz Points™: ${{user.points}}

+ +

Your Ponzverts

+{{#if user.children.length}} + {{#each user.children as |child|}} +
Points: ${{child.points}}, User: {{child.fname}} {{child.lname}}, ponverted on {{child.timestamp}}
+ + + {{/each}} +{{/if}} diff --git a/views/submission.hbs b/views/submission.hbs deleted file mode 100644 index e69de29..0000000 From 931eb6013aff4f9beb779aa2a44807d8d73d9c7e Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 16:21:09 -0400 Subject: [PATCH 09/32] updating one field --- auth/passport.js | 6 ++++ controllers/UserController.js | 68 +++++++++++++++++++++++++++++------ routes/index.js | 9 +++-- 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/auth/passport.js b/auth/passport.js index ea4ff75..0ef2936 100644 --- a/auth/passport.js +++ b/auth/passport.js @@ -37,6 +37,12 @@ module.exports = function(passport) { req.flash("loginMessage", "No user found.") ); // req.flash is the way to set flashdata using connect-flash // if the user is found but the password is wrong + console.log("input password", password); + console.log("user password", user.password); + console.log( + bcrypt.compareSync(password, user.password), + "????" + ); if (!bcrypt.compareSync(password, user.password)) return done( null, diff --git a/controllers/UserController.js b/controllers/UserController.js index 4f2a860..94b6025 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -60,8 +60,8 @@ module.exports = { // create our user with random id try { // registering for another user - console.log("shortid: ", req.session.shortid) - if(req.session.shortid) { + console.log("shortid: ", req.session.shortid); + if (req.session.shortid) { createChildUser(req, res); return; } @@ -86,7 +86,7 @@ module.exports = { async function createChildUser(req, res) { try { - let parentUser = await User.findOne({ shortid: req.session.shortid }) + let parentUser = await User.findOne({ shortid: req.session.shortid }); let id = shortid.generate(); req.body.shortid = id; req.body.parent = parentUser; @@ -94,20 +94,68 @@ async function createChildUser(req, res) { let childUser = await User.create(req.body); - await User.update({ shortid: req.session.shortid }, - { $push: { children: childUser } } - ) - - // parentUser.children(childUser); + parentUser.children.push(childUser); + await parentUser.save(); return res.json({ confirmation: "success", - user: childUser + user: childUser, + parentUser: parentUser }); - } catch(e){ + } catch (e) { return res.json({ confirmation: "fail", message: e.message }); } } + +/* +{ + "confirmation":"success", + "user":{ + "__v":0, + "username":"Susan2", + "password":"$2a$12$8ExCDQLR8wglpNlOEdgIEO1IhqDXuAMcTiotJScs6frho6aPCb1AC", + "fname":"Susan2", + "lname":"Susan2", + "shortid":"ByVEEQfOW", + "_id":"5994a42bade777c8dec3cf71", + "points":0, + "children":[ + + ], + "parent":{ + "_id":"5994a3f5ade777c8dec3cf70", + "username":"Susan", + "password":"$2a$12$lnh4Sjo8Ih3YoG2ki45ZOOgFvmUAFMUd/1lnNUYAESxPgadGvsuMm", + "fname":"Susan", + "lname":"Susan", + "shortid":"ByTxNmfO-", + "__v":1, + "points":0, + "children":[ + "5994a42bade777c8dec3cf71" + ], + "parent":null, + "timestamp":"2017-08-16T19:58:45.263Z" + }, + "timestamp":"2017-08-16T19:59:39.649Z" + }, + "parentUser":{ + "_id":"5994a3f5ade777c8dec3cf70", + "username":"Susan", + "password":"$2a$12$lnh4Sjo8Ih3YoG2ki45ZOOgFvmUAFMUd/1lnNUYAESxPgadGvsuMm", + "fname":"Susan", + "lname":"Susan", + "shortid":"ByTxNmfO-", + "__v":1, + "points":0, + "children":[ + "5994a42bade777c8dec3cf71" + ], + "parent":null, + "timestamp":"2017-08-16T19:58:45.263Z" + } +} + */ diff --git a/routes/index.js b/routes/index.js index 9d36eb7..b07b3f6 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,11 +2,14 @@ const router = require("express").Router(); const { users } = require("../controllers"); router.get("/", (req, res) => { - console.log("req.session", req.session); - if(req.isAuthenticated()) { + console.log("loop again?"); + // console.log("req.session", req.session); + if (req.user) { + console.log("inside redirect here???"); return res.redirect("/ponzvert"); } - return res.render("landing/index"); + + return res.render("landing/index"); }); module.exports = router; From 697a0480e6f40b39b68e36a7ba7cb4f7d28bb03a Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 16:09:08 -0500 Subject: [PATCH 10/32] population issues with parents --- controllers/UserController.js | 86 ++++++++++++----------------------- models/user.js | 4 +- 2 files changed, 32 insertions(+), 58 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 94b6025..3adb48a 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -60,7 +60,7 @@ module.exports = { // create our user with random id try { // registering for another user - console.log("shortid: ", req.session.shortid); + // console.log("shortid: ", req.session.shortid); if (req.session.shortid) { createChildUser(req, res); return; @@ -86,16 +86,20 @@ module.exports = { async function createChildUser(req, res) { try { - let parentUser = await User.findOne({ shortid: req.session.shortid }); - let id = shortid.generate(); + const parentUser = await User.findOne({ shortid: req.session.shortid }); + const id = shortid.generate(); req.body.shortid = id; - req.body.parent = parentUser; - console.log("ParentUser", parentUser); + req.body.parent = parentUser._id; - let childUser = await User.create(req.body); + const childUser = await User.create(req.body); - parentUser.children.push(childUser); - await parentUser.save(); + await User.findByIdAndUpdate(parentUser._id, + { $push: { "children": childUser._id } }, + { "new": true, "upsert": true } ) + + // console.log("parentuser", parentUser.populate('parent')) + // console.log("parentuser", parentUser.populate('parent').parent) + updatePoints(parentUser, 40); return res.json({ confirmation: "success", @@ -110,52 +114,22 @@ async function createChildUser(req, res) { } } -/* -{ - "confirmation":"success", - "user":{ - "__v":0, - "username":"Susan2", - "password":"$2a$12$8ExCDQLR8wglpNlOEdgIEO1IhqDXuAMcTiotJScs6frho6aPCb1AC", - "fname":"Susan2", - "lname":"Susan2", - "shortid":"ByVEEQfOW", - "_id":"5994a42bade777c8dec3cf71", - "points":0, - "children":[ - - ], - "parent":{ - "_id":"5994a3f5ade777c8dec3cf70", - "username":"Susan", - "password":"$2a$12$lnh4Sjo8Ih3YoG2ki45ZOOgFvmUAFMUd/1lnNUYAESxPgadGvsuMm", - "fname":"Susan", - "lname":"Susan", - "shortid":"ByTxNmfO-", - "__v":1, - "points":0, - "children":[ - "5994a42bade777c8dec3cf71" - ], - "parent":null, - "timestamp":"2017-08-16T19:58:45.263Z" - }, - "timestamp":"2017-08-16T19:59:39.649Z" - }, - "parentUser":{ - "_id":"5994a3f5ade777c8dec3cf70", - "username":"Susan", - "password":"$2a$12$lnh4Sjo8Ih3YoG2ki45ZOOgFvmUAFMUd/1lnNUYAESxPgadGvsuMm", - "fname":"Susan", - "lname":"Susan", - "shortid":"ByTxNmfO-", - "__v":1, - "points":0, - "children":[ - "5994a42bade777c8dec3cf71" - ], - "parent":null, - "timestamp":"2017-08-16T19:58:45.263Z" - } +async function updatePoints(parentUser, points) { + + let newParentUser; + try { + console.log("parentUser", parentUser); + if(!parentUser) return; + await User.findByIdAndUpdate(parentUser._id, + { $inc: { 'points': points } } + ) + newParentUser = await parentUser.populate('parent'); + // console.log(newParentUser, "newParentUser"); + if(points > 1) { + points /= 2; + } + } catch(err) { + console.error(err); + } + return updatePoints(newParentUser, points); } - */ diff --git a/models/user.js b/models/user.js index 8887c56..c8dee6a 100644 --- a/models/user.js +++ b/models/user.js @@ -18,8 +18,8 @@ const UserSchema = mongoose.Schema({ }); UserSchema.pre("save", async function(next) { - let user = this; - let hash = await bcrypt.hashSync(user.password, 12); + const user = this; + const hash = await bcrypt.hashSync(user.password, 12); user.password = hash; next(); }) From 77b0607b86f0d1812b938180b9c4388516b8f1e0 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 17:53:09 -0400 Subject: [PATCH 11/32] got basic referrals --- controllers/UserController.js | 41 ++++++++++++++++++++++----------- views/ponzvert/index.handlebars | 2 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 3adb48a..0d361f8 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -85,17 +85,20 @@ module.exports = { }; async function createChildUser(req, res) { + let parentUser; try { - const parentUser = await User.findOne({ shortid: req.session.shortid }); + parentUser = await User.findOne({ shortid: req.session.shortid }); const id = shortid.generate(); req.body.shortid = id; req.body.parent = parentUser._id; const childUser = await User.create(req.body); - await User.findByIdAndUpdate(parentUser._id, - { $push: { "children": childUser._id } }, - { "new": true, "upsert": true } ) + parentUser = await User.findByIdAndUpdate( + parentUser._id, + { $push: { children: childUser._id } }, + { new: true, upsert: true } + ); // console.log("parentuser", parentUser.populate('parent')) // console.log("parentuser", parentUser.populate('parent').parent) @@ -115,21 +118,31 @@ async function createChildUser(req, res) { } async function updatePoints(parentUser, points) { - let newParentUser; try { - console.log("parentUser", parentUser); - if(!parentUser) return; - await User.findByIdAndUpdate(parentUser._id, - { $inc: { 'points': points } } - ) - newParentUser = await parentUser.populate('parent'); - // console.log(newParentUser, "newParentUser"); - if(points > 1) { + console.log(parentUser, "parentUser"); + if (!parentUser) return; + await User.findByIdAndUpdate(parentUser._id, { $inc: { points: points } }); + newParentUser = await User.findById(parentUser.parent); + + console.log(newParentUser, "newParentUser"); + if (points > 1) { points /= 2; } - } catch(err) { + } catch (err) { console.error(err); } return updatePoints(newParentUser, points); } + +// User.findOne({ _id: req.params.id }, function(err, node) { +// populateParents(node).then(function() { +// // Do something with user +// }); +// }); + +// function populateParents(user) { +// return User.populate(user, { parent: "parent" }).then(function(user) { +// return user.parent ? populateParents(user.parent) : Promise.fulfill(user); +// }); +// } diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index ea78152..efd4ebd 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,5 +1,5 @@ - +

{{user.username}}

Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

Ponz Points™: ${{user.points}}

From b8ceb3e54bc04b7f68b4065d06f3df4465a38f4b Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Wed, 16 Aug 2017 17:31:38 -0500 Subject: [PATCH 12/32] child population for ponzvert page working --- controllers/UserController.js | 13 ++----------- routes/ponzvert.js | 16 ++++++++++++++-- views/ponzvert/index.handlebars | 6 ++---- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 0d361f8..96f58bd 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -70,10 +70,7 @@ module.exports = { req.body.shortid = id; let user = await User.create(req.body); - return res.json({ - confirmation: "success", - user: user - }); + return res.redirect("/ponzvert"); } catch (e) { console.error(e.stack); return res.json({ @@ -100,15 +97,9 @@ async function createChildUser(req, res) { { new: true, upsert: true } ); - // console.log("parentuser", parentUser.populate('parent')) - // console.log("parentuser", parentUser.populate('parent').parent) updatePoints(parentUser, 40); - return res.json({ - confirmation: "success", - user: childUser, - parentUser: parentUser - }); + return res.redirect("/ponzvert"); } catch (e) { return res.json({ confirmation: "fail", diff --git a/routes/ponzvert.js b/routes/ponzvert.js index 9aee7ff..4a25c55 100644 --- a/routes/ponzvert.js +++ b/routes/ponzvert.js @@ -1,12 +1,24 @@ const router = require("express").Router(); const { isLoggedIn } = require("../middleware"); +const { User } = require("../models"); -router.get("/", isLoggedIn, (req, res) => { - return res.render("ponzvert/index", { user: req.user }); +router.get("/", isLoggedIn, async (req, res) => { + try { + const user = await User.findById(req.user._id).populate('children') + console.log("userInfo ", user) + return res.render("ponzvert/index", { user }); + } catch(err) { + console.error(err); + return res.json({ + confirmation: "fail", + message: err.message + }); + } }); router.get("/:shortid", (req, res) => { req.session.shortid = req.params.shortid; + return res.redirect("/"); }) diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index efd4ebd..94e63f8 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,4 +1,4 @@ - +

{{user.username}}

Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

@@ -7,8 +7,6 @@

Your Ponzverts

{{#if user.children.length}} {{#each user.children as |child|}} -
Points: ${{child.points}}, User: {{child.fname}} {{child.lname}}, ponverted on {{child.timestamp}}
- - +
Points: ${{child.points}}, User: {{child.username}}, ponverted on {{child.timestamp}}
{{/each}} {{/if}} From 107f2ddac6d4688775fa5dcd870ffee03075f910 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Wed, 16 Aug 2017 18:58:20 -0400 Subject: [PATCH 13/32] finished displaying children --- controllers/UserController.js | 16 ++++++++++++++++ package-lock.json | 5 +++++ package.json | 1 + routes/ponzvert.js | 18 +++--------------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 96f58bd..ad76d99 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -1,5 +1,6 @@ const { User } = require("../models"); const shortid = require("shortid"); +const moment = require("moment"); module.exports = { index: async (req, res) => { @@ -36,6 +37,21 @@ module.exports = { } }, + viewPonzvert: async (req, res) => { + let id = req.user._id; + + try { + const user = await User.findById(id).populate("children"); + + return res.render("ponzvert/index", { user }); + } catch (e) { + return res.json({ + confirmation: "fail", + message: e.message + }); + } + }, + createUser: async (req, res) => { // check if user exists let existingUser; diff --git a/package-lock.json b/package-lock.json index 380de18..1cd95ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -949,6 +949,11 @@ "minimist": "0.0.8" } }, + "moment": { + "version": "2.18.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz", + "integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8=" + }, "mongodb": { "version": "2.2.31", "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.31.tgz", diff --git a/package.json b/package.json index 93e01b5..fb373d5 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "express-flash-messages": "^0.1.1", "express-handlebars": "^3.0.0", "express-session": "^1.15.5", + "moment": "^2.18.1", "mongoose": "^4.11.7", "morgan": "^1.8.2", "passport": "^0.4.0", diff --git a/routes/ponzvert.js b/routes/ponzvert.js index 4a25c55..9023f80 100644 --- a/routes/ponzvert.js +++ b/routes/ponzvert.js @@ -1,25 +1,13 @@ const router = require("express").Router(); const { isLoggedIn } = require("../middleware"); const { User } = require("../models"); +const { users } = require("../controllers"); -router.get("/", isLoggedIn, async (req, res) => { - try { - const user = await User.findById(req.user._id).populate('children') - console.log("userInfo ", user) - return res.render("ponzvert/index", { user }); - } catch(err) { - console.error(err); - return res.json({ - confirmation: "fail", - message: err.message - }); - } -}); +router.get("/", isLoggedIn, users.viewPonzvert); router.get("/:shortid", (req, res) => { req.session.shortid = req.params.shortid; - return res.redirect("/"); -}) +}); module.exports = router; From a678dfde712716439242349e6129ebb3256e8758 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 04:22:41 -0400 Subject: [PATCH 14/32] revamped cover page for a nice UI, added D3 presentation of the data, added infinite child nesting --- controllers/UserController.js | 18 +++- index.js | 17 +++- middleware/login.js | 1 - models/user.js | 11 ++- public/assets/savonne.png | Bin 0 -> 10764 bytes public/javascripts/script.js | 12 +++ public/styles/main.css | 156 ++++++++++++++++++++++++++++++++ routes/index.js | 5 +- views/landing/index.handlebars | 63 ++++++------- views/layouts/main.handlebars | 70 ++++++++++++-- views/ponzvert/index.handlebars | 138 +++++++++++++++++++++++++++- 11 files changed, 434 insertions(+), 57 deletions(-) create mode 100644 public/assets/savonne.png create mode 100644 public/javascripts/script.js create mode 100644 public/styles/main.css diff --git a/controllers/UserController.js b/controllers/UserController.js index ad76d99..3060590 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -40,10 +40,24 @@ module.exports = { viewPonzvert: async (req, res) => { let id = req.user._id; + // do a map user on the first user's parent + // { user: 'Bob, parent: susan } { user:susna } // try { - const user = await User.findById(id).populate("children"); + const user = await User.findById(id) + .populate("children") + .populate("parent"); - return res.render("ponzvert/index", { user }); + console.log(user, "user"); + + const mapUser = user => { + return { + name: user.username, + parent: user.parent ? user.parent.username : "null", + children: user.children.map(mapUser) + }; + }; + + return res.render("ponzvert/index", { user, tree: [mapUser(user)] }); } catch (e) { return res.json({ confirmation: "fail", diff --git a/index.js b/index.js index 1c1595a..adbc6f7 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const bodyParser = require("body-parser"); const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); -const flash = require("connect-flash"); +const flash = require("express-flash-messages"); app.use( session({ @@ -51,7 +51,18 @@ beginConnection app.set("views", path.join(__dirname, "views")); // hbs -app.engine("handlebars", exphbs({ defaultLayout: "main" })); +app.engine( + "handlebars", + exphbs({ + defaultLayout: "main", + helpers: { + toJSON: function(object) { + return JSON.stringify(object); + } + } + }) +); + app.set("view engine", "handlebars"); // middleware @@ -75,8 +86,6 @@ app.post( }) ); - - // listen to server app.listen(3000, () => { console.log(`Listening at port 3000`); diff --git a/middleware/login.js b/middleware/login.js index 149f5ed..fefc39d 100644 --- a/middleware/login.js +++ b/middleware/login.js @@ -1,5 +1,4 @@ module.exports = function(req, res, next) { - console.log("here???"); // if user is authenticated in the session, carry on if (req.isAuthenticated()) return next(); diff --git a/models/user.js b/models/user.js index c8dee6a..f597f90 100644 --- a/models/user.js +++ b/models/user.js @@ -2,7 +2,10 @@ const mongoose = require("mongoose"); const bcrypt = require("bcrypt"); const Schema = mongoose.Schema; -// email, firstname, lastname, ids for each service +const autoPopulateChildren = function(next) { + this.populate("children"); + next(); +}; // more id's per service const UserSchema = mongoose.Schema({ @@ -22,7 +25,11 @@ UserSchema.pre("save", async function(next) { const hash = await bcrypt.hashSync(user.password, 12); user.password = hash; next(); -}) +}); +UserSchema.pre("findOne", autoPopulateChildren).pre( + "find", + autoPopulateChildren +); module.exports = mongoose.model("User", UserSchema); diff --git a/public/assets/savonne.png b/public/assets/savonne.png new file mode 100644 index 0000000000000000000000000000000000000000..bae81744605e32a4bf7948b5dfe08b5d9ec98635 GIT binary patch literal 10764 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 C{=Q`Z literal 0 HcmV?d00001 diff --git a/public/javascripts/script.js b/public/javascripts/script.js new file mode 100644 index 0000000..d284f19 --- /dev/null +++ b/public/javascripts/script.js @@ -0,0 +1,12 @@ +$(() => { + $(".signup").hide(); + $(".side-section").on("click", ".register-link", function(e) { + $(".signin").hide(); + $(".signup").show(); + }); + + $(".side-section").on("click", ".login-link", function(e) { + $(".signin").show(); + $(".signup").hide(); + }); +}); diff --git a/public/styles/main.css b/public/styles/main.css new file mode 100644 index 0000000..3029d61 --- /dev/null +++ b/public/styles/main.css @@ -0,0 +1,156 @@ +@import url('https://fonts.googleapis.com/css?family=Quicksand:400,700'); +* { + box-sizing: border-box; + font-family: 'Quicksand', sans-serif; + margin: 0; + padding: 0; +} + +a, +a:hover, +a:focus { + text-decoration: none; + color: black; +} + +body { + background-color: #f6f6f6; +} + +input { + border: none; + background-color: #f6f6f6; + height: 40px; + margin-top: 10px; + padding-left: 20px; +} + +input::placeholder { + color: black; + font-family: 'Quicksand', sans-serif; + text-align: center; + padding-right: 20px; +} + +input:focus { + outline: none; + background-color: #f6f6f6; +} + +input:-webkit-autofill { + -webkit-box-shadow: 0 0 0px 1000px #f6f6f6 inset; +} + +p { + margin-bottom: 0; +} + +.fa { + margin-right: 20px; +} + +.main-header { + display: flex; + flex-direction: row; + width: 100%; + height: 150px; + background-color: white; +} + +.sub-header { + display: flex; + justify-content: center; + align-items: center; + width: 100%; + height: 50px; + margin-top: 3px; + background-color: white; +} + +.landing-page { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + width: 100%; + height: 90vh; +} + +.side-section { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 33.3%; + height: 100%; +} + +.side-section p { + margin-left: 15px; +} + +.dot { + font-weight: bold; +} + +.main-pic { + display: flex; + justify-content: center; + align-items: center; + width: 33.3%; + height: 100%; +} + +.signin-form { + display: flex; + flex-direction: column; + align-items: center; + width: 800px; + height: 250px; + background-color: white; + margin-top: 30px; +} + +.signup-form { + display: flex; + flex-direction: column; + align-items: center; + width: 800px; + height: 350px; + background-color: white; + margin-top: 30px; +} + +.signin-title { + margin-top: 20px; +} + +.footer-bar { + width: 100%; + height: 30px; + background-color: #282828; +} + +.line { + width: 7%; + background-color: black; + font-size: 1.1em; +} + +.input-group { + width: 30%; + display: flex; + flex-direction: column; +} + +.login-register-btn { + margin-top: 20px; + border: none; + font-family: 'Quicksand', sans-serif; + background-color: white; +} + +/*.money-img { + background: url(../assets/savonne.png) no-repeat center / cover; +} +*/ diff --git a/routes/index.js b/routes/index.js index b07b3f6..c6b3c4c 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,10 +2,7 @@ const router = require("express").Router(); const { users } = require("../controllers"); router.get("/", (req, res) => { - console.log("loop again?"); - // console.log("req.session", req.session); - if (req.user) { - console.log("inside redirect here???"); + if (req.isAuthenticated()) { return res.redirect("/ponzvert"); } diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index 1616b56..540e952 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -1,43 +1,34 @@ -

Register

- - {{#if user}} - - {{/if}} - -
- - -
- -
- - -
-
- - -
-
- - +
+ + + +
+
+ + +
+ + + + +
+ savonne
+ - - +
-

Login

-
-
- - -
-
- - -
- -
diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 5ad8da4..1024926 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -5,15 +5,73 @@ - + + + + -
- + + diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index 94e63f8..7343c90 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -5,8 +5,142 @@

Ponz Points™: ${{user.points}}

Your Ponzverts

-{{#if user.children.length}} +{{!-- {{#if user.children.length}} {{#each user.children as |child|}}
Points: ${{child.points}}, User: {{child.username}}, ponverted on {{child.timestamp}}
{{/each}} -{{/if}} +{{/if}} --}} + + + + From 889e6936593318f4017e1744d541408f7b4fc937 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 04:27:01 -0400 Subject: [PATCH 15/32] added css to input text --- public/styles/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/public/styles/main.css b/public/styles/main.css index 3029d61..86659f6 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -19,6 +19,7 @@ body { input { border: none; + font-family: 'Quicksand', sans-serif; background-color: #f6f6f6; height: 40px; margin-top: 10px; From 3b917c52a522aed89b3889fe46e9f6099a5f9bc2 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 04:34:06 -0400 Subject: [PATCH 16/32] fixed input position --- public/styles/main.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/styles/main.css b/public/styles/main.css index 86659f6..247868f 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -23,13 +23,14 @@ input { background-color: #f6f6f6; height: 40px; margin-top: 10px; - padding-left: 20px; + text-align: center; } input::placeholder { color: black; font-family: 'Quicksand', sans-serif; text-align: center; + padding-left: 20px; padding-right: 20px; } From 1569d68226217e55de862ffc40164313937fea06 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 04:57:00 -0400 Subject: [PATCH 17/32] updatd scripts --- public/javascripts/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/script.js b/public/javascripts/script.js index d284f19..087c62a 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -1,5 +1,5 @@ $(() => { - $(".signup").hide(); + $(".signin").hide(); $(".side-section").on("click", ".register-link", function(e) { $(".signin").hide(); $(".signup").show(); From 23a236de0bec769d6ed4c9454e423d9e16113fb4 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Thu, 17 Aug 2017 11:00:21 -0500 Subject: [PATCH 18/32] working on styling --- public/styles/main.css | 18 ++++++++++++++ views/layouts/main.handlebars | 10 ++++++-- views/partials/ponzvertPartial.handlebars | 10 ++++++++ views/ponzvert/index.handlebars | 29 +++++++++++++---------- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 views/partials/ponzvertPartial.handlebars diff --git a/public/styles/main.css b/public/styles/main.css index 247868f..d96ac58 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -11,6 +11,7 @@ a:hover, a:focus { text-decoration: none; color: black; + font-weight: bold; } body { @@ -152,6 +153,23 @@ p { background-color: white; } +money { + color: green; +} + +.hello { + display: block; + width: 100%; +} + +.test { + border: 1px solid black; + width: 100%; + display: flex; + justify-content: center; + align-items: center; +} + /*.money-img { background: url(../assets/savonne.png) no-repeat center / cover; } diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 1024926..9c77d68 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -44,7 +44,11 @@
- + {{#if user}} + + {{else}} + + {{/if}}

·

@@ -60,9 +64,11 @@
+
{{{body}}} -
+
+
hello
diff --git a/views/partials/ponzvertPartial.handlebars b/views/partials/ponzvertPartial.handlebars new file mode 100644 index 0000000..6047012 --- /dev/null +++ b/views/partials/ponzvertPartial.handlebars @@ -0,0 +1,10 @@ +{{#each children as |child|}} {{! Each item is an "li" }} +
  • +

    ${{child.points}} {{child.username}}

    + {{#if child.children.length}} {{! Within the context of the current item }} +
      + {{> ponzvertPartial children=child.children}} {{! Recursively render the partial }} +
    + {{/if}} +
  • +{{/each}} diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index 7343c90..51844c4 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,15 +1,20 @@ - -

    {{user.username}}

    -

    Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

    -

    Ponz Points™: ${{user.points}}

    +

    Hello {{user.username}}!

    +

    Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

    +

    Ponz Points™: ${{user.points}}

    Your Ponzverts

    -{{!-- {{#if user.children.length}} - {{#each user.children as |child|}} -
    Points: ${{child.points}}, User: {{child.username}}, ponverted on {{child.timestamp}}
    - {{/each}} -{{/if}} --}} + + +
      + {{> ponzvertPartial children=user.children}} +
    + + +
      + {{> ponzvertPartial}} +
    + @@ -18,9 +23,9 @@ // ************** Generate the tree diagram ***************** var margin = {top: 20, right: 120, bottom: 20, left: 120}, - width = 960 - margin.right - margin.left, + width = 960 - margin.right - margin.left + 4000, height = 500 - margin.top - margin.bottom; - + var i = 0, duration = 750, root; @@ -40,7 +45,7 @@ root = treeData[0]; root.x0 = height / 2; root.y0 = 0; - + update(root); d3.select(self.frameElement).style("height", "500px"); From f9bbc377ba6123f9d189110997412aca9e38d140 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 12:36:53 -0400 Subject: [PATCH 19/32] changing node colors --- public/assets/diamond.png | Bin 0 -> 5801 bytes public/styles/main.css | 29 +++++++++++++++--- views/layouts/main.handlebars | 2 +- views/partials/ponzvertPartial.handlebars | 2 +- views/ponzvert/index.handlebars | 35 ++++++++++++++-------- 5 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 public/assets/diamond.png diff --git a/public/assets/diamond.png b/public/assets/diamond.png new file mode 100644 index 0000000000000000000000000000000000000000..b3383f7c2900fbc096aecec61dbc87116268a430 GIT binary patch literal 5801 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 JN|dYv{{hc1zSIB! literal 0 HcmV?d00001 diff --git a/public/styles/main.css b/public/styles/main.css index d96ac58..e35515e 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -11,7 +11,6 @@ a:hover, a:focus { text-decoration: none; color: black; - font-weight: bold; } body { @@ -170,7 +169,29 @@ money { align-items: center; } -/*.money-img { - background: url(../assets/savonne.png) no-repeat center / cover; +.nested-line { + margin-right: 20px; +} + +.profile { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; + width: 100%; + height: 280px; + background-color: white; + margin-top: 30px; + margin-bottom: 30px; +} + +.crazy-boxes { + margin-top: 30px; +} + +.diamond { + margin-top: 20px; + width: 100px; + height: 100px; } -*/ diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 9c77d68..5eebfd5 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -14,7 +14,7 @@ .node circle { fill: #fff; - stroke: steelblue; +/* stroke: black;*/ stroke-width: 3px; } diff --git a/views/partials/ponzvertPartial.handlebars b/views/partials/ponzvertPartial.handlebars index 6047012..a9fcaed 100644 --- a/views/partials/ponzvertPartial.handlebars +++ b/views/partials/ponzvertPartial.handlebars @@ -1,6 +1,6 @@ {{#each children as |child|}} {{! Each item is an "li" }}
  • -

    ${{child.points}} {{child.username}}

    +

    ${{child.points}} {{child.username}}

    {{#if child.children.length}} {{! Within the context of the current item }}
      {{> ponzvertPartial children=child.children}} {{! Recursively render the partial }} diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index 51844c4..eceab97 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,20 +1,25 @@ +
      +

      Hello {{user.username}}!

      +

      Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

      -

      Hello {{user.username}}!

      -

      Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

      +

      Ponz Points™: ${{user.points}}

      +
      + diamond +
      +
      -

      Ponz Points™: ${{user.points}}

      -

      Your Ponzverts

      +
      +

      Your Ponzverts

      +
      -
        - {{> ponzvertPartial children=user.children}} -
      +
      +
        + {{> ponzvertPartial children=user.children}} +
      +
      -
        - {{> ponzvertPartial}} -
      - @@ -70,7 +75,7 @@ .on("click", click); nodeEnter.append("circle") - .attr("r", 1e-6) + .attr("stroke", "black") .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); nodeEnter.append("text") @@ -148,4 +153,10 @@ } update(d); } + + // Get random color + function randomColor() { + return '#' + Math.round(0xffffff * Math.random()).toString(16); + } + From c5a3b24d2ff86a0e0d8e6a1c27fada5f91007729 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Thu, 17 Aug 2017 12:15:06 -0500 Subject: [PATCH 20/32] trying color layers --- views/ponzvert/index.handlebars | 41 ++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index eceab97..1a8984f 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -56,6 +56,8 @@ d3.select(self.frameElement).style("height", "500px"); function update(source) { + let colorArray = makeColorArray(); + console.log(colorArray); // Compute the new tree layout. var nodes = tree.nodes(root).reverse(), @@ -75,7 +77,6 @@ .on("click", click); nodeEnter.append("circle") - .attr("stroke", "black") .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); nodeEnter.append("text") @@ -94,6 +95,16 @@ .attr("r", 10) .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); + // nodeUpdate.select("circle") + // .attr("fill", function(d) { + // return randomColorPostion(colorMat, d); + // } + // }) + nodeUpdate.select("circle") + .style("fill", function(d) { + return randomColorPosition(colorArray, d); + }); + nodeUpdate.select("text") .style("fill-opacity", 1); @@ -159,4 +170,32 @@ return '#' + Math.round(0xffffff * Math.random()).toString(16); } + function makeColorArray() { + console.log("doing this"); + let colorArray = []; + for(let i = 0; i < 10; i++) { colorArray.push(randomColor()) } + return colorArray; + } + + // function makeCorandomColorPositionlorMatrix() { + // console.log("doing this"); + // let colorMat = []; + // for(let i = 0; i < 10; i++) { + // colorMat.push([ + // Math.floor(Math.random() * 256), + // Math.floor(Math.random() * 256), + // Math.floor(Math.random() * 256) + // ]) + // } + // return colorMat; + // } + + function randomColorPosition(colorArray, d) { + console.log(colorArray[Math.floor(d.x) % 10]); + // console.log(typeof colorArray) + // console.log(colorArray) + // console.log(Math.floor(d.x) % 180); + return colorArray[Math.floor(d.x) % 10]; + } + From 1abc47cb17078b105444df9a4298783b6d317cc1 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 13:47:04 -0400 Subject: [PATCH 21/32] finished some styling --- public/styles/main.css | 32 ++++++++++++++++------- views/ponzvert/index.handlebars | 46 +++++++++++---------------------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/public/styles/main.css b/public/styles/main.css index e35515e..e22cab4 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -147,6 +147,7 @@ p { .login-register-btn { margin-top: 20px; + margin-bottom: 20px; border: none; font-family: 'Quicksand', sans-serif; background-color: white; @@ -157,18 +158,11 @@ money { } .hello { + margin-top: 25px; display: block; width: 100%; } -.test { - border: 1px solid black; - width: 100%; - display: flex; - justify-content: center; - align-items: center; -} - .nested-line { margin-right: 20px; } @@ -180,18 +174,38 @@ money { align-items: center; text-align: center; width: 100%; - height: 280px; + height: 180px; background-color: white; margin-top: 30px; margin-bottom: 30px; } .crazy-boxes { + display: flex; + justify-content: center; margin-top: 30px; + border-bottom: 5px solid white; + padding-bottom: 30px; +} + +.crazy-box div { + widows: 50%; } .diamond { margin-top: 20px; + margin-bottom: 20px; width: 100px; height: 100px; } + +.diamond img { + width: 50px; +} + +.svg-container { + width: 100%; + height: 550px; + overflow-x: scroll; + overflow-y: scroll; +} diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index 1a8984f..508ed19 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,6 +1,6 @@

      Hello {{user.username}}!

      -

      Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

      +

      Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

      Ponz Points™: ${{user.points}}

      @@ -14,12 +14,17 @@
      -
        - {{> ponzvertPartial children=user.children}} -
      +
      +
        + {{> ponzvertPartial children=user.children}} +
      +
      +
      - +
      + +
      @@ -28,7 +33,7 @@ // ************** Generate the tree diagram ***************** var margin = {top: 20, right: 120, bottom: 20, left: 120}, - width = 960 - margin.right - margin.left + 4000, + width = 960 - margin.right - margin.left, height = 500 - margin.top - margin.bottom; var i = 0, @@ -41,7 +46,8 @@ var diagonal = d3.svg.diagonal() .projection(function(d) { return [d.y, d.x]; }); - var svg = d3.select("body").append("svg") + var svg = d3.select(".svg-container").append("svg") + .attr("class", "animate-tree") .attr("width", width + margin.right + margin.left) .attr("height", height + margin.top + margin.bottom) .append("g") @@ -95,13 +101,8 @@ .attr("r", 10) .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); - // nodeUpdate.select("circle") - // .attr("fill", function(d) { - // return randomColorPostion(colorMat, d); - // } - // }) nodeUpdate.select("circle") - .style("fill", function(d) { + .style("stroke", function(d) { return randomColorPosition(colorArray, d); }); @@ -177,25 +178,8 @@ return colorArray; } - // function makeCorandomColorPositionlorMatrix() { - // console.log("doing this"); - // let colorMat = []; - // for(let i = 0; i < 10; i++) { - // colorMat.push([ - // Math.floor(Math.random() * 256), - // Math.floor(Math.random() * 256), - // Math.floor(Math.random() * 256) - // ]) - // } - // return colorMat; - // } - function randomColorPosition(colorArray, d) { - console.log(colorArray[Math.floor(d.x) % 10]); - // console.log(typeof colorArray) - // console.log(colorArray) - // console.log(Math.floor(d.x) % 180); - return colorArray[Math.floor(d.x) % 10]; + return colorArray[ d.depth % 10 ]; } From caa18e34824d8a4e23606ca4ca067138bb6d3e02 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Thu, 17 Aug 2017 13:38:01 -0500 Subject: [PATCH 22/32] trying to get flash messages up --- controllers/UserController.js | 4 ++++ index.js | 1 + routes/index.js | 9 +++++++-- views/landing/index.handlebars | 27 +++++++++++++++++++++------ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/controllers/UserController.js b/controllers/UserController.js index 3060590..38cd664 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -2,6 +2,7 @@ const { User } = require("../models"); const shortid = require("shortid"); const moment = require("moment"); + module.exports = { index: async (req, res) => { try { @@ -75,6 +76,7 @@ module.exports = { }); if (existingUser) { + req.session.message = "working good"; return res.json({ confirmation: "fail", message: "user already exists" @@ -93,6 +95,7 @@ module.exports = { // console.log("shortid: ", req.session.shortid); if (req.session.shortid) { createChildUser(req, res); + req.session.message = "working good"; return; } @@ -100,6 +103,7 @@ module.exports = { req.body.shortid = id; let user = await User.create(req.body); + req.session.message = "working good"; return res.redirect("/ponzvert"); } catch (e) { console.error(e.stack); diff --git a/index.js b/index.js index adbc6f7..0e2e88a 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); const flash = require("express-flash-messages"); +// const flash = require("express-flash"); app.use( session({ diff --git a/routes/index.js b/routes/index.js index c6b3c4c..b1b9663 100644 --- a/routes/index.js +++ b/routes/index.js @@ -5,8 +5,13 @@ router.get("/", (req, res) => { if (req.isAuthenticated()) { return res.redirect("/ponzvert"); } - - return res.render("landing/index"); + let shortid; + let message; + shortid = req.session.shortid; + message = req.session.message; + console.log(message); + console.log("flashMessage: ", req.flash('message')); + return res.render("landing/index", { shortid, message: req.flash('message') }); }); module.exports = router; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index 540e952..44af12b 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -3,6 +3,8 @@
      - +
      From 1a0043f5818f946d4cddb4aad3c5598c58a4f740 Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 16:00:02 -0400 Subject: [PATCH 23/32] added clear to referral and rainbow text --- public/styles/main.css | 173 +++++++++++++++++++++- routes/index.js | 12 +- views/landing/index.handlebars | 4 +- views/layouts/main.handlebars | 5 +- views/partials/ponzvertPartial.handlebars | 2 +- views/ponzvert/index.handlebars | 7 +- 6 files changed, 190 insertions(+), 13 deletions(-) diff --git a/public/styles/main.css b/public/styles/main.css index e22cab4..6850cab 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -153,6 +153,10 @@ p { background-color: white; } +.under-line { + text-decoration: underline; +} + money { color: green; } @@ -173,13 +177,18 @@ money { justify-content: center; align-items: center; text-align: center; - width: 100%; - height: 180px; + width: 45%; + margin: 0 auto; + height: 190px; background-color: white; margin-top: 30px; margin-bottom: 30px; } +.profile p { + margin-top: 10px; +} + .crazy-boxes { display: flex; justify-content: center; @@ -209,3 +218,163 @@ money { overflow-x: scroll; overflow-y: scroll; } + +@keyframes rainbow-text { + 0% { + color: #e87d7d; + } + 2% { + color: #e88a7d; + } + 4% { + color: #e8977d; + } + 6% { + color: #e8a47d; + } + 8% { + color: #e8b07d; + } + 10% { + color: #e8bd7d; + } + 12% { + color: #e8ca7d; + } + 14% { + color: #e8d77d; + } + 16% { + color: #e8e47d; + } + 18% { + color: #dfe87d; + } + 20% { + color: #d3e87d; + } + 22% { + color: #c6e87d; + } + 24% { + color: #b9e87d; + } + 26% { + color: #ace87d; + } + 28% { + color: #9fe87d; + } + 30% { + color: #92e87d; + } + 32% { + color: #86e87d; + } + 34% { + color: #7de881; + } + 36% { + color: #7de88e; + } + 38% { + color: #7de89b; + } + 40% { + color: #7de8a8; + } + 42% { + color: #7de8b5; + } + 44% { + color: #7de8c1; + } + 46% { + color: #7de8ce; + } + 48% { + color: #7de8db; + } + 50% { + color: #7de8e8; + } + 52% { + color: #7ddbe8; + } + 54% { + color: #7dcee8; + } + 56% { + color: #7dc1e8; + } + 58% { + color: #7db5e8; + } + 60% { + color: #7da8e8; + } + 62% { + color: #7d9be8; + } + 64% { + color: #7d8ee8; + } + 66% { + color: #7d81e8; + } + 68% { + color: #867de8; + } + 70% { + color: #927de8; + } + 72% { + color: #9f7de8; + } + 74% { + color: #ac7de8; + } + 76% { + color: #b97de8; + } + 78% { + color: #c67de8; + } + 80% { + color: #d37de8; + } + 82% { + color: #df7de8; + } + 84% { + color: #e87de4; + } + 86% { + color: #e87dd7; + } + 88% { + color: #e87dca; + } + 90% { + color: #e87dbd; + } + 92% { + color: #e87db0; + } + 94% { + color: #e87da4; + } + 96% { + color: #e87d97; + } + 98% { + color: #e87d8a; + } + 100% { + color: #e87d7d; + } +} + +.rainbow-text { + animation: rainbow-text 6s infinite 0s, rainbow-text 4s infinite 2s; +} diff --git a/routes/index.js b/routes/index.js index b1b9663..5d8fa59 100644 --- a/routes/index.js +++ b/routes/index.js @@ -10,8 +10,16 @@ router.get("/", (req, res) => { shortid = req.session.shortid; message = req.session.message; console.log(message); - console.log("flashMessage: ", req.flash('message')); - return res.render("landing/index", { shortid, message: req.flash('message') }); + console.log("flashMessage: ", req.flash("message")); + return res.render("landing/index", { + shortid, + message: req.flash("message") + }); +}); + +router.get("/clear", (req, res) => { + req.session.shortid = null; + res.redirect("/"); }); module.exports = router; diff --git a/views/landing/index.handlebars b/views/landing/index.handlebars index 44af12b..242c7f2 100644 --- a/views/landing/index.handlebars +++ b/views/landing/index.handlebars @@ -16,7 +16,6 @@ - {{#if message}}

      {{message}}

      @@ -29,7 +28,8 @@ {{flash}} {{#if shortid}} -

      Referral: {{shortid}}

      +

      Referral ID: {{shortid}}

      +

      clear referral

      {{/if}}
      diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 5eebfd5..8bb1d2d 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -40,7 +40,7 @@
      -

      PONZE.IO

      +

      PONZE.IO

      @@ -62,14 +62,13 @@ -
      {{{body}}}
      -
      +
      hello
      diff --git a/views/partials/ponzvertPartial.handlebars b/views/partials/ponzvertPartial.handlebars index a9fcaed..457992c 100644 --- a/views/partials/ponzvertPartial.handlebars +++ b/views/partials/ponzvertPartial.handlebars @@ -1,6 +1,6 @@ {{#each children as |child|}} {{! Each item is an "li" }}
    • -

      ${{child.points}} {{child.username}}

      +

      {{child.points}}pz {{child.username}}

      {{#if child.children.length}} {{! Within the context of the current item }}
        {{> ponzvertPartial children=child.children}} {{! Recursively render the partial }} diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index 508ed19..bf36e24 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -1,15 +1,16 @@

        Hello {{user.username}}!

        -

        Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

        -

        Ponz Points™: ${{user.points}}

        +

        Your referral link is http://localhost:3000/ponzvert/{{user.shortid}}

        + +

        Ponz Points™: {{user.points}}pz

        diamond
        -

        Your Ponzverts

        +

        Your Stats

        From db2e5431924edec09d7c2f6018b8f01e1c47c5c3 Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Thu, 17 Aug 2017 15:54:46 -0500 Subject: [PATCH 24/32] pyramid stuff work --- controllers/UserController.js | 7 ++++ public/styles/main.css | 11 ++++-- routes/index.js | 4 +++ views/layouts/main.handlebars | 2 +- views/ponzvert/index.handlebars | 37 ++++++++++++-------- views/scheme/index.js | 62 +++++++++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 views/scheme/index.js diff --git a/controllers/UserController.js b/controllers/UserController.js index 38cd664..932e8c2 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -67,6 +67,13 @@ module.exports = { } }, + // viewScheme: async (req, res) => { + // let data = [ { + // key]; + // + // return res.render("scheme/index", ) + // }, + createUser: async (req, res) => { // check if user exists let existingUser; diff --git a/public/styles/main.css b/public/styles/main.css index 6850cab..d66237b 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -213,12 +213,19 @@ money { } .svg-container { - width: 100%; - height: 550px; + /*width: 100%;*/ + height: 900px; + width: 1000px; overflow-x: scroll; overflow-y: scroll; } +svg { + display: block; + width: 1000px; + height: 100%; +} + @keyframes rainbow-text { 0% { color: #e87d7d; diff --git a/routes/index.js b/routes/index.js index 5d8fa59..21d1d31 100644 --- a/routes/index.js +++ b/routes/index.js @@ -22,4 +22,8 @@ router.get("/clear", (req, res) => { res.redirect("/"); }); +router.get("/scheme", (req, res) => { + res.render("scheme/index") +}) + module.exports = router; diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 8bb1d2d..a673446 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -36,7 +36,7 @@

        ·

        -

        scheme

        +

        scheme

  • diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index bf36e24..a610c43 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -20,11 +20,11 @@ {{> ponzvertPartial children=user.children}}
    - +
    - +
    @@ -63,8 +63,18 @@ d3.select(self.frameElement).style("height", "500px"); function update(source) { - let colorArray = makeColorArray(); - console.log(colorArray); + let colorArray = [ + "#e87d7d", + "#e8bd7d", + "#d3e87d", + "#92e87d", + "#7de8a8", + "#7de8e8", + "#7da8e8", + "#927de8", + "#d37de8", + "#e87dbd" + ] // Compute the new tree layout. var nodes = tree.nodes(root).reverse(), @@ -167,20 +177,17 @@ update(d); } - // Get random color - function randomColor() { - return '#' + Math.round(0xffffff * Math.random()).toString(16); - } - - function makeColorArray() { - console.log("doing this"); - let colorArray = []; - for(let i = 0; i < 10; i++) { colorArray.push(randomColor()) } - return colorArray; - } function randomColorPosition(colorArray, d) { + printKeyValues(d); return colorArray[ d.depth % 10 ]; } + function printKeyValues(d) { + let keys = Object.keys(d) + keys.forEach((key) => { + console.log(key, d[key]); + }) + } + diff --git a/views/scheme/index.js b/views/scheme/index.js new file mode 100644 index 0000000..60451e5 --- /dev/null +++ b/views/scheme/index.js @@ -0,0 +1,62 @@ +< script src = "http://d3js.org/d3.v3.min.js" > +< script > var width = 700, + height = 450, + radius = Math.min(width, height) / 2; + +var color = d3.scale.ordinal().range([ + "#255aee", + "#3a6fff", + "#4f84ff", + "rgb(101,154,302)", + "rgb(122,175,323)", + "rgb(144,197,345)", + "rgb(165,218,366)" +]); + +var svg = d3.select("body").append("svg").attr("width", width).attr("height", height).append("g") + +d3.csv("data.csv", function(error, data) { + var pyramid = d3.pyramid().size([width, height]).value(function(d) { + return d.population; + }); + + var line = d3.svg.line().interpolate('linear-closed').x(function(d, i) { + return d.x; + }).y(function(d, i) { + return d.y; + }); + + var g = svg.selectAll(".pyramid-group").data(pyramid(data)).enter().append("g").attr("class", "pyramid-group"); + + g.append("path").attr("d", function(d) { + return line(d.coordinates); + }).style("fill", function(d) { + return color(d.region); + }); + + g.append("text").attr({ + "y": function(d, i) { + if (d.coordinates.length === 4) { + return (((d.coordinates[0].y - d.coordinates[1].y) / 2) + d.coordinates[1].y) + 5; + } else { + return (d.coordinates[0].y + d.coordinates[1].y) / 2 + 10; + } + }, + "x": function(d, i) { + return width / 2; + } + }).style("text-anchor", "middle").text(function(d) { + return d.region; + }); + + d3.select("body").append("table").attr({ + "id": "footer", + "width": width + "px" + }) + + d3.select("body #footer").append("tr").attr({"class": "PykCharts-credits", "id": "credit-datasource"}).append("td").style("text-align", "left").html("Credits: " + + "Pykcharts" + + ""); + +}); + From 00c038546161f88ab28c7547711c2b394f8afaba Mon Sep 17 00:00:00 2001 From: Benjamin Soung Date: Thu, 17 Aug 2017 17:39:24 -0400 Subject: [PATCH 25/32] got d3 overflow working --- public/styles/main.css | 11 +++--- views/ponzvert/index.handlebars | 44 ++++++++++++++++++++--- views/scheme/index.handlebars | 1 + views/scheme/index.js | 62 --------------------------------- 4 files changed, 46 insertions(+), 72 deletions(-) create mode 100644 views/scheme/index.handlebars delete mode 100644 views/scheme/index.js diff --git a/public/styles/main.css b/public/styles/main.css index d66237b..adef3b7 100644 --- a/public/styles/main.css +++ b/public/styles/main.css @@ -213,17 +213,16 @@ money { } .svg-container { - /*width: 100%;*/ - height: 900px; - width: 1000px; + /* width: 100%;*/ + height: 100%; + width: 100%; overflow-x: scroll; overflow-y: scroll; } svg { - display: block; - width: 1000px; - height: 100%; + display: block; + height: 100%; } @keyframes rainbow-text { diff --git a/views/ponzvert/index.handlebars b/views/ponzvert/index.handlebars index a610c43..0821b97 100644 --- a/views/ponzvert/index.handlebars +++ b/views/ponzvert/index.handlebars @@ -10,7 +10,7 @@
    -

    Your Stats

    +

    Your Ponzverts

    @@ -33,6 +33,8 @@ var treeData = {{{toJSON tree}}}; // ************** Generate the tree diagram ***************** + var svgWidth = 960; + var margin = {top: 20, right: 120, bottom: 20, left: 120}, width = 960 - margin.right - margin.left, height = 500 - margin.top - margin.bottom; @@ -60,10 +62,25 @@ update(root); - d3.select(self.frameElement).style("height", "500px"); + d3.select(self.frameElement) + .style("height", "900px") + + + + // d3.select("div#chartId") + // .append("div") + // .classed("svg-container", true) //container class to make it responsive + // .append("svg") + // //responsive SVG needs these 2 attributes and no width and height attr + // .attr("preserveAspectRatio", "xMinYMin meet") + // .attr("viewBox", "0 0 600 400") + // //class to make it responsive + // .classed("svg-content-responsive", true); function update(source) { - let colorArray = [ + + + var colorArray = [ "#e87d7d", "#e8bd7d", "#d3e87d", @@ -108,6 +125,17 @@ .duration(duration) .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }); + nodeUpdate.select("circle") + .attr("y", function(d) { + svgWidth = Math.max(svgWidth, d.y); + + + console.log(svgWidth, 'what is svg width') + + console.log(svg, 'what is svg') + console.log(d, '???') + }) + nodeUpdate.select("circle") .attr("r", 10) .style("fill", function(d) { return d._children ? "lightsteelblue" : "#fff"; }); @@ -163,6 +191,11 @@ d.x0 = d.x; d.y0 = d.y; }); + + svg = d3.select("svg") + .attr("class", "animate-tree") + .attr("width", (svgWidth + 200) + margin.right + margin.left) + .attr("height", height + margin.top + margin.bottom) } // Toggle children on click. @@ -177,9 +210,12 @@ update(d); } + function resize(previous, current) { + + } function randomColorPosition(colorArray, d) { - printKeyValues(d); + // printKeyValues(d); return colorArray[ d.depth % 10 ]; } diff --git a/views/scheme/index.handlebars b/views/scheme/index.handlebars new file mode 100644 index 0000000..123e83f --- /dev/null +++ b/views/scheme/index.handlebars @@ -0,0 +1 @@ +

    Scheme!!!! >:)

    diff --git a/views/scheme/index.js b/views/scheme/index.js deleted file mode 100644 index 60451e5..0000000 --- a/views/scheme/index.js +++ /dev/null @@ -1,62 +0,0 @@ -< script src = "http://d3js.org/d3.v3.min.js" > -< script > var width = 700, - height = 450, - radius = Math.min(width, height) / 2; - -var color = d3.scale.ordinal().range([ - "#255aee", - "#3a6fff", - "#4f84ff", - "rgb(101,154,302)", - "rgb(122,175,323)", - "rgb(144,197,345)", - "rgb(165,218,366)" -]); - -var svg = d3.select("body").append("svg").attr("width", width).attr("height", height).append("g") - -d3.csv("data.csv", function(error, data) { - var pyramid = d3.pyramid().size([width, height]).value(function(d) { - return d.population; - }); - - var line = d3.svg.line().interpolate('linear-closed').x(function(d, i) { - return d.x; - }).y(function(d, i) { - return d.y; - }); - - var g = svg.selectAll(".pyramid-group").data(pyramid(data)).enter().append("g").attr("class", "pyramid-group"); - - g.append("path").attr("d", function(d) { - return line(d.coordinates); - }).style("fill", function(d) { - return color(d.region); - }); - - g.append("text").attr({ - "y": function(d, i) { - if (d.coordinates.length === 4) { - return (((d.coordinates[0].y - d.coordinates[1].y) / 2) + d.coordinates[1].y) + 5; - } else { - return (d.coordinates[0].y + d.coordinates[1].y) / 2 + 10; - } - }, - "x": function(d, i) { - return width / 2; - } - }).style("text-anchor", "middle").text(function(d) { - return d.region; - }); - - d3.select("body").append("table").attr({ - "id": "footer", - "width": width + "px" - }) - - d3.select("body #footer").append("tr").attr({"class": "PykCharts-credits", "id": "credit-datasource"}).append("td").style("text-align", "left").html("Credits: " + - "Pykcharts" + - ""); - -}); - From d6bd769cff74b03d48f637e06732076c292af84b Mon Sep 17 00:00:00 2001 From: Alex-Willenbrink Date: Thu, 17 Aug 2017 17:04:03 -0500 Subject: [PATCH 26/32] sockets are up and running --- auth/passport.js | 6 +- controllers/UserController.js | 18 +- index.js | 24 ++- package-lock.json | 328 ++++++++++++++++++++++++++++++++ package.json | 4 +- public/javascripts/script.js | 6 + routes/index.js | 4 +- views/layouts/main.handlebars | 2 + views/ponzvert/index.handlebars | 10 +- views/scheme/index.handlebars | 1 - 10 files changed, 368 insertions(+), 35 deletions(-) delete mode 100644 views/scheme/index.handlebars diff --git a/auth/passport.js b/auth/passport.js index 0ef2936..1d866ce 100644 --- a/auth/passport.js +++ b/auth/passport.js @@ -33,8 +33,7 @@ module.exports = function(passport) { if (!user) return done( null, - false, - req.flash("loginMessage", "No user found.") + false ); // req.flash is the way to set flashdata using connect-flash // if the user is found but the password is wrong console.log("input password", password); @@ -46,8 +45,7 @@ module.exports = function(passport) { if (!bcrypt.compareSync(password, user.password)) return done( null, - false, - req.flash("loginMessage", "Oops! Wrong password.") + false ); // create the loginMessage and save it to session as flashdata // all is well, return successful user return done(null, user); diff --git a/controllers/UserController.js b/controllers/UserController.js index 932e8c2..03b5819 100644 --- a/controllers/UserController.js +++ b/controllers/UserController.js @@ -67,13 +67,6 @@ module.exports = { } }, - // viewScheme: async (req, res) => { - // let data = [ { - // key]; - // - // return res.render("scheme/index", ) - // }, - createUser: async (req, res) => { // check if user exists let existingUser; @@ -83,11 +76,8 @@ module.exports = { }); if (existingUser) { - req.session.message = "working good"; - return res.json({ - confirmation: "fail", - message: "user already exists" - }); + req.session.message = "User Already Exists"; + return res.redirect("/"); } } catch (e) { return res.json({ @@ -99,10 +89,9 @@ module.exports = { // create our user with random id try { // registering for another user - // console.log("shortid: ", req.session.shortid); + req.session.message = "You are Registered!"; if (req.session.shortid) { createChildUser(req, res); - req.session.message = "working good"; return; } @@ -110,7 +99,6 @@ module.exports = { req.body.shortid = id; let user = await User.create(req.body); - req.session.message = "working good"; return res.redirect("/ponzvert"); } catch (e) { console.error(e.stack); diff --git a/index.js b/index.js index 0e2e88a..882e73e 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,13 @@ const bodyParser = require("body-parser"); const exphbs = require("express-handlebars"); const session = require("express-session"); const passport = require("passport"); -const flash = require("express-flash-messages"); -// const flash = require("express-flash"); +const server = require("http").createServer(app); + + + +const io = require("socket.io")(server); +app.use("/socket.io", express.static(__dirname + "node_modules/socket.io-client/dist/")); +console.log(__dirname, "node_modules/socket.io-client/dist/"); app.use( session({ @@ -19,7 +24,6 @@ app.use( app.use(passport.initialize()); app.use(passport.session()); -app.use(flash()); const mongoose = require("mongoose"); const Promise = require("bluebird"); @@ -87,7 +91,19 @@ app.post( }) ); + +io.on('connection', client => { + _client = client; + // update(client); + + // client.on("test", (data) => { + // client.emit("happyStuff", "sfjfjf"); + // } + client.emit("happyStuff", "sfjfjf"); + +}) + // listen to server -app.listen(3000, () => { +server.listen(3000, () => { console.log(`Listening at port 3000`); }); diff --git a/package-lock.json b/package-lock.json index 1cd95ad..b77672a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,11 @@ "negotiator": "0.6.1" } }, + "after": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", + "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=" + }, "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", @@ -66,6 +71,11 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "arraybuffer.slice": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", + "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=" + }, "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -101,11 +111,26 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, + "base64id": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", + "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=" + }, "basic-auth": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.1.0.tgz", @@ -130,11 +155,24 @@ "tweetnacl": "0.14.5" } }, + "better-assert": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", + "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", + "requires": { + "callsite": "1.0.0" + } + }, "bindings": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.2.1.tgz", "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" }, + "blob": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", + "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=" + }, "block-stream": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", @@ -212,6 +250,11 @@ "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=" }, + "callsite": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", + "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=" + }, "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", @@ -270,6 +313,21 @@ "delayed-stream": "1.0.0" } }, + "component-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", + "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=" + }, + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=" + }, + "component-inherit": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", + "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -410,6 +468,81 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" }, + "engine.io": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.0.tgz", + "integrity": "sha1-XKQ4486f28kVxKIcjdnhJmcG5X4=", + "requires": { + "accepts": "1.3.3", + "base64id": "1.0.0", + "cookie": "0.3.1", + "debug": "2.6.8", + "engine.io-parser": "2.1.1", + "uws": "0.14.5", + "ws": "2.3.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "engine.io-client": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.1.tgz", + "integrity": "sha1-QVqYUrrbFPoAj6PvHjFgjbZ2EyU=", + "requires": { + "component-emitter": "1.2.1", + "component-inherit": "0.0.3", + "debug": "2.6.8", + "engine.io-parser": "2.1.1", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "parsejson": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "ws": "2.3.1", + "xmlhttprequest-ssl": "1.5.3", + "yeast": "0.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "engine.io-parser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.1.tgz", + "integrity": "sha1-4Ps/DgRi9/WLt3waUun1p+JuRmg=", + "requires": { + "after": "0.8.2", + "arraybuffer.slice": "0.0.6", + "base64-arraybuffer": "0.1.5", + "blob": "0.0.4", + "has-binary2": "1.0.2" + } + }, "es6-promise": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz", @@ -715,6 +848,26 @@ "har-schema": "1.0.5" } }, + "has-binary2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.2.tgz", + "integrity": "sha1-6D26SfC5vk0CbSc2U1DZ8D9Uvpg=", + "requires": { + "isarray": "2.0.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + } + } + }, + "has-cors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", + "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=" + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -767,6 +920,11 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=" }, + "indexof": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=" + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -1166,6 +1324,11 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, + "object-component": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", + "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=" + }, "object-keys": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", @@ -1211,6 +1374,30 @@ "wordwrap": "0.0.3" } }, + "parsejson": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz", + "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=", + "requires": { + "better-assert": "1.0.2" + } + }, + "parseqs": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", + "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", + "requires": { + "better-assert": "1.0.2" + } + }, + "parseuri": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", + "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", + "requires": { + "better-assert": "1.0.2" + } + }, "parseurl": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", @@ -1501,6 +1688,105 @@ "hoek": "2.16.3" } }, + "socket.io": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.3.tgz", + "integrity": "sha1-Q1nwaiSTOua9CHeYr3jGgOrjReM=", + "requires": { + "debug": "2.6.8", + "engine.io": "3.1.0", + "object-assign": "4.1.1", + "socket.io-adapter": "1.1.1", + "socket.io-client": "2.0.3", + "socket.io-parser": "3.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "socket.io-adapter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz", + "integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs=" + }, + "socket.io-client": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.3.tgz", + "integrity": "sha1-bK9K/5+FsZ/ZG2zhPWmttWT4hzs=", + "requires": { + "backo2": "1.0.2", + "base64-arraybuffer": "0.1.5", + "component-bind": "1.0.0", + "component-emitter": "1.2.1", + "debug": "2.6.8", + "engine.io-client": "3.1.1", + "has-cors": "1.1.0", + "indexof": "0.0.1", + "object-component": "0.0.3", + "parseqs": "0.0.5", + "parseuri": "0.0.5", + "socket.io-parser": "3.1.2", + "to-array": "0.1.4" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, + "socket.io-parser": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.2.tgz", + "integrity": "sha1-28IoIVH8T6675Aru3Ady66YZ9/I=", + "requires": { + "component-emitter": "1.2.1", + "debug": "2.6.8", + "has-binary2": "1.0.2", + "isarray": "2.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "requires": { + "ms": "2.0.0" + } + }, + "isarray": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz", + "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4=" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", @@ -1626,6 +1912,11 @@ } } }, + "to-array": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", + "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=" + }, "tough-cookie": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", @@ -1695,6 +1986,11 @@ "random-bytes": "1.0.0" } }, + "ultron": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.0.tgz", + "integrity": "sha1-sHoualQagV/Go0zNRTO67DB8qGQ=" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -1715,6 +2011,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" }, + "uws": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/uws/-/uws-0.14.5.tgz", + "integrity": "sha1-Z6rzPEaypYel9mZtAPdpEyjxSdw=", + "optional": true + }, "vary": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.1.tgz", @@ -1761,6 +2063,27 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "ws": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz", + "integrity": "sha1-a5Sz5EfLajY/eF6vlK9jWejoHIA=", + "requires": { + "safe-buffer": "5.0.1", + "ultron": "1.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", + "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=" + } + } + }, + "xmlhttprequest-ssl": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", + "integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=" + }, "yargs": { "version": "3.10.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", @@ -1772,6 +2095,11 @@ "decamelize": "1.2.0", "window-size": "0.1.0" } + }, + "yeast": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", + "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" } } } diff --git a/package.json b/package.json index fb373d5..5217dca 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,8 @@ "morgan": "^1.8.2", "passport": "^0.4.0", "passport-local": "^1.0.0", - "shortid": "^2.2.8" + "shortid": "^2.2.8", + "socket.io": "^2.0.3", + "socket.io-client": "^2.0.3" } } diff --git a/public/javascripts/script.js b/public/javascripts/script.js index 087c62a..36a66ad 100644 --- a/public/javascripts/script.js +++ b/public/javascripts/script.js @@ -9,4 +9,10 @@ $(() => { $(".signin").show(); $(".signup").hide(); }); + + const socket = io.connect('http://localhost:3000'); + + socket.on('happyStuff', (data) => { + console.log(data); + }); }); diff --git a/routes/index.js b/routes/index.js index 21d1d31..40dfa5c 100644 --- a/routes/index.js +++ b/routes/index.js @@ -10,10 +10,8 @@ router.get("/", (req, res) => { shortid = req.session.shortid; message = req.session.message; console.log(message); - console.log("flashMessage: ", req.flash("message")); return res.render("landing/index", { - shortid, - message: req.flash("message") + shortid }); }); diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index a673446..557d58a 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -7,6 +7,8 @@ + +