@@ -133,8 +133,8 @@ app.get('/colors{/:index}', async (req, res) => {
133133// })
134134
135135app . all ( '/vt/:type/:hash' , async ( req , res , next ) => {
136- if ( req . method === 'PURGE' ) {
137- debug ( ' PURGE:' , req . originalUrl )
136+ if ( [ 'PURGE' , 'POST' ] . includes ( req . method ) ) {
137+ debug ( ` PURGE: ${ req . method } ` , req . originalUrl )
138138 if ( ! [ 'id' , 'sha' ] . includes ( req . params . type ) ) return next ( )
139139 const hash = req . params . hash . includes ( ':' )
140140 ? req . params . hash . split ( ':' ) [ 1 ]
@@ -167,8 +167,8 @@ app.get('/vt/:type/:hash', async (req, res) => {
167167} )
168168
169169app . all ( '/vt/:owner/:repo/:asset{/:tag}' , async ( req , res , next ) => {
170- if ( req . method === 'PURGE' ) {
171- debug ( ' PURGE:' , req . originalUrl )
170+ if ( [ 'PURGE' , 'POST' ] . includes ( req . method ) ) {
171+ debug ( ` PURGE: ${ req . method } ` , req . originalUrl )
172172 const tag = req . params . tag || 'latest'
173173 const key = `${ req . params . owner } /${ req . params . repo } /${ req . params . asset } /${ tag } `
174174 return purgeKey ( res , key )
@@ -189,8 +189,8 @@ app.get('/vt/:owner/:repo/:asset{/:tag}', async (req, res) => {
189189} )
190190
191191app . all ( '/ghcr/tags/:owner/:package{/:latest}' , async ( req , res , next ) => {
192- if ( req . method === 'PURGE' ) {
193- debug ( ' PURGE:' , req . originalUrl )
192+ if ( [ 'PURGE' , 'POST' ] . includes ( req . method ) ) {
193+ debug ( ` PURGE: ${ req . method } ` , req . originalUrl )
194194 const key = `ghcr/tags/${ req . params . owner } /${ req . params . package } /tags/list`
195195 return purgeKey ( res , key )
196196 }
@@ -233,8 +233,8 @@ app.get('/ghcr/tags/:owner/:package{/:latest}', async (req, res) => {
233233} )
234234
235235app . all ( '/ghcr/size/:owner/:package{/:tag}' , async ( req , res , next ) => {
236- if ( req . method === 'PURGE' ) {
237- debug ( ' PURGE:' , req . originalUrl )
236+ if ( [ 'PURGE' , 'POST' ] . includes ( req . method ) ) {
237+ debug ( ` PURGE: ${ req . method } ` , req . originalUrl )
238238 const tag = req . params . tag ? req . params . tag : 'latest'
239239 const key = `ghcr/size/${ req . params . owner } /${ req . params . package } /${ tag } `
240240 return purgeKey ( res , key )
@@ -270,8 +270,8 @@ app.get('/static/:message{/:label}', async (req, res) => {
270270
271271app . all ( '/:type/:url/:path' , async ( req , res , next ) => {
272272 if ( ! [ 'yaml' , 'json' ] . includes ( req . params . type ) ) return next ( )
273- if ( req . method === 'PURGE' ) {
274- debug ( ' PURGE:' , req . originalUrl )
273+ if ( [ 'PURGE' , 'POST' ] . includes ( req . method ) ) {
274+ debug ( ` PURGE: ${ req . method } ` , req . originalUrl )
275275 return purgeKey ( res , req . path )
276276 }
277277 next ( )
@@ -431,6 +431,11 @@ async function purgeKey(res, key) {
431431 const result = await cacheDelete ( key )
432432 debug ( 'result:' , result )
433433 res . send ( result . toString ( ) )
434+ if ( result ) {
435+ incrKey ( 'purge_hit' ) . catch ( console . error )
436+ } else {
437+ incrKey ( 'purge_miss' ) . catch ( console . error )
438+ }
434439}
435440
436441/**
0 commit comments