Skip to content

Commit

Permalink
update nuxt demo, add notion-client endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Nov 10, 2022
1 parent 96cea06 commit cfb9b0d
Show file tree
Hide file tree
Showing 5 changed files with 1,666 additions and 943 deletions.
2 changes: 1 addition & 1 deletion demo/nuxt/app.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts"></script>

<template>
<NuxtChild></NuxtChild>
<NuxtPage></NuxtPage>
</template>

<style>
Expand Down
3 changes: 2 additions & 1 deletion demo/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"start": "node .output/server/index.mjs"
},
"dependencies": {
"nuxt": "^3.0.0-rc.3",
"notion-client": "^6.15.6",
"nuxt": "^3.0.0-rc.12",
"vue3-notion": "^0.1.35"
}
}
10 changes: 10 additions & 0 deletions demo/nuxt/server/api/page/[pageId].ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NotionAPI } from "notion-client";

export default defineEventHandler(async (event) => {
const pageId = event.context.params.pageId;

const api = new NotionAPI();
const page = await api.getPage(pageId.toString());

return page;
});
10 changes: 3 additions & 7 deletions demo/nuxt/server/middleware/swr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import type { IncomingMessage, ServerResponse } from "http"

export default (_req: IncomingMessage, res: ServerResponse, next: () => void) => {
// cache for 2 mins (120 seconds)
res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate")
next()
}
export default defineEventHandler((event) => {
event.res.setHeader("Cache-Control", "s-maxage=120, stale-while-revalidate");
});
Loading

0 comments on commit cfb9b0d

Please sign in to comment.