Skip to content

Commit 182fffa

Browse files
committed
feat: increment install_count on each install script request
1 parent df610ed commit 182fffa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/hooks.server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const handle: Handle = async ({ event, resolve }) => {
2929
if (isCurl || !isBrowser) {
3030
const script = generateInstallScript(config.username, config.slug, config.custom_script, config.dotfiles_repo || '');
3131

32+
env.DB.prepare('UPDATE configs SET install_count = install_count + 1 WHERE alias = ?').bind(alias).run().catch(() => {});
33+
3234
return new Response(script, {
3335
headers: {
3436
'Content-Type': 'text/plain; charset=utf-8',
@@ -61,6 +63,8 @@ export const handle: Handle = async ({ event, resolve }) => {
6163
if (config && config.is_public) {
6264
const script = generateInstallScript(username, slug, config.custom_script, config.dotfiles_repo || '');
6365

66+
env.DB.prepare('UPDATE configs SET install_count = install_count + 1 WHERE user_id = ? AND slug = ?').bind(user.id, slug).run().catch(() => {});
67+
6468
return new Response(script, {
6569
headers: {
6670
'Content-Type': 'text/plain; charset=utf-8',

0 commit comments

Comments
 (0)