Skip to content

Commit

Permalink
Add API metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-lippert committed Dec 20, 2023
1 parent 0032435 commit 0d1a538
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,25 @@ export class Counter {
}

const retval = {
key: pathname.replace(/^\/(api\/?)?/, ''),
value: this.value,
count: origin + pathname,
read: origin + pathname + '?read',
reset: origin + pathname + '?reset',
callbacks: this.callback?.length ? this.callback : undefined,
api: {
icon: '🧛',
name: 'count.do',
description: 'A simple counter with callbacks',
url: 'https://count.do/',
type: 'https://apis.do/tools',
endpoints: {
count: origin + pathname,
read: origin + pathname + '?read',
reset: origin + pathname + '?reset',
},
site: 'https://count.do',
repo: 'https://github.com/drivly/count.do',
},
data: {
key: pathname.replace(/^\/(api\/?)?/, ''),
value: this.value,
callbacks: this.callback?.length ? this.callback : undefined,
},
}
return new Response(JSON.stringify(retval, null, 2), { headers: { 'content-type': 'application/json' } })
}
Expand Down

0 comments on commit 0d1a538

Please sign in to comment.