Skip to content

Commit 373c948

Browse files
committed
Add playground
1 parent 62ccded commit 373c948

File tree

16 files changed

+250
-44
lines changed

16 files changed

+250
-44
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ coverage
5454
Network Trash Folder
5555
Temporary Items
5656
.apdisk
57+
58+
*.db

playground/app.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<template>
22
<div>
3-
Nuxt module playground!
3+
<NuxtPage />
44
</div>
55
</template>
6-
7-
<script setup>
8-
</script>

playground/lib/prisma.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { PrismaClient } from '@prisma/client'
2+
3+
const prisma = new PrismaClient()
4+
5+
export {
6+
prisma
7+
}

playground/lib/todo.server.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { prisma } from './prisma'
2+
3+
export async function getTodos () {
4+
const todos = await prisma.todo.findMany()
5+
return todos
6+
}
7+
8+
export async function getTodo (id: number) {
9+
const todo = await prisma.todo.findFirstOrThrow({
10+
where: {
11+
id
12+
}
13+
})
14+
return todo
15+
}

playground/nuxt.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ import MyModule from '..'
44
export default defineNuxtConfig({
55
modules: [
66
MyModule
7-
],
8-
myModule: {
9-
addPlugin: true
10-
}
7+
]
118
})

playground/package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
{
2-
"private": true,
3-
"name": "my-module-playground"
2+
"name": "playground",
3+
"devDependencies": {
4+
"esno": "^0.16.3",
5+
"prisma": "^4.6.1"
6+
},
7+
"prisma": {
8+
"seed": "esno prisma/seed.ts",
9+
"schema": "./prisma/schema.prisma"
10+
},
11+
"dependencies": {
12+
"@prisma/client": "^4.6.1"
13+
}
414
}

playground/pages/index.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import { getTodos } from '~~/lib/todo.server'
3+
4+
const todos = await getTodos()
5+
</script>
6+
7+
<template>
8+
<div>
9+
<ul>
10+
<li>
11+
<NuxtLink v-for="todo in todos" :key="todo.id" :to="`/todos/${todo.id}`">
12+
{{ todo.title }}
13+
</NuxtLink>
14+
</li>
15+
</ul>
16+
</div>
17+
</template>

playground/pages/todos/[id].vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script setup lang="ts">
2+
import { getTodo } from '~~/lib/todo.server'
3+
import { useRoute } from '#imports'
4+
5+
const route = useRoute()
6+
const todo = await getTodo(Number(route.params.id))
7+
</script>
8+
9+
<template>
10+
<div>
11+
Todo: {{ todo }}
12+
</div>
13+
</template>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- CreateTable
2+
CREATE TABLE "Todo" (
3+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
4+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
"updatedAt" DATETIME NOT NULL,
6+
"title" TEXT NOT NULL,
7+
"completed" BOOLEAN NOT NULL,
8+
"content" TEXT
9+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Please do not edit this file manually
2+
# It should be added in your version-control system (i.e. Git)
3+
provider = "sqlite"

0 commit comments

Comments
 (0)