Skip to content

Commit

Permalink
Migration to drizzle to support cloudflare worker officially
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Apr 7, 2024
1 parent b9b4e89 commit d28ed10
Show file tree
Hide file tree
Showing 51 changed files with 2,341 additions and 512 deletions.
Binary file modified bun.lockb
Binary file not shown.
11 changes: 11 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Config } from 'drizzle-kit';

export default {
schema: './server/db/schema.ts',
out: './server/db/drizzle',
driver: 'turso',
dbCredentials: {
url: process.env.DB_URL!,
authToken: process.env.DB_AUTH_TOKEN!,
},
} satisfies Config;
7 changes: 4 additions & 3 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ const { __dirname } = createCommonJS(import.meta.url)

export default defineNuxtConfig({
runtimeConfig: {
JWT_KEY: '',
JWT_KEY: 'f4c0f54576b147238afe4c237faf1ebf',
},
nitro: {
preset: 'bun',
preset: 'cloudflare-pages',
experimental: {
openAPI: true
},
// node: true,
},
imports: {
presets: [{
from: '@tanstack/vue-query',
imports: ['useMutation']
},]
}]
},
vite: {
define: {
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"dev": "HOST=localhost nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"prisma:generate": "prisma generate",
"prisma:migrate": "prisma migrate dev",
"postinstall": "nuxt prepare",
"lint": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint:fix": "eslint --fix --ext \".js,.vue\" --ignore-path .gitignore .",
Expand All @@ -19,12 +17,13 @@
"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/s3-request-presigner": "^3.540.0",
"@hebilicious/vue-query-nuxt": "^0.3.0",
"@libsql/client": "^0.6.0",
"@pinia/nuxt": "^0.5.1",
"@prisma/client": "^5.11.0",
"@tanstack/vue-query": "^5.28.9",
"chart.js": "3.3.2",
"drizzle-orm": "^0.30.7",
"h3": "^1.11.1",
"jsonwebtoken": "^9.0.2",
"jose": "^5.2.4",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"pg": "^8.11.3",
Expand All @@ -36,11 +35,11 @@
},
"devDependencies": {
"@babel/eslint-parser": "^7.18.9",
"@types/jsonwebtoken": "^9.0.6",
"@types/lodash": "^4.17.0",
"@types/pg": "^8.11.4",
"@types/uuid": "^9.0.8",
"autoprefixer": "^10.4.19",
"drizzle-kit": "^0.20.14",
"eslint": "^8.30.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-nuxt": "^4.0.0",
Expand All @@ -50,7 +49,6 @@
"nuxt-primevue": "^0.3.1",
"postcss": "^8.4.38",
"prettier": "2.7.1",
"prisma": "^5.11.0",
"sass": "^1.60.0",
"sass-loader": "^10.4.1",
"tailwindcss": "^3.4.3"
Expand Down
10 changes: 7 additions & 3 deletions pages/apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const orgsStore = useOrgsStore()
const onRowSelect = (event: any) => {
const appName = event.data.name
console.log(event.data)
const orgName = event.data.Organization.name
const orgName = event.data.organization.name
navigateTo(`/orgs/${orgName}/apps/${appName}`)
};
Expand Down Expand Up @@ -85,6 +85,10 @@ const search = (e: any) => {
}, _.isEmpty)
}
const upperCase = (value: string | null | undefined) => {
return value?.toUpperCase()
}
</script>

<template>
Expand Down Expand Up @@ -126,7 +130,7 @@ const search = (e: any) => {
<div class="flex flex-row gap-3 items-center px-3 py-2">
<div class="rounded flex items-center justify-center"
style="height: 34px; width: 34px; background-color: #ece9fc; color: #2a1261">
<label class="text-2xl">{{ _.upperCase(prop.data.displayName[0]) }}</label>
<label class="text-2xl">{{ upperCase(prop.data.displayName[0]) }}</label>
</div>
<label class="font-semibold text-lg">{{ prop.data.displayName }}</label>
</div>
Expand All @@ -139,7 +143,7 @@ const search = (e: any) => {
</Column>
<Column header="Owner" v-if="!isOrg">
<template #body="prop">
{{ prop.data.Organization.name }}
{{ prop.data.organization.name }}
</template>
</Column>
<template #empty>
Expand Down
Binary file removed prisma/data/app.db
Binary file not shown.
50 changes: 0 additions & 50 deletions prisma/migrations/20240330222807_/migration.sql

This file was deleted.

19 changes: 0 additions & 19 deletions prisma/migrations/20240402001549_/migration.sql

This file was deleted.

17 changes: 0 additions & 17 deletions prisma/migrations/20240403222737_/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20240403223916_/migration.sql

This file was deleted.

26 changes: 0 additions & 26 deletions prisma/migrations/20240404165653_/migration.sql

This file was deleted.

8 changes: 0 additions & 8 deletions prisma/migrations/20240404171110_/migration.sql

This file was deleted.

2 changes: 0 additions & 2 deletions prisma/migrations/20240404225428_/migration.sql

This file was deleted.

12 changes: 0 additions & 12 deletions prisma/migrations/20240404225611_/migration.sql

This file was deleted.

3 changes: 0 additions & 3 deletions prisma/migrations/migration_lock.toml

This file was deleted.

91 changes: 0 additions & 91 deletions prisma/schema.prisma

This file was deleted.

13 changes: 7 additions & 6 deletions server/api/add-me-to-org.get.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { organizationsPeople } from "../db/schema"

export default defineEventHandler(async ({ context }) => {
const userId = context.auth.userId
const org = await context.prisma.organizations.findFirstOrThrow()
await context.prisma.organizationsPeople.create({
data: {
organizationId: org.id,
userId: userId,
},
const db = context.drizzle
const org = await db.query.organizations.findFirst()
await db.insert(organizationsPeople).values({
organizationId: org!.id,
userId: userId,
})
return {}
})
Loading

0 comments on commit d28ed10

Please sign in to comment.