My dumb ass didnt have proper auth for calls. grr
This commit is contained in:
parent
10322fefcc
commit
ee3ad51468
10
index.js
10
index.js
|
|
@ -876,14 +876,7 @@ app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
||||||
const ani = Number(req.params.ani);
|
const ani = Number(req.params.ani);
|
||||||
pool.getConnection().then(conn => {
|
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 = ? 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
|
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 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) => {
|
|
||||||
const row = rows[0];
|
const row = rows[0];
|
||||||
if (row) {
|
if (row) {
|
||||||
// Check if the ANI is within the block range
|
// Check if the ANI is within the block range
|
||||||
|
|
@ -907,7 +900,6 @@ app.get('/api/v1/route/:apiKey/:ani/:number', (req, res) => {
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error('Error getting route:', err);
|
console.error('Error getting route:', err);
|
||||||
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)
|
res.status(500).send(`${process.env.MSG_ROUTE_ADDRESS}/500`)
|
||||||
});
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
res.status(401).send(`${process.env.MSG_ROUTE_ADDRESS}/401`)
|
res.status(401).send(`${process.env.MSG_ROUTE_ADDRESS}/401`)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue