mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
fixed config paths
This commit is contained in:
parent
9c0038f0a3
commit
bf1b92fdf1
18 changed files with 92 additions and 124 deletions
|
@ -54,7 +54,7 @@
|
||||||
"$containers": "src/containers",
|
"$containers": "src/containers",
|
||||||
"$constants": "src/constants",
|
"$constants": "src/constants",
|
||||||
"$sprites": "src/sprites",
|
"$sprites": "src/sprites",
|
||||||
"$config": "src/config",
|
"$config": "config",
|
||||||
"$styles": "src/styles",
|
"$styles": "src/styles",
|
||||||
"$redux": "src/redux",
|
"$redux": "src/redux",
|
||||||
"$utils": "src/utils",
|
"$utils": "src/utils",
|
||||||
|
@ -62,8 +62,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"extensions": [".js", ".jsx", ".scss"],
|
"extensions": [".js", ".jsx", ".scss"],
|
||||||
|
"modules": ["config", "src", "node_modules"]
|
||||||
"modules": ["src", "node_modules"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -14,5 +14,8 @@ yarn-error.log
|
||||||
/osrm/pbf
|
/osrm/pbf
|
||||||
/osrm/pbf/*
|
/osrm/pbf/*
|
||||||
|
|
||||||
|
/config/frontend.js
|
||||||
|
/config/backend.js
|
||||||
|
|
||||||
# Bundle
|
# Bundle
|
||||||
*.js.map
|
*.js.map
|
||||||
|
|
10
README.md
10
README.md
|
@ -22,18 +22,20 @@ Next you need to edit start_server.sh to specify address, port for server and pa
|
||||||
|
|
||||||
After that run start_server.sh in screen or by the way you feel comfortable.
|
After that run start_server.sh in screen or by the way you feel comfortable.
|
||||||
|
|
||||||
Next edit ```./src/config.js``` and specify OSRM url there. By default, OSRM starts at ```http://localhost:5000/```
|
Next edit ```./config/frontend.js``` and specify OSRM url there. By default, OSRM starts at ```https://localhost:5001/```
|
||||||
|
|
||||||
### Frontend
|
### Common setup
|
||||||
Configs are placed in ```./src/config.js``` and ```./src/constants/```
|
Look at ```/config/``` folder, there's backend and frontend .example.js files, just rename them to .js only.
|
||||||
|
|
||||||
|
### Client
|
||||||
|
Configs are placed in ```./config/frontend.js```
|
||||||
|
|
||||||
For development launch ```npm start``` and visit ```http://localhost:8000/```
|
For development launch ```npm start``` and visit ```http://localhost:8000/```
|
||||||
|
|
||||||
For production launch ```npm build```, the output will be placed at ```./dist``` folder, you should configure your http server to serve index html from that folder.
|
For production launch ```npm build```, the output will be placed at ```./dist``` folder, you should configure your http server to serve index html from that folder.
|
||||||
|
|
||||||
### Backend
|
### Backend
|
||||||
Take a look at ```./backend/config/``` files, especially at ```db.js```. Your api server will be spawned at ```http://localhost:3000/```
|
Take a look at ```./config/backend.js```. By default your api server will be spawned at ```http://localhost:3000/```
|
||||||
|
|
||||||
For development launch ```npm serve-dev```, it will launch dev server, reloading on every code update
|
For development launch ```npm serve-dev```, it will launch dev server, reloading on every code update
|
||||||
|
|
||||||
|
|
|
@ -1,90 +1,34 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
const { CONFIG } = require('../../config/backend');
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const app = require('../app');
|
const app = require('../app');
|
||||||
const debug = require('debug')('orchid-backend:server');
|
const fs = require('fs');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
/**
|
if (CONFIG.HTTP.ENABLED) {
|
||||||
* Get port from environment and store in Express.
|
const httpPort = CONFIG.HTTP.PORT;
|
||||||
*/
|
app.set('port', httpPort);
|
||||||
|
|
||||||
const port = normalizePort(process.env.PORT || '3000');
|
const httpServer = http.createServer(app);
|
||||||
app.set('port', port);
|
httpServer.listen(httpPort);
|
||||||
|
|
||||||
/**
|
httpServer.on('error', console.log);
|
||||||
* Create HTTP server.
|
httpServer.on('listening', console.log);
|
||||||
*/
|
|
||||||
|
|
||||||
const server = http.createServer(app);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Listen on provided port, on all network interfaces.
|
|
||||||
*/
|
|
||||||
|
|
||||||
server.listen(port);
|
|
||||||
server.on('error', onError);
|
|
||||||
server.on('listening', onListening);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalize a port into a number, string, or false.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function normalizePort(val) {
|
|
||||||
const port = parseInt(val, 10);
|
|
||||||
|
|
||||||
if (isNaN(port)) {
|
|
||||||
// named pipe
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port >= 0) {
|
|
||||||
// port number
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
if (CONFIG.HTTPS.ENABLED) {
|
||||||
* Event listener for HTTP server "error" event.
|
const sslPort = CONFIG.HTTPS.PORT;
|
||||||
*/
|
app.set('port', sslPort);
|
||||||
|
|
||||||
function onError(error) {
|
const privateKey = fs.readFileSync(CONFIG.HTTPS.PRIVATE_KEY, 'utf8');
|
||||||
if (error.syscall !== 'listen') {
|
const certificate = fs.readFileSync(CONFIG.HTTPS.CERTIFICATE, 'utf8');
|
||||||
throw error;
|
const ca = fs.readFileSync(CONFIG.HTTPS.CA, 'utf8');
|
||||||
}
|
|
||||||
|
|
||||||
const bind = typeof port === 'string'
|
const sslServer = https.createServer({ privateKey, certificate, ca }, app);
|
||||||
? 'Pipe ' + port
|
|
||||||
: 'Port ' + port;
|
|
||||||
|
|
||||||
// handle specific listen errors with friendly messages
|
sslServer.listen(sslPort);
|
||||||
switch (error.code) {
|
sslServer.on('error', console.log);
|
||||||
case 'EACCES':
|
sslServer.on('listening', console.log);
|
||||||
console.error(bind + ' requires elevated privileges');
|
|
||||||
process.exit(1);
|
|
||||||
break;
|
|
||||||
case 'EADDRINUSE':
|
|
||||||
console.error(bind + ' is already in use');
|
|
||||||
process.exit(1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Event listener for HTTP server "listening" event.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function onListening() {
|
|
||||||
const addr = server.address();
|
|
||||||
const bind = typeof addr === 'string'
|
|
||||||
? 'pipe ' + addr
|
|
||||||
: 'port ' + addr.port;
|
|
||||||
debug('Listening on ' + bind);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
const user = 'user';
|
const { CONFIG } = require('../../config/backend');
|
||||||
const password = 'password';
|
|
||||||
const hostname = 'vault48.org';
|
const {
|
||||||
const port = 27017;
|
DB: {
|
||||||
const db = 'map';
|
USER, PASSWORD, HOSTNAME, PORT, DATABASE
|
||||||
|
}
|
||||||
|
} = CONFIG;
|
||||||
|
|
||||||
const mongoose = require('mongoose');
|
const mongoose = require('mongoose');
|
||||||
mongoose.Promise = require('bluebird');
|
mongoose.Promise = require('bluebird');
|
||||||
|
|
||||||
mongoose.connect(`mongodb://${user}:${password}@${hostname}:${port}/${db}`, { });
|
mongoose.connect(`mongodb://${USER}:${PASSWORD}@${HOSTNAME}:${PORT}/${DATABASE}`, { });
|
||||||
const database = mongoose.connection;
|
const database = mongoose.connection;
|
||||||
|
|
||||||
database.on('error', (err) => { console.error(`Database Connection Error: ${err}`); process.exit(2); });
|
database.on('error', (err) => { console.error(`Database Connection Error: ${err}`); process.exit(2); });
|
||||||
database.on('connected', () => { console.info('Succesfully connected to MongoDB Database'); });
|
database.on('connected', () => { console.info('Succesfully connected to MongoDB Database'); });
|
||||||
|
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module.exports.SOCIAL = {
|
|
||||||
VK: {
|
|
||||||
client_secret: 'Z71DsxoMF7PS9kayLuks',
|
|
||||||
client_id: 5987644,
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -2,7 +2,7 @@ const { User } = require('../../../models');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { generateUser } = require('../guest');
|
const { generateUser } = require('../guest');
|
||||||
const { STRINGS } = require('../../../config/strings');
|
const { STRINGS } = require('../../../config/strings');
|
||||||
const { SOCIAL } = require('../../../config/social');
|
const { CONFIG } = require('../../../../config/backend');
|
||||||
|
|
||||||
const fetchUserData = async (req, res) => {
|
const fetchUserData = async (req, res) => {
|
||||||
const { query: { code } } = req;
|
const { query: { code } } = req;
|
||||||
|
@ -12,8 +12,8 @@ const fetchUserData = async (req, res) => {
|
||||||
'https://oauth.vk.com/access_token',
|
'https://oauth.vk.com/access_token',
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
client_id: SOCIAL.VK.client_id,
|
client_id: CONFIG.SOCIAL.VK.APP_ID,
|
||||||
client_secret: SOCIAL.VK.client_secret,
|
client_secret: CONFIG.SOCIAL.VK.SECRET,
|
||||||
code,
|
code,
|
||||||
redirect_uri: `http://${host}/auth/social/vk`,
|
redirect_uri: `http://${host}/auth/social/vk`,
|
||||||
}
|
}
|
||||||
|
|
27
config/backend.example.js
Normal file
27
config/backend.example.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
module.exports.CONFIG = {
|
||||||
|
HTTPS: {
|
||||||
|
ENABLED: false,
|
||||||
|
PORT: 3000,
|
||||||
|
PRIVATE_KEY: '/etc/letsencrypt/live/HOSTNAME.org/privkey.pem',
|
||||||
|
CERTIFICATE: '/etc/letsencrypt/live/HOSTNAME.org/cert.pem',
|
||||||
|
CA: '/etc/letsencrypt/live/hostname/chain.pem',
|
||||||
|
},
|
||||||
|
HTTP: {
|
||||||
|
ENABLED: false,
|
||||||
|
PORT: 3000,
|
||||||
|
},
|
||||||
|
DB: { // mongo db config
|
||||||
|
USER: 'user',
|
||||||
|
PASSWORD: 'password',
|
||||||
|
HOSTNAME: 'HOSTNAME.org',
|
||||||
|
PORT: 27017,
|
||||||
|
DATABASE: 'map',
|
||||||
|
},
|
||||||
|
SOCIAL: {
|
||||||
|
VK: {
|
||||||
|
ENABLED: false,
|
||||||
|
SECRET: 'YOUR_VK_SECRET', // secret token
|
||||||
|
APP_ID: 0, // numeric
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,7 +1,11 @@
|
||||||
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
|
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
|
||||||
|
|
||||||
export const CONFIG = {
|
const API_ADDR = 'https://HOSTNAME.org:3000';
|
||||||
OSRM_URL: 'http://vault48.org:5000/route/v1',
|
const OSRM_URL = 'https://HOSTNAME.org:5001/route/v1';
|
||||||
|
|
||||||
|
export const CLIENT = {
|
||||||
|
OSRM_URL,
|
||||||
|
API_ADDR,
|
||||||
STROKE_WIDTH: 5,
|
STROKE_WIDTH: 5,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { GuestButton } from '$components/user/GuestButton';
|
import { GuestButton } from '$components/user/GuestButton';
|
||||||
import { TEST } from '$constants/api';
|
|
||||||
import { DEFAULT_USER, ROLES } from '$constants/auth';
|
import { DEFAULT_USER, ROLES } from '$constants/auth';
|
||||||
import { UserButton } from '$components/user/UserButton';
|
import { UserButton } from '$components/user/UserButton';
|
||||||
import { UserMenu } from '$components/user/UserMenu';
|
import { UserMenu } from '$components/user/UserMenu';
|
||||||
|
@ -12,6 +11,7 @@ import type { UserType } from '$constants/types';
|
||||||
import { Icon } from '$components/panels/Icon';
|
import { Icon } from '$components/panels/Icon';
|
||||||
|
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import { CLIENT } from '$config/frontend';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: UserType,
|
user: UserType,
|
||||||
|
@ -62,8 +62,7 @@ export class Component extends React.PureComponent<Props, void> {
|
||||||
const left = (width - 700) / 2;
|
const left = (width - 700) / 2;
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
// `https://oauth.vk.com/authorize?client_id=5987644&scope=&redirect_uri=${SERVER}/engine/oauthOrchid.php&response_type=code`,
|
`https://oauth.vk.com/authorize?client_id=5987644&scope=&redirect_uri=${CLIENT.API_ADDR}/auth/social/vk`,
|
||||||
`https://oauth.vk.com/authorize?client_id=5987644&scope=&redirect_uri=${TEST}/auth/social/vk`,
|
|
||||||
'socialPopupWindow',
|
'socialPopupWindow',
|
||||||
`location=no,width=700,height=370,scrollbars=no,top=${top},left=${left},resizable=no`
|
`location=no,width=700,height=370,scrollbars=no,top=${top},left=${left},resizable=no`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
export const SERVER = 'http://alpha-map.vault48.org';
|
import { CLIENT } from '$config/frontend';
|
||||||
export const TEST = 'http://localhost:3000';
|
|
||||||
|
|
||||||
export const API = {
|
export const API = {
|
||||||
GET_GUEST: `${TEST}/auth`,
|
GET_GUEST: `${CLIENT.API_ADDR}/auth`,
|
||||||
CHECK_TOKEN: `${TEST}/auth`,
|
CHECK_TOKEN: `${CLIENT.API_ADDR}/auth`,
|
||||||
GET_MAP: `${TEST}/route`,
|
GET_MAP: `${CLIENT.API_ADDR}/route`,
|
||||||
POST_MAP: `${TEST}/route`,
|
POST_MAP: `${CLIENT.API_ADDR}/route`,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
// Стили карт
|
// Стили карт
|
||||||
import { editor } from '$modules/Editor';
|
|
||||||
|
|
||||||
const TILEMAPS = {
|
const TILEMAPS = {
|
||||||
WATERCOLOR: {
|
WATERCOLOR: {
|
||||||
name: 'Watercolor',
|
name: 'Watercolor',
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { ROLES } from '$constants/auth';
|
|
||||||
|
|
||||||
export type UserType = {
|
export type UserType = {
|
||||||
new_messages: Number,
|
new_messages: Number,
|
||||||
place_types: Object,
|
place_types: Object,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { map, tileLayer } from 'leaflet';
|
import { map, tileLayer } from 'leaflet';
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import 'leaflet-editable';
|
import 'leaflet-editable';
|
||||||
import { PROVIDER } from '$config';
|
import { PROVIDER } from '$config/frontend';
|
||||||
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
|
import { DEFAULT_PROVIDER, PROVIDERS } from '$constants/providers';
|
||||||
|
|
||||||
export class Map {
|
export class Map {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import L from 'leaflet';
|
||||||
import 'leaflet-geometryutil';
|
import 'leaflet-geometryutil';
|
||||||
import { simplify } from '$utils/simplify';
|
import { simplify } from '$utils/simplify';
|
||||||
import { findDistance, middleCoord } from '$utils/geom';
|
import { findDistance, middleCoord } from '$utils/geom';
|
||||||
import { CONFIG } from '$config';
|
import { CLIENT } from '$config/frontend';
|
||||||
|
|
||||||
const polyStyle = {
|
const polyStyle = {
|
||||||
color: 'url(#activePathGradient)',
|
color: 'url(#activePathGradient)',
|
||||||
|
@ -50,7 +50,7 @@ export class Poly {
|
||||||
latlngs[i - 1],
|
latlngs[i - 1],
|
||||||
[mid.lat, mid.lng]
|
[mid.lat, mid.lng]
|
||||||
],
|
],
|
||||||
{ color: 'none', weight: CONFIG.STROKE_WIDTH }
|
{ color: 'none', weight: CLIENT.STROKE_WIDTH }
|
||||||
).addTo(this.arrows);
|
).addTo(this.arrows);
|
||||||
|
|
||||||
slide._path.setAttribute('marker-end', 'url(#long-arrow)');
|
slide._path.setAttribute('marker-end', 'url(#long-arrow)');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import L from 'leaflet';
|
import L from 'leaflet';
|
||||||
import Routing from 'leaflet-routing-machine/src/index';
|
import Routing from 'leaflet-routing-machine/src/index';
|
||||||
import { CONFIG } from '$config';
|
import { CLIENT } from '$config/frontend';
|
||||||
import { DomMarker } from '$utils/DomMarker';
|
import { DomMarker } from '$utils/DomMarker';
|
||||||
|
|
||||||
export class Router {
|
export class Router {
|
||||||
|
@ -22,7 +22,7 @@ export class Router {
|
||||||
}).on('linetouched', this.lockPropagations);
|
}).on('linetouched', this.lockPropagations);
|
||||||
|
|
||||||
this.router = Routing.control({
|
this.router = Routing.control({
|
||||||
serviceUrl: CONFIG.OSRM_URL,
|
serviceUrl: CLIENT.OSRM_URL,
|
||||||
profile: 'bike',
|
profile: 'bike',
|
||||||
fitSelectedRoutes: false,
|
fitSelectedRoutes: false,
|
||||||
routeLine,
|
routeLine,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { editor } from '$modules/Editor';
|
import { editor } from '$modules/Editor';
|
||||||
import { COLORS, CONFIG } from '$config';
|
import { COLORS, CLIENT } from '$config/frontend';
|
||||||
import saveAs from 'file-saver';
|
import saveAs from 'file-saver';
|
||||||
import { DEFAULT_PROVIDER, PROVIDERS, replaceProviderUrl } from '$constants/providers';
|
import { replaceProviderUrl } from '$constants/providers';
|
||||||
|
|
||||||
const latLngToTile = latlng => {
|
const latLngToTile = latlng => {
|
||||||
const { map } = editor.map;
|
const { map } = editor.map;
|
||||||
|
@ -119,7 +119,7 @@ export const composePoly = ({ points, ctx }) => {
|
||||||
ctx.strokeStyle = 'red';
|
ctx.strokeStyle = 'red';
|
||||||
ctx.lineCap = 'round';
|
ctx.lineCap = 'round';
|
||||||
ctx.lineJoin = 'round';
|
ctx.lineJoin = 'round';
|
||||||
ctx.lineWidth = CONFIG.STROKE_WIDTH + 0.5;
|
ctx.lineWidth = CLIENT.STROKE_WIDTH + 0.5;
|
||||||
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(points[0].x, points[0].y);
|
ctx.moveTo(points[0].x, points[0].y);
|
||||||
|
|
|
@ -35,7 +35,7 @@ const resolve = {
|
||||||
$containers: join(__dirname, 'src/containers'),
|
$containers: join(__dirname, 'src/containers'),
|
||||||
$constants: join(__dirname, 'src/constants'),
|
$constants: join(__dirname, 'src/constants'),
|
||||||
$sprites: join(__dirname, 'src/sprites'),
|
$sprites: join(__dirname, 'src/sprites'),
|
||||||
$config: join(__dirname, 'src/config'),
|
$config: join(__dirname, './config'),
|
||||||
$styles: join(__dirname, 'src/styles'),
|
$styles: join(__dirname, 'src/styles'),
|
||||||
$redux: join(__dirname, 'src/redux'),
|
$redux: join(__dirname, 'src/redux'),
|
||||||
$utils: join(__dirname, 'src/utils'),
|
$utils: join(__dirname, 'src/utils'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue