Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow selection to use a3 markers as imageUrls for point markers #9

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
APP_PORT=3192
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_EXT_PORT=3193
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=la3map
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
package-lock.json
app.db
app.db
.env
50 changes: 50 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3"

name: la3map
services:
node:
build: ./
working_dir: /usr/app
environment:
- NODE_ENV=production
- IS_DOCKER=true
ports:
- ${APP_PORT}:3000
depends_on:
postgres:
condition: service_healthy
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:3000/healthcheck"
]
interval: 30s
timeout: 10s
retries: 5
command: "npm start"
restart: unless-stopped
volumes:
- ./:/usr/app
- /usr/app/node_modules
postgres:
env_file: .env
image: postgis/postgis:12-3.3
healthcheck:
test: [ "CMD", "pg_isready", "-U", "${POSTGRES_USER}" ]
interval: 5s
timeout: 5s
retries: 5
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
ports:
- ${POSTGRES_EXT_PORT}:5432
volumes:
- pg_data:/var/lib/postgresql/data

volumes:
pg_data: {}
13 changes: 0 additions & 13 deletions docker-compose.yml

This file was deleted.

98 changes: 98 additions & 0 deletions lib/db.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// database connection and model definitions

const Sequelize = require('sequelize');

// create/connect database (SQLite)
// const sequelize = new Sequelize({
// dialect: 'sqlite',
// storage: dbFile,
// // logging: false,
// // transactionType: 'IMMEDIATE',
// retry: {
// max: 10
// }
// });


// create/connect database (PostgreSQL)
const sequelize = new Sequelize(`postgres://${process.env.POSTGRES_USER}:${process.env.POSTGRES_PASSWORD}@${process.env.POSTGRES_HOST}:${process.env.POSTGRES_PORT}/${process.env.POSTGRES_DB}`, {
dialect: 'postgres',
application_name: 'la3map',
keepAlive: true,
logging: false
});

// define models
const Drawing = sequelize.define('Drawing', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true,
},
// data is json
data: Sequelize.DataTypes.GEOMETRY,
description: Sequelize.TEXT,
color: Sequelize.TEXT,
imageUrl: Sequelize.TEXT,
});

const Session = sequelize.define('Session', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true,
},
worldname: Sequelize.TEXT,
});

const User = sequelize.define('User', {
username: {
type: Sequelize.TEXT,
unique: true,
},
password: Sequelize.TEXT,
role: Sequelize.TEXT,
});


const Marker = sequelize.define('Marker', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true,
},
addon: {
type: Sequelize.TEXT,
},
marker_name: {
type: Sequelize.TEXT,
},
url: Sequelize.TEXT
},
{
indexes: [
{
unique: true,
fields: ['addon', 'marker_name']
}
]
}
);

// define relationships
Drawing.Session = Drawing.belongsTo(Session, {
foreignKey: 'session_id',
onDelete: 'CASCADE',
});
Session.Drawings = Session.hasMany(Drawing, {
foreignKey: 'session_id',
onDelete: 'CASCADE',
})

module.exports = {
sequelize,
Drawing,
Session,
User,
Marker,
};
Loading