diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aa4f011..cc89360 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,8 +26,21 @@ jobs: uses: pnpm/action-setup@v2 with: version: 8 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies + run: "pnpm install" - name: Build step - run: "pnpm i && npx nuxt build --preset=deno_deploy" + run: "npx nuxt build --preset=deno_deploy" env: NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} - name: Upload to Deno Deploy diff --git a/server/api/[listId]/index.get.ts b/server/api/[listId]/index.get.ts index 608c92c..1b6dc7a 100644 --- a/server/api/[listId]/index.get.ts +++ b/server/api/[listId]/index.get.ts @@ -5,6 +5,8 @@ async function listTodos(kv: Kv, listId: string) { const iter = await kv.list({ prefix: ['list', listId] }, { consistency: 'strong' }) const todos = [] for await (const todo of iter) todos.push(todo.value) + + todos.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)) return todos } diff --git a/server/utils/kv.ts b/server/utils/kv.ts index d2dfafd..0d3a2b7 100644 --- a/server/utils/kv.ts +++ b/server/utils/kv.ts @@ -7,4 +7,8 @@ export const useKv = async () => { const { openKv } = await OpenKV() return openKv('kv.db') } + throw createError({ + statusCode: 500, + message: 'Could not find a Deno KV for production, make sure to deploy on Deno Deploy.' + }) } \ No newline at end of file