Skip to content

Commit

Permalink
Merge pull request #27 from racemap/status-report-with-random-check
Browse files Browse the repository at this point in the history
Status report with random check
  • Loading branch information
karlTGA authored Apr 19, 2024
2 parents 8932d58 + 1004028 commit 1bd5958
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 181 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
node_modules/

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14
FROM node:20.12.2

COPY . /app
WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions hgt.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function bufferStream(stream) {
bufs.push(d);
});
stream.on('end', () => {
console.log("end")
console.log('end');
resolve(Buffer.concat(bufs));
});
stream.on('error', (err) => {
console.log("error")
console.log('error');
reject(err);
});
});
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ async function handleGET(req, res) {
async function handleGETStatus(req, res) {
try {
// try to receive a test value
await tiles.getElevation([0, 0]);
const randomLng = Math.random() * 360 - 180;
const randomLat = Math.random() * 180 - 90;

await tiles.getElevation([randomLat, randomLng]);
return send(res, 200, 'Ok');
} catch (error) {
console.error('Status Check Failed!');
Expand All @@ -75,7 +78,7 @@ async function handler(req, res) {
case 'POST':
return await handlePOST(req, res);
case 'GET':
if (req.url == '/status') {
if (req.url === '/status') {
return await handleGETStatus(req, res);
} else {
return await handleGET(req, res);
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elevation-service",
"version": "0.0.1",
"version": "1.1.0",
"main": "index.js",
"scripts": {
"start": "micro index.js",
Expand All @@ -11,12 +11,10 @@
"license": "MIT",
"dependencies": {
"limited-map": "^0.0.1",
"lru-memoize": "^1.0.2",
"memoizee": "^0.4.14",
"micro": "^9.3.2",
"micro": "^10.0.1",
"micro-cors": "^0.1.1",
"micro-query": "^0.3.0",
"node-fetch": "^2.6.1"
"micro-query": "^0.3.0"
},
"devDependencies": {
"prettier": "^2.2.1"
Expand Down
5 changes: 3 additions & 2 deletions tileset.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path');
const fetch = require('node-fetch');
const memoize = require('memoizee');
const { readFile } = require('fs/promises');
const { promisify } = require('util');
Expand Down Expand Up @@ -56,7 +55,9 @@ class FileTileSet extends TileSet {
class S3TileSet extends TileSet {
async _getTile(lat, lng) {
// console.log(`${S3TileSet.baseUrl}/${this.getFilePath(lat, lng)}`);
let buffer = await fetch(`${S3TileSet.baseUrl}/${this.getFilePath(lat, lng)}`).then(r => r.arrayBuffer());
let buffer = await fetch(`${S3TileSet.baseUrl}/${this.getFilePath(lat, lng)}`).then((r) =>
r.arrayBuffer(),
);
if (this.options.gzip) {
buffer = Buffer.from(await promisify(gunzip)(buffer));
}
Expand Down
Loading

0 comments on commit 1bd5958

Please sign in to comment.