Browse Source

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

main
suroh 1 year ago
parent
commit
357024df22
  1. 22
      README.md
  2. 4
      backend/.env.template
  3. 14
      backend/controllers/maps.js
  4. 8
      backend/knexfile.js
  5. 2477
      backend/package-lock.json
  6. 4
      backend/package.json
  7. 2
      frontend/src/components/MapView.js
  8. 1298
      package-lock.json
  9. 22
      package.json

22
README.md

@ -6,7 +6,27 @@ An interactive map tool. A tool for collaborative planning on maps. Anyone can c
## 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

4
backend/.env.template

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

14
backend/controllers/maps.js

@ -16,6 +16,20 @@ const getMapByName = async (req, res) => {
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)
} catch (error) {
console.error(error)

8
backend/knexfile.js

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

2477
backend/package-lock.json

File diff suppressed because it is too large

4
backend/package.json

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

2
frontend/src/components/MapView.js

@ -91,11 +91,13 @@ class MapView extends LitElement {
}
setPoints(points) {
console.log(points)
points.forEach((p, i) => {
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>` : ''}`)
})
const end = points.length - 1
this.leaflet.setView([ points[end].location.x, points[end].location.y ], 13)
}

1298
package-lock.json

File diff suppressed because it is too large

22
package.json

@ -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"
}
}
Loading…
Cancel
Save