feat: clear account tts cache (#176)

* feat: clear account tts cache

* get parsed account_sid
This commit is contained in:
Hoan Luu Huu authored and GitHub committed 2023-06-02 07:40:14 -04:00
1 parent 3c8cbd97c5
commit f3d3afee73
2 files changed
+17 -2

No files matched your search

+16 -2
View File
@@ -1,14 +1,28 @@
const router = require('express').Router();
const {
parseAccountSid
} = require('./utils');
router.delete('/', async(req, res) => {
const {purgeTtsCache} = req.app.locals;
await purgeTtsCache();
const account_sid = parseAccountSid(req);
if (account_sid) {
await purgeTtsCache({account_sid});
} else {
await purgeTtsCache();
}
res.sendStatus(204);
});
router.get('/', async(req, res) => {
const {getTtsSize} = req.app.locals;
const size = await getTtsSize();
const account_sid = parseAccountSid(req);
let size = 0;
if (account_sid) {
size = await getTtsSize(`tts:${account_sid}:*`);
} else {
size = await getTtsSize();
}
res.status(200).json({size});
});