Skip to content

Commit 68c023b

Browse files
committed
fix(ci): upload club data to netlify blobs
1 parent eb7d491 commit 68c023b

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

netlify/functions/update-club-info-background.mts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import type { Config } from '@netlify/functions'
1+
import type { Config, Context } from '@netlify/functions'
2+
import { getStore } from '@netlify/blobs'
3+
import type { Clubs } from '~/types/clubs'
24
import updateClubInfo from '~/utils/update-club-info'
35

4-
export default async () => {
5-
await updateClubInfo()
6+
export default async (context: Context) => {
7+
const store = getStore('enspire')
8+
const clubs: Clubs = await updateClubInfo()
9+
await store.setJSON('clubs', clubs)
10+
11+
return new Response('Done')
612
}
713

814
export const config: Config = {

nuxt.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ export default defineNuxtConfig({
1010
dir: '/data',
1111
repo: 'computerization/enspire',
1212
},
13-
netlify: {
14-
driver: 'netlify',
15-
name: 'enspire',
16-
},
1713
},
1814
},
1915

server/api/club/all_details.get.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { getStore } from '@netlify/blobs'
2+
13
export default defineCachedEventHandler(async (event) => {
24
const { auth } = event.context
35

@@ -6,5 +8,5 @@ export default defineCachedEventHandler(async (event) => {
68
return
79
}
810

9-
return await useStorage('netlify').getItem('clubs')
11+
return await getStore('enspire').get('clubs', { type: 'json' })
1012
}, { maxAge: 60 * 60 * 4 /* 4 hours */ })

utils/crawler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,5 @@ export default async function main(): Promise<Clubs> {
6464
}
6565
}
6666

67-
await useStorage('netlify').setItem('clubs', output)
68-
6967
return output
7068
}

utils/update-club-info.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export default async function main() {
127127
// eslint-disable-next-line no-console
128128
console.log(`start transaction with length ${runSequence.length}`)
129129
await prisma.$transaction(runSequence)
130+
131+
return clubs
130132
}
131133

132134
main()

0 commit comments

Comments
 (0)