modified to have only one set of scripts for install, migration and dev env

This commit is contained in:
suroh 2023-09-14 13:39:47 +02:00
parent 248a0fb05a
commit 357024df22
9 changed files with 1379 additions and 2428 deletions

View File

@ -6,7 +6,27 @@ An interactive map tool. A tool for collaborative planning on maps. Anyone can c
## Install ## Install
Ethermap is built in JavaScript (soz) using NodeJS. Install instructinos for the back and frontend are in their respective folders. Ethermap is built in JavaScript (soz) using NodeJS. To install you can do so by running the following commands.
To install all dependencies for the front and backend :
```sh
$ npm run install:all
```
You will then need to create a `.env` file in the root of the backend. There is a `.env.template` that you can copy as a guide. For a dev server you can simply copy and paste the template leaving it as is.
Then migrate the database structure :
```sh
$ npm run migrate:latest
```
Then you should be able to run the dev servers :
```sh
$ npm run dev:all
```
> NOTE : while you can change the server port number, the front end is hardwired to make requests on port 3000, so for now don't change this.
The backend is running on the port that you defined in your `.env` file (by default it is port 3000), and the frontend will be running on the default Vite port `5173`.
## Desires ## Desires

View File

@ -1,8 +1,8 @@
# ethermap # ethermap
SITE_NAME= SITE_NAME=ethermap
# Server Setup # Server Setup
PORT= PORT=3000
# Database Setup # Database Setup
DB_PROVIDER= DB_PROVIDER=

View File

@ -16,6 +16,20 @@ const getMapByName = async (req, res) => {
map = await MapModel.query().findById(created.id).withGraphFetched('map_points') map = await MapModel.query().findById(created.id).withGraphFetched('map_points')
} }
// convert location from string to point
if (map?.map_points.length > 0) {
map.map_points.forEach(p => {
if (
typeof p.location === 'string' ||
p.location instanceof String
) {
const locString = p.location.replace(/[()\s]/g, '')
const [ x, y ] = locString.split(',')
p.location = { x, y }
}
})
}
res.json(map) res.json(map)
} catch (error) { } catch (error) {
console.error(error) console.error(error)

View File

@ -24,10 +24,8 @@ export default {
test: { test: {
client: 'sqlite3', client: 'sqlite3',
connection: ':memory:',
useNullAsDefault: true, useNullAsDefault: true,
connection: {
filename: './db/testing.db'
},
migrations: { migrations: {
directory: __dirname + '/db/migrations' directory: __dirname + '/db/migrations'
}, },
@ -37,7 +35,7 @@ export default {
}, },
staging: { staging: {
client: 'pg', client: process.env.DB_PROVIDER,
connection: { connection: {
database: process.env.DB_NAME, database: process.env.DB_NAME,
user: process.env.DB_USER, user: process.env.DB_USER,
@ -55,7 +53,7 @@ export default {
}, },
production: { production: {
client: 'pg', client: process.env.DB_PROVIDER,
connection: { connection: {
database: process.env.DB_NAME, database: process.env.DB_NAME,
user: process.env.DB_USER, user: process.env.DB_USER,

2433
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -27,13 +27,13 @@
"objection": "^3.1.1", "objection": "^3.1.1",
"pg": "^8.11.3", "pg": "^8.11.3",
"socket.io": "^4.7.2", "socket.io": "^4.7.2",
"sqlite3": "^5.1.6" "sqlite3": "^5.1.6",
"vite-express": "^0.10.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^5.3.1", "ava": "^5.3.1",
"eslint": "^8.48.0", "eslint": "^8.48.0",
"nodemon": "^3.0.1", "nodemon": "^3.0.1",
"pg-mem": "^2.6.13",
"supertest": "^6.3.3" "supertest": "^6.3.3"
} }
} }

View File

@ -91,11 +91,13 @@ class MapView extends LitElement {
} }
setPoints(points) { setPoints(points) {
console.log(points)
points.forEach((p, i) => { points.forEach((p, i) => {
this.points[i] = L.marker([ p.location.x, p.location.y ]).addTo(this.leaflet) this.points[i] = L.marker([ p.location.x, p.location.y ]).addTo(this.leaflet)
this.points[i].bindPopup(`<h3>${p.name}</h3>${p.notes ? `<p>${p.notes}</p>` : ''}`) this.points[i].bindPopup(`<h3>${p.name}</h3>${p.notes ? `<p>${p.notes}</p>` : ''}`)
}) })
const end = points.length - 1 const end = points.length - 1
this.leaflet.setView([ points[end].location.x, points[end].location.y ], 13) this.leaflet.setView([ points[end].location.x, points[end].location.y ], 13)
} }

1298
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

22
package.json Normal file
View File

@ -0,0 +1,22 @@
{
"name": "ethermap",
"version": "1.0.0",
"description": "> This is very much a janky _earlydays_ project. All help is welcome!",
"main": "index.js",
"scripts": {
"install:front": "cd ./frontend && npm i",
"install:back": "cd ./backend && npm i",
"install:all": "npm-run-all --sequential install:front install:back",
"migrate:latest": "cd ./backend && npm run migrate:latest",
"migrate:drop": "cd ./backend && npm run migrate:drop",
"dev:front": "cd ./frontend && npm run dev",
"dev:back": "cd ./backend && npm run dev",
"dev:all": "npm-run-all --parallel dev:front dev:back"
},
"keywords": [],
"author": "",
"license": "GPL-3.0-or-later",
"devDependencies": {
"npm-run-all": "^4.1.5"
}
}