diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c6fe1903 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +env.sh \ No newline at end of file diff --git a/.glitch-assets b/.glitch-assets new file mode 100644 index 00000000..e69de29b diff --git a/API.js b/API.js new file mode 100644 index 00000000..a1d2c55e --- /dev/null +++ b/API.js @@ -0,0 +1,45 @@ +const { MongoClient } = require("mongodb"); +const ObjectID = require('mongodb').ObjectID; + +const host = process.env.MONGODB_HOST +const user = process.env.MONGODB_USER +const password = process.env.MONGODB_PASSWORD +const database = process.env.MONGODB_DATABASE + +const uri = `mongodb+srv://${user}:${password}@${host}/${database}?retryWrites=true&w=majority` + +const client = new MongoClient(uri); +client.connect() + + + +// This block of code is for inserting records into the DB. + +// try { +// client.connect() +// .then(() => { +// let words = +// // "aerobics, archer, arena, arrow, athlete, badminton, ball, baseball, baseball bat, basketball, baton, batter, bicycle, bike, biker, billiards, bobsleigh, boomerang, bow, bowling, boxing, canoe, cathcer, chest plate, club, coach, competitor, curling, cyclist, dartboard, darts, deadlifting, diving, dodgeball, dugout, dumbbell, e-sports, end zone, exercise, fencing, field, field hockey, figure skating, finish, fitness, football, formula one, free throw, frisbee, goal, goalie, golf, gym, gymnast, half time, hammer throw, handball, hang gliding, hardball, helmet, high jump, hole in one, home run, home team, hurdle, ice hockey, ice skating, jogging, judo, jump rope, karate, keeper, kitesurfing, kneepads, kung fu, lacrosse, lawn bowling, loser, marathon, nascar, off season, offside, olympics, overtime, penalty, ping pong, pit crew, pit stop, pitcher, pole vault, puck, race, rafting, rally, referee, rock climbing, roller derby, roller skating, rugby, sailing, score, shoulder pad, ski, snorkeling, snowboarding, soccer, softball, somersault, stadium, start, studded shoes, sumo wrestling, surfing, swimming, synchronized swimming, table tennis, target, team, teammate, tee, tennis racket, trampoline, triathlon, tug of war, ultramarathon, volley ball, wakeboarding, water polo, water ski, weightlifting, wetsuit, windsurfing, winner, yoga" +// //"apple, apple juice, apple pie, apple sauce, asparagus, avocado, bacon, bagel, baguette, baked beans, baked potato, banana, banana bread, banana split, barbecue sauce, bean, beer, beet, bell pepper, biscuit, blackberry, blueberry, bread, broccoli, brownie, bubblegum, burrito, butter, cabbage, cake, candy necklace, caramel apple, carrot, cauliflower, caviar, celery, cereal, cheese, cheeseburger, cheesecake, cherry, chicken burger, chicken nugget, chili, chocolate, chocolate bunny, chocolate cake, chocolate egg, chocolate milk, churro, citrus, cocktail, coffee, cookie, corn, corn dog, cotton candy, crab stick, cranberry, croissant, cucumber, cupcake, curry, donut, egg, energy drink, fish and chips, fish burger ,fish sauce, fondue, french fries, french toast, frog butt, fruitcake, garlic, garlic bread, grape, grapefruit, gravy, grilled cheese, grilled chicken, guacamole, gummy bear, gummy worm, ham, hamburger, hash brown, honey, hot chocolate, hot dog, hot sauce, ice cream, ice cream cake, ice cube, iced tea, jalapeno, jam, jawbreaker, jelly, kebab, ketchup, kiwi, lamb chops, lasagna, lemon, lemonade, lettuce, lime, liquorish, lollipop, mac and cheese, macaroni, maple syrup, margarine, martini, mashed potatoes, mayonnaise, meatball, meatloaf, melon, milk, milkshake, monkey brain, mushroom, mustard, nacho, noodle, olive, omelet, onion, onion ring, orange, orange juice, oyster sauce, pancake, papaya, peach, peanut butter, pear, peas, pepper, pepperoni, pickle, pie, pigs in a blanket, pineapple, pizza, plum, pomegranate, popcorn, popcorn chicken, potato, potato chip, prawn cracker, pretzel, prune, pudding, pumpkin pie, radish, raisin, ranch sauce, raspberry, ravioli, relish, rice, salsa, salt, sandwich, sausage, scrambled egg, shrimp, smoothie, soda, soup, space cake, spaghetti, spare ribs, sprout, star fruit, steak, strawberry, stroop waffle, stuffing, sugar, sushi, sweet potato, taco, tail fin soup, tangerine, tea, toast, tomato, turkey, turnip, vodka, waffle, wasabi, watermelon, whipped cream, whiskey, wine, yogurt" +// let wordArr = words.split(", ") +// let docs = [] +// for(let i = 0; i < wordArr.length; i++) { +// let doc = {word: wordArr[i]} +// docs.push(doc) +// } +// client.db("a4-webware").collection("words").insertMany(docs) + +// }) +// } catch(e) { +// console.log(e) +// } + + +// Get the specified number of words from the db +const getWords = function(num) { + var queryDoc = {}; + + return client.db("a4-webware").collection("words").aggregate([{ $sample: { size: num } }]).toArray(); +} + +exports.getWords = getWords; \ No newline at end of file diff --git a/README.md b/README.md index 3ac96956..c59420e3 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,14 @@ -Assignment 4 - Creative Coding: Interactive Multimedia Experiences -=== +## Drawing App -Due: October 9th, by 11:59 PM. +Sam Moran -For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies; the server requirements are minimal. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser. +Glitch Link: https://a4-sam-moran.glitch.me/ -Baseline Requirements ---- +My project is based on the same idea as Skribbl.io. It is a multiplayer game where one player is given a word to draw, and the other players have to guess the word based on the drawing. +I used WebSockets to communicate between clients and the server and synchronize state in near-realtime. This was a difficult task because I had to synchronize both the internal state of +the server and all clients, as well as the UI state of the clients, with very low latency so that the game plays smoothly. I mostly accomplished this; the one major feature I didn't have +time to figure out is changing the player who is in control of starting the game when the current player in control disconnects. Aside from that, the game works as expected and intended! +Have fun! -Your application is required to implement the following functionalities: - -- A server created using Express. This server can be as simple as needed. -- A client-side interactive experience using at least one of the following web technologies frameworks. - - [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences - - [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations - - [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers - - [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML. - - [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback. -- A user interface for interaction with your project, which must expose at least six parameters for user control. [dat.gui](https://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage) is highly recommended for this. You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that mouse and touch events will both be supported in your app. -- Your application should display basic documentation for the user interface when the application first loads. This documentation should be dismissable, however, users should be able to redisplay it via either a help buton (this could, for example, be inside a dat.gui interface) or via a keyboard shortcut (commonly the question mark). -- Your HTML and CSS should validate. There are options/plugins for most IDEs to check validation. - -The interactive experience should possess a reasonable level of complexity. Some examples: -### Three.js -- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents. -- A simple 3D game -- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization. -### Canvas -- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using ; we'll be checking to ensure that your implementation is not a copy of these. -- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience. -### Web Audio API -- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. -### D3.js -- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users. - -Deliverables ---- - -Do the following to complete this assignment: - -1. Implement your project with the above requirements. -3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly. -4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it. -5. Fork this repository and modify the README to the specifications below. *NOTE: If you don't use Glitch for hosting (where we can see the files) then you must include all project files that you author in your repo for this assignment*. -6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`. - -Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions) ---- - -## Your Web Application Title - -your hosting link e.g. http://a4-charlieroberts.glitch.me - -Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include: - -- the goal of the application -- challenges you faced in realizing the application -- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here. +You will need at least 2 players connected in order to start the game. Only 1 player can draw at a time. If the leader (player in control of starting the game) disconnects before the game +starts, the server must be restarted, else the game will be unable to be started. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..5950b5fb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,719 @@ +{ + "name": "a4-creative-coding", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=" + }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "bl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz", + "integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==", + "requires": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "bson": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.5.tgz", + "integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg==" + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "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=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "denque": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.4.1.tgz", + "integrity": "sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==" + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "ejs": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.5.tgz", + "integrity": "sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==", + "requires": { + "jake": "^10.6.1" + } + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "express-ws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/express-ws/-/express-ws-4.0.0.tgz", + "integrity": "sha512-KEyUw8AwRET2iFjFsI1EJQrJ/fHeGiJtgpYgEWG3yDv4l/To/m3a2GaYfeGyB3lsWdvbesjF5XCMx+SVBgAAYw==", + "requires": { + "ws": "^5.2.0" + }, + "dependencies": { + "ws": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "requires": { + "async-limiter": "~1.0.0" + } + } + } + }, + "filelist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz", + "integrity": "sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jake": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz", + "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==", + "requires": { + "async": "0.9.x", + "chalk": "^2.4.2", + "filelist": "^1.0.1", + "minimatch": "^3.0.4" + } + }, + "kareem": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", + "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "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.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.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.7" + } + }, + "mongodb": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.2.tgz", + "integrity": "sha512-sSZOb04w3HcnrrXC82NEh/YGCmBuRgR+C1hZgmmv4L6dBz4BkRse6Y8/q/neXer9i95fKUBbFi4KgeceXmbsOA==", + "requires": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "require_optional": "^1.0.1", + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" + } + }, + "mongoose": { + "version": "5.10.9", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.10.9.tgz", + "integrity": "sha512-7dkr1d6Uyk87hELzoc6B7Zo7kkPTx8rKummk51Y0je2V2Ttsw0KFPwTp1G8JIbBta7Wpw8j15PJi0d33Ode2nw==", + "requires": { + "bson": "^1.1.4", + "kareem": "2.3.1", + "mongodb": "3.6.2", + "mongoose-legacy-pluralize": "1.0.2", + "mpath": "0.7.0", + "mquery": "3.2.2", + "ms": "2.1.2", + "regexp-clone": "1.0.0", + "safe-buffer": "5.2.1", + "sift": "7.0.1", + "sliced": "1.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } + } + }, + "mongoose-legacy-pluralize": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", + "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" + }, + "mpath": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.7.0.tgz", + "integrity": "sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg==" + }, + "mquery": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz", + "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==", + "requires": { + "bluebird": "3.5.1", + "debug": "3.1.0", + "regexp-clone": "^1.0.0", + "safe-buffer": "5.1.2", + "sliced": "1.0.1" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "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" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "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=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "proxy-addr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.1" + } + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "regexp-clone": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", + "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" + }, + "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.1.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=" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "sift": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", + "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" + }, + "sliced": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", + "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "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.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "ws": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..e5a00a25 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "a4-creative-coding", + "version": "1.0.0", + "description": "A4 for Webware at WPI", + "main": "server.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "start": "node server.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/sdmoran/a4-creative-coding.git" + }, + "author": "Sam Moran smoran@wpi.edu", + "license": "ISC", + "bugs": { + "url": "https://github.com/sdmoran/a4-creative-coding/issues" + }, + "homepage": "https://github.com/sdmoran/a4-creative-coding#readme", + "dependencies": { + "ejs": "^3.1.5", + "express": "^4.17.1", + "uuid": "^8.3.1", + "ws": "^7.3.1", + "express-ws": "^4.0.0", + "mongodb": "^3.6.1", + "mongoose": "^5.10.9" + } +} diff --git a/public/scripts.js b/public/scripts.js new file mode 100644 index 00000000..20db6c8a --- /dev/null +++ b/public/scripts.js @@ -0,0 +1,252 @@ +// Constants/globals +var CLIENT_ID = null; +var CLIENT_NAME = ""; +var canvas; +var ctx; +var prev; +var curr; +var lineWidth = 10; +var color = "#000000" +var colors = ["#000000", "#FF0000", "#FF7F00", "#FFFF00", "#00FF00", "#00FFFF", "#007FFF", "#0000FF", "#7F00FF", "#FF00FF", + "#FFFFFF", "#E05151", "#E09951", "#E0E051", "#51E051", "#51E0E0", "#5199E0", "#5151E0", "#9951E0", "#E051E0", ] + +// WEBSOCKET +const ws = new WebSocket('wss://' + location.host); + +// Vue app, yay Vue! +const app = new Vue({ + el: "#app", + data: { + players: [], + messages: [], + word: "", + timeLeft: null, + isLeader: false, + canDraw: false, + started: false, + gameFinished: false, + }, + methods: { + sendStart: function() { + let e = document.getElementById("numRounds") + let numRounds = e.options[e.selectedIndex].text; + + e = document.getElementById("secondsPerRound") + let secondsPerRound = e.options[e.selectedIndex].text; + + ws.send(JSON.stringify({ + id: CLIENT_ID, + command: "START", + numRounds: parseInt(numRounds), + secondsPerRound: parseInt(secondsPerRound) + })) + } + } +}) + +// Get canvas context +window.onload = function() { + canvas = document.getElementById('canvasArea'); + ctx = canvas.getContext('2d'); + + // Display modal + $('#helpModal').modal(); + + document.getElementById('joinButton').onclick = function() { + // Get rid of attributes - no longer need them + document.getElementById('joinButton').remove(); + CLIENT_NAME = document.getElementById('nameField').value; + document.getElementById('nameField').remove(); + + // Register client with server + registerPlayer(); + + document.getElementById('clearButton').onclick = function() { + if(app.canDraw) { + sendClear(); + clear(); + } + } + + // Setup stroke buttons + for(let i = 10; i <= 50; i+= 10) { + const strokeButton = document.createElement('button'); + strokeButton.innerText = i; + strokeButton.id = `strokeButton${i}` + strokeButton.classList = "btn btn-primary" + document.getElementById('strokeButtonContainer').appendChild(strokeButton); + document.getElementById(`strokeButton${i}`).addEventListener("click", function() {lineWidth = i}); + } + + // Setup color buttons + for(let i = 0; i < colors.length; i++) { + const colorButton = document.createElement('button'); + colorButton.innerText = "x"; + colorButton.id = `colorButton${i}` + colorButton.classList += "btn" + colorButton.style = `background-color: ${colors[i]}; color: ${colors[i]}; border: 1px black solid;`; + document.getElementById('colorButtonContainer').appendChild(colorButton); + document.getElementById(`colorButton${i}`).addEventListener("click", function() {color = colors[i]}); + } + + // Set listener for chat messages + var msgBox = document.getElementById('messageBox') + msgBox.addEventListener("keydown", e => { + if(e.keyCode === 13 && msgBox.value.length >= 3) { + var guess = msgBox.value; + msgBox.value = ""; + sendGuess(guess); + } + }) + } +} + +function move(e) { + if(e.buttons && app.canDraw) { + if(!prev) { + prev = {x: e.offsetX, y: e.offsetY} + return + } + curr = {x: e.offsetX, y: e.offsetY} + draw(color, lineWidth, prev, curr) + sendDraw(); + prev = curr; + } +} + +function draw(style, width, p1, p2) { + ctx.beginPath(); + ctx.strokeStyle = style; + ctx.lineCap = 'round'; + ctx.lineWidth = width; + ctx.moveTo(p1.x, p1.y) + ctx.lineTo(p2.x, p2.y) + ctx.stroke(); +} + +function setWidth(i) { + lineWidth = i; +} + +function clear() { + ctx.clearRect(0, 0, canvas.width, canvas.height) +} + +window.onmousemove = move; + +// Make it so strokes don't connect to prev stroke between holding mouse down +window.onclick = function() { + prev = null; +} + + +ws.onopen = () => { + console.log("Connected to server!") +} + +ws.onmessage = (message) => { + console.log(message.data) + // Handle receiving message + + const obj = JSON.parse(message.data) + + if(obj.command === "ID") { + CLIENT_ID = obj.id; + console.log(CLIENT_ID); + console.log(obj) + app.isLeader = obj.isLeader; + } + else if(obj.command === "START") { + app.started = true; + app.gameFinished = false; + } + else if(obj.command === "GUESS") { + app.messages.push({player: obj.name, message: obj.guess}) + // Needs a short timeout to make sure Vue adds the element before we scroll + setTimeout(function() { + // Scroll to bottom + var elem = document.getElementById('guessBox'); + elem.scrollTop = elem.scrollHeight; + }) + } + else if(obj.command === "CORRECT") { + app.messages.push({player: obj.name, correct: true}); + let correctPlayer = app.players.find((p) => p.name === obj.name); + correctPlayer.correct++; + correctPlayer.correctThisDrawing = true; + } + else if(obj.command === "WORD") { + app.word = obj.word; + // On new word, reset correctThisDrawing for all players. + for(let i = 0; i < app.players.length; i++) { + app.players[i].correctThisDrawing = false; + } + } + else if(obj.command === "TICK") { + app.timeLeft = obj.timeLeft; + } + else if(obj.command === "CLEAR") { + clear(); + } + else if(obj.command === "ENABLE_DRAW") { + alert("You can now draw!") + app.canDraw = true; + } + else if(obj.command === "DISABLE_DRAW") { + app.canDraw = false; + } + else if(obj.command === "DRAW" && obj.id != CLIENT_ID) { + draw(obj.color, obj.lineWidth, obj.p1, obj.p2); + } + else if(obj.command === "CLEAR") { + clear(); + } + else if(obj.command === "UPDATE_PLAYERS") { + app.players = obj.players; + } + else if(obj.command === "GAME_OVER") { + app.messages = []; + app.word = ""; + app.timeLeft = null; + app.canDraw = false; + app.started = false; + app.gameFinished = true; + } +} + +const registerPlayer = function() { + const obj = { + command: "NEW_PLAYER", + name: CLIENT_NAME + } + ws.send(JSON.stringify(obj)); +} + +const sendDraw = function() { + console.log("Sending draw...") + const obj = { + id: CLIENT_ID, + command: "DRAW", + color: color, + lineWidth: lineWidth, + p1: prev, + p2: curr + } + ws.send(JSON.stringify(obj)) +} + +const sendClear = function() { + ws.send(JSON.stringify({ + id: CLIENT_ID, + command: "CLEAR" + })) + clear(); +} + +const sendGuess = function(guess) { + ws.send(JSON.stringify({ + id: CLIENT_ID, + command: "GUESS", + guess: guess + })) +} \ No newline at end of file diff --git a/public/style.css b/public/style.css new file mode 100644 index 00000000..6c960ffd --- /dev/null +++ b/public/style.css @@ -0,0 +1,24 @@ +canvas { + border: 1px dotted black; + cursor:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAABF0lEQVRYhe3WsYqEMBAG4L/Ydh4nvs42Kdxn8iCChRBInsJ3MBIWYetDZGULm+SK1cNil7trjBzzwTSm+XGSSQDGGGOMsR2cAGQALktly7dDOAMYiKgTQjRCiIaIOgDDspZUSUStMaZ3zk11XX9WVXX33o/W2isRtQDKVOHORNSGEGKe5w8AcVtSyhhCiEvI3f/kCcBgjOlfhduGNMb0eLZ71z2ZEVHnvR/fhVvLez8uezLbM+BFCNFUVXX/KWBZljOAjz3D/SmgUmoWQjR4jp/d/LrFzrkpRYu/D4mU8m04KWXUWt+Q4JAAmzHzKmTqMbMqiai11l6dc1NRFFEpNTvnJq31LfWgXh36qlsd+rHAGGOMsX/sC5dFysLg0h0kAAAAAElFTkSuQmCC) 20 20, default; +} + +#chatBox { + border: 1px solid grey; +} + +.scroll { + height: 36rem; + overflow: hidden; + overflow-y: scroll; + margin-bottom: 2rem; +} + +.btn { + margin: 1px; + border: 1px solid black; +} + +.correctThisDrawing { + color: lawngreen; +} \ No newline at end of file diff --git a/server.js b/server.js new file mode 100644 index 00000000..3b36c2db --- /dev/null +++ b/server.js @@ -0,0 +1,314 @@ +const express = require('express') +const WebSocket = require('ws') +const { v4: uuidv4 } = require('uuid') +const app = express() +const port = process.env.PORT || 3000 +const API = require("./API") + +// Use ejs as render engine +app.set('view engine', 'ejs'); + +// Used to unset interval when game ends. +var loop; + +let words = []; + +// Defaults +const ROUND_LENGTH = 90 +const NUM_ROUNDS = 2 +const MIN_PLAYERS = 2 +const MAX_PLAYERS = 8 + +// Set up initial game state +var game = { + players: [], + leader: null, + nowDrawingIdx: 0, + answerIdx: 0, + correctPlayers: [], + timeLeft: ROUND_LENGTH, + numRounds: NUM_ROUNDS, + started: false, +} + +// Keep track of messages previously sent by clients +var messages = [] + + +// Make static files in public/ directory available +app.use(express.static("public")) + +app.get('/', (req, res) => { + res.render("index", {title: "Home"}) +}) + +// Create HTTP server so WebSocket works not-just-locally +const http = require('http') +const server = http.createServer(app) + +// WebSocket server +const wss = new WebSocket.Server({server}) + +// SERVER, not APP, listens, which includes websocket +server.listen(port, () => { + console.log(`App listening on port ${port}`) +}) + + +wss.on('connection', (ws) => { + // Generate unique ID and add to list of clients + var client_id = uuidv4(); + + console.log("New client connected!") + console.log("Total clients connected: %d", wss.clients.size) + + // When new client connects, send them all previous messages + for(let i = 0; i < messages.length; i++) { + ws.send(messages[i]) + } + + ws.on('message', (message) => { + const obj = JSON.parse(message) + + // OK hear me out on this; I almost used a switch statement, but decided not + // to because some commands also need other conditions to be met in order to + // do anything, which would need ANOTHER if statement after the "case x:". So + // I did it this way. :) + + // Add new player to game state and send unique ID to client + if(obj["command"] === "NEW_PLAYER" && game.players.length < MAX_PLAYERS) { + + // First player is leader + const isLeader = game.players.length < 1 + + const player = { + id: client_id, + socket: ws, + name: obj.name, + leader: isLeader, + correct: 0, + score: 0, + } + + if(isLeader) { + game.leader = player; + } + + game.players.push(player); + + console.log("Registered new player!") + console.log("Playername: %s", obj.name) + + // Tell client the player's ID and if they're leader + ws.send(JSON.stringify({ + command: "ID", + id: client_id, + isLeader: isLeader, + })) + + // Send update list of players to each client + var players = game.players.map(p => { + return {name: p.name, correct: p.correct}; + }) + + sendToClients( + JSON.stringify({ + command: "UPDATE_PLAYERS", + players: players + }) + ) + } + + // Start game. Only leader can do this, and only if there are at least MIN_PLAYERS connected. + else if(obj.command === "START" && obj.id === game.leader.id && game.players.length >= MIN_PLAYERS) { + game.started = true; + game.timeLeft = obj.secondsPerRound || ROUND_LENGTH; + game.numRounds = obj.numRounds || NUM_ROUNDS; + + console.log(obj) + sendToClients(JSON.stringify({ + command: "START" + })); + API.getWords(game.players.length * game.numRounds).then((w) => { + words = w.map((it) => { + return it.word.toLowerCase(); + }) + console.log("Got words: ", words) + console.log("Game starting!") + tick(); + sendWordToClients(); + enableDrawing(game.players[game.nowDrawingIdx].id) + loop = setInterval(gameLoop, 1000); + }) + } + + // Handle guess, only if game is started + else if(obj.command === "GUESS" && game.started) { + // Figure out which player is guessing + const player = game.players.find(p => p.id === obj.id); + + // Don't let leader guess & don't let players guess more than once + if(game.players[game.nowDrawingIdx] === player || game.correctPlayers.includes(player)) { + return; + } + + // Correct guess - record it and notify clients + else if(obj.guess.toLowerCase() === words[game.answerIdx]) { + player.correct++; + game.correctPlayers.push(player); + sendToClients(JSON.stringify( + { + command: "CORRECT", + name: player.name, + correct: player.correct + } + )) + } + + // Incorrect guess - still notify clients because it goes into chat + else { + sendToClients(JSON.stringify( + { + command: "GUESS", + name: player.name, + guess: obj.guess + } + )) + } + + console.log("Player %s guessed: %s", player.name, obj.guess); + } + + // Check that clear command has authority to do so, then send to all clients + else if(obj["command"] === "CLEAR" && obj["id"] === game.players[game.nowDrawingIdx].id) { + messages = []; + sendToClients(JSON.stringify({command: "CLEAR"})) + return; + } + + // Check that draw command has authority to do so, then send to all clients + else if(obj["command"] === "DRAW" && obj["id"] === game.players[game.nowDrawingIdx].id) { + messages.push(message); + sendToClients(message); + } + }) + + ws.on('close', () => { + console.log("Client disconnected!") + console.log("Total clients connected: %d", wss.clients.size) + }) +}) + +// Send given message to all clients. +function sendToClients(msg) { + wss.clients.forEach((c) => { + if(c.readyState === WebSocket.OPEN) { + c.send(msg) + } + }) +} + +// Send given message ONLY to individual client. +function sendToClient(id, msg) { + var sock = game.players.find( p => p.id === id).socket + if(sock.readyState === WebSocket.OPEN) { + sock.send(msg) + } +} + +// Get word, blanked out except for specified positions if given +function getBlankedWord(word, revealLetters=[]) { + console.log("Word: %s", word) + let re = /\W/g + let blankedWord = word.replace(/\w/g, "_"); + + // for(let i = 0; i < revealLetters.length; i++) { + // let idx = revealLetters[i] + // blankedWord = blankedWord.substring(0, idx) + word[idx] + blankedWord.substring(idx+1) + // } + return blankedWord; +} + +// Disables drawing for all players, then enables drawing for specified player +function enableDrawing(id) { + sendToClients(JSON.stringify( + { + command: "DISABLE_DRAW" + } + )); + console.log("LETTING CLIENT %s DRAW", id) + sendToClient(id, JSON.stringify( + { + command: "ENABLE_DRAW" + } + )) +} + +// Sends word to clients +function sendWordToClients() { + // Send blanked word to all clients + sendToClients(JSON.stringify({ + command: "WORD", + word: getBlankedWord(words[game.answerIdx]), + })) + + // Send full word to client drawing + sendToClient(game.players[game.nowDrawingIdx].id, JSON.stringify({ + command: "WORD", + word: words[game.answerIdx], + nowDrawing: true + })) +} + +// Updates clients with time left in round +function tick() { + sendToClients(JSON.stringify({ + command: "TICK", + timeLeft: game.timeLeft + })) +} + +// Ends game and resets values for the next round +function endGame() { + // Reset values + game.started = false; + game.answerIdx = 0; + game.nowDrawingIdx = 0; + game.timeLeft = 15; + game.correctPlayers = []; + clearInterval(loop); + sendToClients(JSON.stringify({ + command: "GAME_OVER" + })) +} + +// Actual gameplay loop. Starts when leader hits start. +const gameLoop = function() { + game.timeLeft--; + tick(); + // Check length -1 because currently drawing player doesn't get to guess + if(game.correctPlayers.length === game.players.length - 1 || game.timeLeft === 0) { + if(game.answerIdx === words.length - 1) { + endGame(); + } + else { + // If all players have guessed correctly, wait a few seconds before advancing + clearInterval(loop); + setTimeout(() => { + nextQuestion(); + }, 3000) + } + } +} + +// Setup gamestate for new question +function nextQuestion() { + loop = setInterval(gameLoop, 1000); + game.correctPlayers = [] + game.answerIdx++; + game.timeLeft = ROUND_LENGTH; + game.nowDrawingIdx = (game.nowDrawingIdx + 1) % game.players.length; + sendToClients(JSON.stringify({command: "CLEAR"})); + sendWordToClients(); + enableDrawing(game.players[game.nowDrawingIdx].id); +} \ No newline at end of file diff --git a/views/index.ejs b/views/index.ejs new file mode 100644 index 00000000..0e87c401 --- /dev/null +++ b/views/index.ejs @@ -0,0 +1,153 @@ + + + + <%- include("./partials/head"); %> + + + + +
+
+
+ + + +

Current players:

+
    +
  • {{ p.name }} ({{ p.correct}} correct)
  • +
+ +
+ + + + + +
+
+ +
+

It's your turn to draw!

+

Game over!

+
+

Word: {{ word }}{{ word }}

Time left: {{ timeLeft }}

+
+ + +
+ +
+

Chat

+
+

+ {{ m.player }} guessed the answer! + {{ m.player }}: {{ m.message }} +

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

Stroke Width

+
+
+ +
+
+
+
+
+ + + + +
+ +
+ + + + + + + diff --git a/views/partials/head.ejs b/views/partials/head.ejs new file mode 100644 index 00000000..b18728ef --- /dev/null +++ b/views/partials/head.ejs @@ -0,0 +1,15 @@ + + + <%= title %> + + + + + + + + + + + + \ No newline at end of file diff --git a/words.txt b/words.txt new file mode 100644 index 00000000..e69de29b