forked from anneb/pgserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclearcache.js
33 lines (33 loc) · 896 Bytes
/
clearcache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module.exports = function (app, cache) {
/**
* @swagger
*
* /admin/clearcache/{table}:
* get:
* description: clears the cache for the specified table.
* tags: ['meta']
* summary: 'clear cache for the specified table'
* produces:
* - application/json
* parameters:
* - name: table
* description: The name of the table
* in: path
* required: true
* type: string
* responses:
* 200:
* description: result
* 422:
* description: table not found or not accessible
*/
app.get('/clearcache/:table', async (req, res)=> {
const cacheDir = `${req.params.table}`;
try {
await cache.clearCache(cacheDir);
return res.json({result: 'ok', message: `cache cleared for ${req.params.table}`})
} catch(err) {
res.status(500).json({error:err.message})
}
});
}