kopia lustrzana https://github.com/FacilMap/facilmap
Adapt structure to add npm bin for facilmap-server
rodzic
986d62b87f
commit
17a3b981ab
|
@ -5,6 +5,15 @@ The FacilMap server is written in [node.js](https://nodejs.org/en/). To run the
|
|||
* You need to create a database on one of the systems supported by [Sequelize](https://sequelize.org/master/), it is recommended to use MySQL/MariaDB. When creating a database for FacilMap, make sure to use the `utf8mb4` charset/collation to make sure that characters from all languages can be used on a map. By default, MySQL/MariaDB uses the `latin1` charset, which mostly supports only basic latin characters. When you start the FacilMap server for the first time, the necessary tables are created using the charset of the database.
|
||||
* It is recommended to run FacilMap as an unprivileged user.
|
||||
|
||||
## Run the latest release
|
||||
|
||||
A bundled version of the FacilMap server is published on NPM as [facilmap-server](https://www.npmjs.com/package/facilmap-server). To run it, run the following steps:
|
||||
|
||||
1. If you don’t have a global NPM prefix set up yet, run `npm config set prefix ~/.local`. This will install npm packages into `~/.local/bin`, rather than trying to install them into `/usr/local/bin`.
|
||||
2. Install facilmap-server by running `npm install -g facilmap-server`
|
||||
3. Create a `config.env` file based on [`config.env.example`](https://github.com/FacilMap/facilmap/blob/master/config.env.example) and to adjust the [configuration](./config).
|
||||
4. Start the FacilMap server by running `~/.local/bin/facilmap-server dotenv_config_path=config.env`.
|
||||
|
||||
|
||||
## Run the development version
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"url": "https://github.com/FacilMap/facilmap.git"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"README.md",
|
||||
"tsconfig.json"
|
||||
|
@ -25,14 +26,16 @@
|
|||
"scripts": {
|
||||
"start": "npm run deps && npm run server",
|
||||
"deps": "npm install",
|
||||
"server": "ts-node --transpile-only src/server.ts",
|
||||
"dev-server": "FM_DEV=true ts-node --transpile-only src/server.ts",
|
||||
"build": "tsc; chmod +x dist/server.js",
|
||||
"clean": "rimraf dist",
|
||||
"server": "dist/server.js dotenv_config_path=../config.env",
|
||||
"dev-server": "FM_DEV=true ts-node --transpile-only src/server.ts dotenv_config_path=../config.env",
|
||||
"test": "jest",
|
||||
"types": "tsc --noEmit src/**/*.ts",
|
||||
"lint": "eslint src/**/*.ts"
|
||||
},
|
||||
"bin": {
|
||||
"facilmap-server": "ts-node --transpile-only src/server.ts"
|
||||
"facilmap-server": "./dist/server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mapbox/polyline": "^1.1.1",
|
||||
|
@ -94,6 +97,7 @@
|
|||
"@types/string-similarity": "^4.0.0",
|
||||
"debug": "^4.3.1",
|
||||
"jest": "^26.6.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.4.4",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3",
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Options as SequelizeOptions } from "sequelize";
|
||||
import { config as dotenv } from "dotenv";
|
||||
|
||||
dotenv({ path: `${__dirname}/../../config.env`});
|
||||
import "dotenv/config";
|
||||
|
||||
export interface DbConfig {
|
||||
type: SequelizeOptions['dialect'];
|
||||
|
@ -25,7 +23,7 @@ interface Config {
|
|||
}
|
||||
|
||||
const config: Config = {
|
||||
userAgent: process.env.USER_AGENT || 'FacilMap (https://facilmap.org/)',
|
||||
userAgent: process.env.USER_AGENT || 'FacilMap',
|
||||
host: process.env.HOST || undefined,
|
||||
port: process.env.PORT ? Number(process.env.PORT) : 8080,
|
||||
db : {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DataTypes, HasManyGetAssociationsMixin, Model, Op } from "sequelize";
|
||||
import { BboxWithZoom, ID, Latitude, Line, LineCreate, ExtraInfo, LineUpdate, Longitude, PadId, Point, Route, TrackPoint } from "../../../types/src";
|
||||
import { BboxWithZoom, ID, Latitude, Line, LineCreate, ExtraInfo, LineUpdate, Longitude, PadId, Point, Route, TrackPoint } from "facilmap-types";
|
||||
import Database from "./database";
|
||||
import { BboxWithExcept, dataDefinition, DataModel, getLatType, getLonType, makeBboxCondition, makeNotNullForeignKey, validateColour } from "./helpers";
|
||||
import { isEqual, mapValues } from "lodash";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DataTypes, Model } from "sequelize";
|
||||
import { BboxWithZoom, ID, Latitude, Longitude, Marker, MarkerCreate, MarkerUpdate, PadId } from "../../../types/src";
|
||||
import { BboxWithZoom, ID, Latitude, Longitude, Marker, MarkerCreate, MarkerUpdate, PadId } from "facilmap-types";
|
||||
import { BboxWithExcept, dataDefinition, DataModel, getLatType, getLonType, makeBboxCondition, makeNotNullForeignKey, validateColour } from "./helpers";
|
||||
import Database from "./database";
|
||||
import { getElevationForPoint } from "../elevation";
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Model } from "sequelize";
|
||||
import { DataTypes, Op } from "sequelize";
|
||||
import { PadData, PadDataCreate, PadDataUpdate, PadId } from "../../../types/src";
|
||||
import { DataTypes, Model, Op } from "sequelize";
|
||||
import { PadData, PadDataCreate, PadDataUpdate, PadId } from "facilmap-types";
|
||||
import Database from "./database";
|
||||
import { streamEachPromise } from "../utils/streams";
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { generateRandomId } from "../utils/utils";
|
||||
import { DataTypes, Model, Op } from "sequelize";
|
||||
import Database from "./database";
|
||||
import { BboxWithZoom, ID, Latitude, Longitude, PadId, Point, Route, RouteMode, TrackPoint } from "../../../types/src";
|
||||
import { BboxWithZoom, ID, Latitude, Longitude, PadId, Point, Route, RouteMode, TrackPoint } from "facilmap-types";
|
||||
import { BboxWithExcept, getLatType, getLonType, makeBboxCondition } from "./helpers";
|
||||
import { WhereOptions } from "sequelize/types/lib/model";
|
||||
import { calculateRouteForLine } from "../routing/routing";
|
||||
|
@ -172,7 +172,11 @@ export default class DatabaseRoutes {
|
|||
time: line.time,
|
||||
ascent: line.ascent,
|
||||
descent: line.descent,
|
||||
extraInfo: line.extraInfo
|
||||
extraInfo: line.extraInfo,
|
||||
top: line.top,
|
||||
left: line.left,
|
||||
bottom: line.bottom,
|
||||
right: line.right
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Sequelize, { Model } from "sequelize";
|
||||
import { Field, ID, PadId, Type, TypeCreate, TypeUpdate } from "../../../types/src";
|
||||
import { Field, ID, PadId, Type, TypeCreate, TypeUpdate } from "facilmap-types";
|
||||
import Database from "./database";
|
||||
import { makeNotNullForeignKey, validateColour } from "./helpers";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { DataTypes, Model } from "sequelize";
|
||||
import { ID, Latitude, Longitude, PadId, View, ViewCreate, ViewUpdate } from "../../../types/src";
|
||||
import { ID, Latitude, Longitude, PadId, View, ViewCreate, ViewUpdate } from "facilmap-types";
|
||||
import Database from "./database";
|
||||
import { getLatType, getLonType, makeNotNullForeignKey } from "./helpers";
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import highland from "highland";
|
||||
import { Point } from "../../types/src";
|
||||
import { Point } from "facilmap-types";
|
||||
|
||||
// const API_URL = "https://elevation.mapzen.com/height";
|
||||
// const LIMIT = 500;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { jsonStream, streamToArrayPromise, toStream } from "../utils/streams";
|
||||
import { clone } from "../utils/utils";
|
||||
import { compileExpression } from "facilmap-utils";
|
||||
import { Marker, PadId } from "../../../types/src";
|
||||
import { Marker, MarkerFeature, LineFeature, PadId } from "facilmap-types";
|
||||
import Database from "../database/database";
|
||||
import { keyBy, mapValues, omit } from "lodash";
|
||||
import { LineWithTrackPoints } from "../database/line";
|
||||
import { MarkerFeature, LineFeature } from "facilmap-types";
|
||||
|
||||
export function exportGeoJson(database: Database, padId: PadId, filter?: string): Highland.Stream<string> {
|
||||
return toStream(async () => {
|
||||
|
|
|
@ -47,7 +47,7 @@ async function download() {
|
|||
const res = await new Promise<IncomingMessage>((resolve, reject) => {
|
||||
https.get(url + (currentMd5 || ""), {
|
||||
headers: {
|
||||
Authorization: `Basic ${new Buffer(config.maxmindUserId + ':' + config.maxmindLicenseKey).toString('base64')}`
|
||||
Authorization: `Basic ${Buffer.from(config.maxmindUserId + ':' + config.maxmindLicenseKey).toString('base64')}`
|
||||
}
|
||||
}, resolve).on("error", reject);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { calculateBbox, isInBbox } from "../utils/geo";
|
||||
import { Bbox, BboxWithZoom, Point, RouteMode, TrackPoint } from "../../../types/src";
|
||||
import { Bbox, BboxWithZoom, LineCreate, Point, Route, RouteInfo, RouteMode, TrackPoint } from "facilmap-types";
|
||||
import { decodeRouteMode, DecodedRouteMode, calculateDistance } from "facilmap-utils";
|
||||
import { LineCreate, Route, RouteInfo } from "facilmap-types";
|
||||
import { calculateOSRMRoute } from "./osrm";
|
||||
import { calculateORSRoute, getMaximumDistanceBetweenRoutePoints } from "./ors";
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Bbox, Point } from "facilmap-types";
|
||||
import { Latitude } from "../../../types/src";
|
||||
import { Bbox, Latitude, Point } from "facilmap-types";
|
||||
|
||||
const R = 6371; // km
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "CommonJS",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
|
|
|
@ -8,12 +8,18 @@
|
|||
},
|
||||
"license": "AGPL-3.0",
|
||||
"author": "Candid Dauth <cdauth@cdauth.eu>",
|
||||
"main": "./src/index.ts",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FacilMap/facilmap.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"README.md",
|
||||
"tsconfig.json"
|
||||
|
@ -21,5 +27,8 @@
|
|||
"dependencies": {
|
||||
"@types/geojson": "^7946.0.7"
|
||||
},
|
||||
"devDependencies": {}
|
||||
"devDependencies": {
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.2.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es3",
|
||||
"target": "esnext",
|
||||
"module": "CommonJS",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
|
@ -8,7 +9,6 @@
|
|||
"outDir": "dist",
|
||||
"moduleResolution": "node",
|
||||
"noErrorTruncation": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
|
@ -12,16 +12,20 @@
|
|||
},
|
||||
"license": "AGPL-3.0",
|
||||
"author": "Candid Dauth <cdauth@cdauth.eu>",
|
||||
"main": "./src/index.ts",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FacilMap/facilmap.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rimraf dist",
|
||||
"types": "tsc --noEmit src/*",
|
||||
"lint": "eslint src/*"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"README.md",
|
||||
"tsconfig.json"
|
||||
|
@ -47,6 +51,7 @@
|
|||
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
||||
"@typescript-eslint/parser": "^4.18.0",
|
||||
"jest": "^26.6.3",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typescript": "^4.2.3"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "CommonJS",
|
||||
"esModuleInterop": true,
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
|
@ -9,8 +10,7 @@
|
|||
"moduleResolution": "node",
|
||||
"noErrorTruncation": true,
|
||||
"skipLibCheck": true,
|
||||
"experimentalDecorators": true,
|
||||
"noEmit": true
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
|
@ -8415,7 +8415,7 @@ typedarray@^0.0.6:
|
|||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||
|
||||
typescript@^4.1.3, typescript@^4.2.3:
|
||||
typescript@^4.1.3, typescript@^4.2.3, typescript@^4.2.4:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
|
||||
integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
|
||||
|
|
Ładowanie…
Reference in New Issue