diff --git a/nodejs/basic-example/talkjs-backend/file.json b/nodejs/basic-example/talkjs-backend/file.json deleted file mode 100644 index ff18c49c..00000000 --- a/nodejs/basic-example/talkjs-backend/file.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "users": [ - { - "id": 2, - "name": "John Morrison", - "email": "john.morrison@operator.com", - "photoUrl": "https://randomuser.me/api/portraits/men/62.jpg", - "role": "USER" - }, - { - "id": 1, - "name": "Tom Hardy", - "email": "tom.hardy@operator.com", - "photoUrl": "https://randomuser.me/api/portraits/men/1.jpg", - "role": "USER" - } - ] -} \ No newline at end of file diff --git a/nodejs/basic-example/talkjs-backend/server.js b/nodejs/basic-example/talkjs-backend/server.js index 9ae59a5b..e5ec5a78 100644 --- a/nodejs/basic-example/talkjs-backend/server.js +++ b/nodejs/basic-example/talkjs-backend/server.js @@ -5,7 +5,7 @@ import bodyParser from "body-parser"; import { LowSync, JSONFileSync } from "lowdb"; -const adapter = new JSONFileSync("file.json"); +const adapter = new JSONFileSync("users.json"); const db = new LowSync(adapter); db.read(); db.data ||= { users: [] }; @@ -23,7 +23,6 @@ app.post("/createUser", (req, res) => { const email = req.body.email; const photoUrl = req.body.photoUrl; const role = req.body.role; - console.log(id, name, email, photoUrl, role); db.data.users.push({ id: id, name: name, @@ -47,4 +46,4 @@ app.get("/getUser/:id", (req, res) => { } }); -app.listen(port, () => console.log(`Server up and running at port ${port}!`)); +app.listen(port, () => console.log(`Server up and running on port ${port}`)); diff --git a/nodejs/basic-example/talkjs-backend/users.json b/nodejs/basic-example/talkjs-backend/users.json new file mode 100644 index 00000000..44d3ecc8 --- /dev/null +++ b/nodejs/basic-example/talkjs-backend/users.json @@ -0,0 +1,20 @@ +{ + "users": [ + { + "id": "1", + "name": "Alice", + "email": "alice@example.com", + "photoUrl": "https://talkjs.com/new-web/avatar-7.jpg", + "role": "default", + "welcomeMessage": "Hi 👋" + }, + { + "id": "2", + "name": "Sebastian", + "email": "sebastian@example.com", + "photoUrl": "https://talkjs.com/new-web/avatar-2.jpg", + "role": "default", + "welcomeMessage": "Hello there!" + } + ] +} diff --git a/nodejs/basic-example/talkjs-frontend/index.html b/nodejs/basic-example/talkjs-frontend/index.html index 382a5076..8b03ea81 100644 --- a/nodejs/basic-example/talkjs-frontend/index.html +++ b/nodejs/basic-example/talkjs-frontend/index.html @@ -1,48 +1,43 @@ - -
- - + + +