My dumb ass didnt have proper auth for calls. grr
This commit is contained in:
parent
10322fefcc
commit
ee3ad51468
12
index.js
12
index.js
|
|
@ -876,14 +876,7 @@ app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
|||
const ani = Number(req.params.ani);
|
||||
pool.getConnection().then(conn => {
|
||||
//conn.query("SELECT * FROM routes WHERE apiKey = ? AND block_start <= ? AND block_start + block_length >= ?", [apiKey, ani, ani]).then((rows) => {
|
||||
conn.query("SELECT * FROM routes WHERE apiKey = ?", [apiKey]).then((rows) => { // We'll try this Nick, if it doesn't work we'll go back to the original
|
||||
const row = rows[0];
|
||||
// If no row or error, return 401
|
||||
if (!row) {
|
||||
res.status(401).send(`${process.env.MSG_ROUTE_ADDRESS}/401`)
|
||||
return;
|
||||
}
|
||||
conn.query('SELECT * FROM routes WHERE block_start <= ? AND block_start + block_length >= ?', [number, number]).then((rows) => {
|
||||
conn.query('SELECT * FROM routes WHERE block_start <= ? AND block_start + block_length >= ? AND apiKey = ?;', [number, number, apiKey]).then((rows) => {
|
||||
const row = rows[0];
|
||||
if (row) {
|
||||
// Check if the ANI is within the block range
|
||||
|
|
@ -907,8 +900,7 @@ app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
|||
}).catch(err => {
|
||||
console.error('Error getting route:', err);
|
||||
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)
|
||||
});
|
||||
}).catch(err => {
|
||||
}).catch(err => {
|
||||
console.error(err);
|
||||
res.status(401).send(`${process.env.MSG_ROUTE_ADDRESS}/401`)
|
||||
}).finally(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue