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:

-
+