Skip to content

Commit

Permalink
Merge pull request #7 from hackoregon/fix/route-and-png
Browse files Browse the repository at this point in the history
Fix/route and png
  • Loading branch information
DingoEatingFuzz authored Oct 27, 2019
2 parents ff65ab6 + b407da0 commit d45b62c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ const app = express();

app.use(cors());

app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function(req, res) {
app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function (req, res) {
const { z, x, y } = req.params;
new MBTiles(path.join(__dirname, "tiles", "tiles.mbtiles"), function(
new MBTiles(path.join(__dirname, "tiles", "tiles.mbtiles"), function (
err,
mbtiles
) {
if (err) {
res.header("Content-Type", "text/plain");
res.status(500).send(`Tile error: ${err}`);
} else {
mbtiles.getTile(z, x, y, function(err, tile, headers) {
mbtiles.getTile(z, x, y, function (err, tile, headers) {
if (err) {
res.header("Content-Type", "text/plain");
res.status(404).send(`Tile error ${err}`);
Expand All @@ -31,13 +31,13 @@ app.get("/tiles/:version/tiles/:z/:x/:y.pbf", function(req, res) {
});
});

const themeHandler = function(req, res) {
const themeHandler = function (req, res) {
let theme = req.params.theme;
if (!theme.endsWith(".json")) {
theme = theme + ".json";
}
const filePath = path.join(__dirname, "themes", theme);
fs.readFile(filePath, "utf8", function(err, file) {
fs.readFile(filePath, "utf8", function (err, file) {
if (err) {
res.status(500);
res.json({ status: 500, message: `Could not load theme: ${err}` });
Expand All @@ -55,11 +55,11 @@ const themeHandler = function(req, res) {
app.get("/tiles/styles/:version/:theme", themeHandler);
app.get("/tiles/:version/:theme", themeHandler);

app.get("/tiles/styles/:version/:theme/sprite.json", function(req, res) {
app.get(["/tiles/styles/:version/:theme/sprite.json", "/tiles/styles/:version/:theme/[email protected]"], function (req, res) {
res.json({});
});

app.get("/tiles/styles/:version/:theme/sprite.png", function(req, res) {
app.get(["/tiles/styles/:version/:theme/sprite.png", "/tiles/styles/:version/:theme/[email protected]"], function (req, res) {
const reader = fs.createReadStream(
path.join(__dirname, "themes", "sprite.png")
);
Expand Down
Binary file modified themes/sprite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d45b62c

Please sign in to comment.