From 0c20db100ba4539c79df8b5b6ad88a0b7cb90222 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Thu, 9 Apr 2020 10:30:15 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B6=F0=9F=8D=B2=20Checkpoint=20./views?= =?UTF-8?q?/room.handlebars:530995/365=20./server.js:530995/486=20./views/?= =?UTF-8?q?join.handlebars:530995/26=20./package.json:530995/1360?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 ++- server.js | 14 ++++++++++++-- shrinkwrap.yaml | 2 ++ views/join.handlebars | 2 +- views/room.handlebars | 18 ++++++------------ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 6f4e6c6..ed6affc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ }, "dependencies": { "express": "^4.17.1", - "express-handlebars": "^4.0.3" + "express-handlebars": "^4.0.3", + "body-parser": "^1.19.0" }, "engines": { "node": "12.x" diff --git a/server.js b/server.js index 5914ec4..7d1fbe8 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,13 @@ const express = require("express"); -var exphbs = require('express-handlebars'); +const exphbs = require('express-handlebars'); +const bodyParser = require('body-parser') + const app = express(); +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({ + extended: true +})); app.engine('handlebars', exphbs()); app.set('view engine', 'handlebars'); @@ -12,7 +18,11 @@ app.get("/:roomId/join", (request, response) => { }); app.post("/:roomId/join", (request, response) => { - response.render('room', {layout: false, room: request.params.roomId}); + response.render('room', { + layout: false, + room: request.params.roomId, + name: request.body.name + }); }); const listener = app.listen(process.env.PORT, () => { diff --git a/shrinkwrap.yaml b/shrinkwrap.yaml index 50e8e26..9333ccc 100644 --- a/shrinkwrap.yaml +++ b/shrinkwrap.yaml @@ -1,4 +1,5 @@ dependencies: + body-parser: 1.19.0 express: 4.17.1 express-handlebars: 4.0.3 packages: @@ -562,5 +563,6 @@ registry: 'https://registry.npmjs.org/' shrinkwrapMinorVersion: 9 shrinkwrapVersion: 3 specifiers: + body-parser: ^1.19.0 express: ^4.17.1 express-handlebars: ^4.0.3 diff --git a/views/join.handlebars b/views/join.handlebars index af277c4..c19371c 100644 --- a/views/join.handlebars +++ b/views/join.handlebars @@ -20,7 +20,7 @@

Tell me your (team) name:

-
+