Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit 9fa09f6

Browse files
authored
Merge pull request #23 from patrixr/support-publishing-endpoint
ADD: Support for publishing api
2 parents 9dac9da + dd29707 commit 9fa09f6

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

lib/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,15 @@ const Cache = (strapi) => {
134134
}
135135
};
136136

137-
router.post('/content-manager/explorer/:scope', bustAdmin);
138-
router.put('/content-manager/explorer/:scope/:id*', bustAdmin);
139-
router.delete('/content-manager/explorer/:scope/:id*', bustAdmin);
137+
router.post('/content-manager/explorer/:scope', bustAdmin);
138+
router.post('/content-manager/explorer/:scope/publish/:id*', bustAdmin);
139+
router.post('/content-manager/explorer/:scope/unpublish/:id*', bustAdmin);
140+
router.put('/content-manager/explorer/:scope/:id*', bustAdmin);
141+
router.delete('/content-manager/explorer/:scope/:id*', bustAdmin);
140142

141143
strapi.app.use(router.routes());
142144
},
143145
};
144146
};
145147

146-
module.exports = Cache;
148+
module.exports = Cache;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "strapi-middleware-cache",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
44
"description": "Cache strapi requests",
55
"main": "./lib",
66
"scripts": {

tests/cache.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ describe('Caching', () => {
114114
expect(res3.body.uid).to.equal(res2.body.uid + 1);
115115
expect(requests).to.have.lengthOf(3);
116116
});
117+
118+
it(`busts the cache on an admin panel ${method.toUpperCase()} publishing change`, async () => {
119+
const res1 = await agent(strapi.app).get('/academies').expect(200);
120+
121+
expect(requests).to.have.lengthOf(1);
122+
123+
const res2 = await agent(strapi.app)[method]('/content-manager/explorer/application::academy.academy/publish/1').expect(200);
124+
125+
expect(res2.body.uid).to.equal(res1.body.uid + 1);
126+
expect(requests).to.have.lengthOf(2);
127+
128+
const res3 = await agent(strapi.app).get('/academies').expect(200);
129+
130+
expect(res3.body.uid).to.equal(res2.body.uid + 1);
131+
expect(requests).to.have.lengthOf(3);
132+
});
117133
});
118134
});
119135

0 commit comments

Comments
 (0)