From efea5051c8c5097de5e097d47cd05013cc02b6d8 Mon Sep 17 00:00:00 2001 From: suroh Date: Thu, 14 Sep 2023 14:43:19 +0200 Subject: [PATCH] updated README with tech information --- README.md | 22 ++++++++++++++++++++++ frontend/src/components/MapView.js | 9 +++++++-- frontend/src/controllers/MapController.js | 3 +++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0f6a1d..644e286 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,28 @@ $ npm run dev You should now be able to access ethermaps on [http://localhost:3000](http://localhost:3000/) (or whichever port you configured in your `.env` file). +## Tech + +### Backend + +Backend is running on [express.js](https://expressjs.com/) with [ViteExpress](https://github.com/szymmis/vite-express) bridging the gap between the fron and backends. + +Database models, and queries are handled by [objection.js](https://vincit.github.io/objection.js/) ORM built on top of [knex](https://knexjs.org/). During dev the database defaults to an Sqlite3 db, and then during production it will be able to handle whichever database you choose. For now it has only been setup to work with PostgreSQL. + +Live data is shared with the client using [socket.io](https://socket.io/). + +Tests are written with [AVA](https://github.com/avajs/ava) and route testing uses [supertest](https://github.com/ladjs/supertest). + +### Frontend + +Frontend is an SPA using [lit](https://lit.dev/) element, and some [utilities](https://github.com/thepassle/app-tools) by [Pascal Schilp](https://github.com/thepassle). + +Map rendering is done with [leaflet](https://leafletjs.com/). + +Live rendering of users is done with [socket.io-client](https://socket.io/docs/v4/client-api/). + +For the developer environment and future building, the frontend is managed by [Vite](https://vitejs.dev/). + ## Desires Minimal viable functionality for this project is the following : diff --git a/frontend/src/components/MapView.js b/frontend/src/components/MapView.js index 2d0348b..46c49cb 100644 --- a/frontend/src/components/MapView.js +++ b/frontend/src/components/MapView.js @@ -81,11 +81,16 @@ class MapView extends LitElement { }) // get the map with name + // TODO@me only run this if we are at the path /m/:mapName this.mapController.get(this.name).then(m => { - this.socket.emit('connect-map', m.id) + if (m?.id) { + this.socket.emit('connect-map', m.id) + } // set points - this.setPoints(m.map_points) + if (m?.map_points.length > 0) { + this.setPoints(m.map_points) + } }) } diff --git a/frontend/src/controllers/MapController.js b/frontend/src/controllers/MapController.js index 2cd6c6f..0120ef8 100644 --- a/frontend/src/controllers/MapController.js +++ b/frontend/src/controllers/MapController.js @@ -9,6 +9,9 @@ export default class MapController { async get(name) { try { const req = await fetch(`/api/map/${name}`) + + console.log(req) + const json = await req.json() this.map = json