kopia lustrzana https://github.com/FacilMap/facilmap
Serve frontend files from server using express
rodzic
0971e10de6
commit
d56650c549
|
@ -34,6 +34,9 @@
|
||||||
"osmtogeojson": "^2.2.12",
|
"osmtogeojson": "^2.2.12",
|
||||||
"leaflet-fullHash": "https://raw.githubusercontent.com/KoGor/leaflet-fullHash/master/leaflet-fullHash.js"
|
"leaflet-fullHash": "https://raw.githubusercontent.com/KoGor/leaflet-fullHash/master/leaflet-fullHash.js"
|
||||||
},
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"leaflet": "^1.0.1"
|
||||||
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"bootstrap": {
|
"bootstrap": {
|
||||||
"main": [
|
"main": [
|
||||||
|
|
|
@ -17,6 +17,7 @@ var combine = require("stream-combiner");
|
||||||
var sourcemaps = require("gulp-sourcemaps");
|
var sourcemaps = require("gulp-sourcemaps");
|
||||||
var inject = require("gulp-inject");
|
var inject = require("gulp-inject");
|
||||||
var img64 = require("./gulpfile-img64");
|
var img64 = require("./gulpfile-img64");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
var files = [
|
var files = [
|
||||||
"app/**/*.js",
|
"app/**/*.js",
|
||||||
|
@ -36,7 +37,7 @@ gulp.task("clean", function() {
|
||||||
|
|
||||||
gulp.task("deps", function() {
|
gulp.task("deps", function() {
|
||||||
return combine(
|
return combine(
|
||||||
gulp.src(mainBowerFiles({ paths: { bowerDirectory: '../bower_components', bowerJson: '../bower.json' } }), { base: process.cwd() + "/" }),
|
gulp.src(mainBowerFiles({ paths: { bowerDirectory: __dirname + '/../bower_components', bowerJson: __dirname + '/../bower.json' } }), { base: path.resolve(__dirname + "/..") + "/" }),
|
||||||
gulpIf([ "**/*.js", "**/*.css" ], combine(
|
gulpIf([ "**/*.js", "**/*.css" ], combine(
|
||||||
gulpIf("**/*.js", combine(
|
gulpIf("**/*.js", combine(
|
||||||
newer("build/dependencies.js"),
|
newer("build/dependencies.js"),
|
||||||
|
@ -105,7 +106,8 @@ gulp.task("all", [ "deps", "app" ], function() {
|
||||||
sourcemaps.init({ loadMaps: true }),
|
sourcemaps.init({ loadMaps: true }),
|
||||||
concat("all.css"),
|
concat("all.css"),
|
||||||
sourcemaps.write("./sourcemaps")
|
sourcemaps.write("./sourcemaps")
|
||||||
)
|
),
|
||||||
|
gulp.src("deref.html")
|
||||||
),
|
),
|
||||||
gulp.dest("build")
|
gulp.dest("build")
|
||||||
);
|
);
|
||||||
|
@ -115,8 +117,9 @@ gulp.task("index", [ "all" ], function() {
|
||||||
return combine(
|
return combine(
|
||||||
gulp.src("index.html"),
|
gulp.src("index.html"),
|
||||||
img64(),
|
img64(),
|
||||||
|
concat("build/index.html"),
|
||||||
inject(gulp.src([ "build/all.js", "build/all.css" ], { read: false }), { relative: true, removeTags: true }),
|
inject(gulp.src([ "build/all.js", "build/all.css" ], { read: false }), { relative: true, removeTags: true }),
|
||||||
gulp.dest("build")
|
gulp.dest(".")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,6 @@
|
||||||
<!-- inject:js -->
|
<!-- inject:js -->
|
||||||
<!-- endinject -->
|
<!-- endinject -->
|
||||||
|
|
||||||
<script src="http://localhost:40829/socket.io/socket.io.js"></script>
|
<script src="socket.io/socket.io.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -4,11 +4,16 @@
|
||||||
"author": "Candid Dauth <cdauth@cdauth.eu>",
|
"author": "Candid Dauth <cdauth@cdauth.eu>",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server/server.js"
|
"start": "npm run deps && npm run build && npm run server",
|
||||||
|
"deps": "npm update --dev && bower update",
|
||||||
|
"build": "gulp",
|
||||||
|
"server": "node server/server.js",
|
||||||
|
"clean": "gulp clean"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cheerio": "^0.22.0",
|
"cheerio": "^0.22.0",
|
||||||
"compressjs": "^1.0.3",
|
"compressjs": "^1.0.3",
|
||||||
|
"express": "^4.14.0",
|
||||||
"promise": "^7.1.1",
|
"promise": "^7.1.1",
|
||||||
"request": "^2.75.0",
|
"request": "^2.75.0",
|
||||||
"request-promise": "^4.1.1",
|
"request-promise": "^4.1.1",
|
||||||
|
|
|
@ -9,6 +9,10 @@ var routing = require("./routing");
|
||||||
var gpx = require("./gpx");
|
var gpx = require("./gpx");
|
||||||
var search = require("./search");
|
var search = require("./search");
|
||||||
var Promise = require("promise");
|
var Promise = require("promise");
|
||||||
|
var express = require("express");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
|
var frontendPath = path.resolve(__dirname + "/../frontend");
|
||||||
|
|
||||||
Object.defineProperty(Error.prototype, "toJSON", {
|
Object.defineProperty(Error.prototype, "toJSON", {
|
||||||
value: function() {
|
value: function() {
|
||||||
|
@ -25,9 +29,18 @@ Object.defineProperty(Error.prototype, "toJSON", {
|
||||||
|
|
||||||
var dbP = database.connect();
|
var dbP = database.connect();
|
||||||
|
|
||||||
var app = http.createServer();
|
var app = express();
|
||||||
var appP = Promise.denodeify(app.listen.bind(app))(config.port, config.host).then(function() {
|
|
||||||
var io = socketIo.listen(app);
|
app.use(express.static(frontendPath + "/build/"));
|
||||||
|
|
||||||
|
app.get("/:padId", function(req, res) {
|
||||||
|
res.sendFile(frontendPath + "/build/index.html");
|
||||||
|
});
|
||||||
|
|
||||||
|
var server = http.createServer(app);
|
||||||
|
|
||||||
|
var serverP = Promise.denodeify(server.listen.bind(server))(config.port, config.host).then(function() {
|
||||||
|
var io = socketIo.listen(server);
|
||||||
|
|
||||||
io.sockets.on("connection", function(socket) {
|
io.sockets.on("connection", function(socket) {
|
||||||
var d = domain.create();
|
var d = domain.create();
|
||||||
|
@ -309,7 +322,7 @@ var appP = Promise.denodeify(app.listen.bind(app))(config.port, config.host).the
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all([ dbP, appP ]).then(function() {
|
Promise.all([ dbP, serverP ]).then(function() {
|
||||||
console.log("Server started on " + (config.host || "*" ) + ":" + config.port);
|
console.log("Server started on " + (config.host || "*" ) + ":" + config.port);
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
Ładowanie…
Reference in New Issue