Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
o0shojo0o committed Nov 11, 2023
1 parent 77d6c4f commit e69df56
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Install dependencies with `npm install` and run dev server with `npn run dev`.

## Changelog

### 1.8.1 (2023-11-11)

- (o0shojo0o) small fixes

### 1.8.0 (2023-11-11)

- (o0shojo0o) only active telemetry users can see statistics
Expand Down
9 changes: 5 additions & 4 deletions libs/pixelItRepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ async function getBMPByID(id) {
a.id = ?`,
id
)
if (result[0][0]) {
result[0][0].animated = tools.mysqlToBool(result[0][0].animated)
return result[0][0]
}

result[0][0].animated = tools.mysqlToBool(result[0][0].animated)

return result[0][0]
} catch (error) {
log.error('getBMPByID: {error}', { error: error })
return null
return undefined
}
};

Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ app.get('/api/GetBMPByID/:id', async (req, res) => {
return;
}

const bmp = (await cache.getOrSet(`GetBMPByID_${id}`, () => { return repo.getBMPByID(id) }, 0)) ?? {};
const bmp = (await cache.getOrSet(`GetBMPByID_${id}`, () => { return repo.getBMPByID(id) }, 0));

if (!bmp) {
log.warn('{apiPath}: BMP ID: {id} is not valide', { apiPath: 'GetBMPByID', id: id, sourceIP, rawUrl, useragent: req.useragent, rateLimit: req.rateLimit, });
res.status(400).send(`BMP ID: ${id} is not valide`);
return;
}

log.info('{apiPath}: BMP with ID {id} and name {name} successfully delivered', { apiPath: 'GetBMPByID', id: bmp.id, name: bmp.name, sourceIP, rawUrl, useragent: req.useragent, rateLimit: req.rateLimit, });
res.send(bmp);
Expand Down

0 comments on commit e69df56

Please sign in to comment.