add usage logging for premium services
This commit is contained in:
@@ -17,7 +17,8 @@
|
|||||||
"connectionString": "",
|
"connectionString": "",
|
||||||
"senderAddress": "apinotifications@enstrayed.com",
|
"senderAddress": "apinotifications@enstrayed.com",
|
||||||
|
|
||||||
"authKeyInDb": "apiAuthKeys.azure"
|
"authKeyInDb": "apiAuthKeys.azure",
|
||||||
|
"usageKeyPrefix": "apiUsage.azure."
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,10 @@ app.post("/sendemail", (rreq,rres) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
azureEmail.beginSend(message).then(ares => {
|
azureEmail.beginSend(message).then(ares => {
|
||||||
|
db.incr(`${globalConfig.azure.usageKeyPrefix}${rreq.get("Authorization")}`)
|
||||||
console.log(`${rreq.get("cf-connecting-ip")} POST /sendemail returned 200 KEY:${rreq.get("Authorization")}`)
|
console.log(`${rreq.get("cf-connecting-ip")} POST /sendemail returned 200 KEY:${rreq.get("Authorization")}`)
|
||||||
rres.sendStatus(200)
|
rres.sendStatus(200)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ app.post("/cider", (rreq,rres) => { // POST stop listening on cider target
|
|||||||
|
|
||||||
fetch(`http://${globalConfig.cider.targetHost}:${globalConfig.cider.targetPort}/stop`).then(fres => { // send GET /stop to cider target
|
fetch(`http://${globalConfig.cider.targetHost}:${globalConfig.cider.targetPort}/stop`).then(fres => { // send GET /stop to cider target
|
||||||
if (fres.status == 204) {
|
if (fres.status == 204) {
|
||||||
|
console.log(`${rreq.get("cf-connecting-ip")} POST /cider returned 200 KEY:${rreq.get("Authorization")}`)
|
||||||
rres.sendStatus(200) // if that works then 200
|
rres.sendStatus(200) // if that works then 200
|
||||||
} else {
|
} else {
|
||||||
rres.sendStatus(500) // otherwise lol
|
rres.sendStatus(500) // otherwise lol
|
||||||
|
|||||||
Reference in New Issue
Block a user