TJ
TJ
Explore posts from servers
PPrisma
Created by TJ on 11/1/2024 in #help-and-questions
Does Prisma support MariaDB 10.6
The error is gone after removing the empty string map attribute.
7 replies
PPrisma
Created by TJ on 11/1/2024 in #help-and-questions
Does Prisma support MariaDB 10.6
I used db pull to introspect a MariaDB 10.6 database, and a schema is generated without error. Then I encounter the following error when I tried to generate the Prisma Client,
$ pnpm prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Error parsing attribute "@relation": The `map` argument cannot be an empty string.
--> prisma/schema.prisma:5285
|
5284 | updated_at DateTime? @db.Timestamp(0)
5285 | book_groups book_groups @relation(fields: [book_group_id], references: [id], onDelete: Cascade, map: "")
|

Validation Error Count: 1
[Context: getDmmf]

Prisma CLI Version : 5.21.1
$ pnpm prisma generate
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Error: Prisma schema validation - (get-dmmf wasm)
Error code: P1012
error: Error parsing attribute "@relation": The `map` argument cannot be an empty string.
--> prisma/schema.prisma:5285
|
5284 | updated_at DateTime? @db.Timestamp(0)
5285 | book_groups book_groups @relation(fields: [book_group_id], references: [id], onDelete: Cascade, map: "")
|

Validation Error Count: 1
[Context: getDmmf]

Prisma CLI Version : 5.21.1
7 replies
DTDrizzle Team
Created by seckraken on 6/14/2024 in #help
Create a view with Drizzle
In the case like this we will have a schema.js to create tables and another SQL file to create the views. I'm wondering how we store and run this SQL file?
8 replies
DTDrizzle Team
Created by TJ on 6/16/2024 in #help
Conflicting peer dependency of [email protected] when installing [email protected] in Next.js 14.2.4
@Flexi I installed drizzle-orm with --force like what @A Dapper Raccoon explained.
6 replies
DTDrizzle Team
Created by TJ on 5/8/2024 in #help
How to share Drizzle schema in multiple projects?
Thanks, @JipSterk So this how I share the schema in monorepo: I have created two packages, db to store the schema and app to import the schema:
/
+--db
| +- schema.js
| +- index.js
| +- drizzle.config.js
|
+--app
| +- app.js
/
+--db
| +- schema.js
| +- index.js
| +- drizzle.config.js
|
+--app
| +- app.js
Note that the drizzle.config.js is created in db to generate the migration using drizzle-kit. Then the schema looks like this,
// schema.js
export const invoices = pgTable("users", { ...})
// schema.js
export const invoices = pgTable("users", { ...})
and the package main script to export the schema,
// index.js
export * from "./schema.js";
// index.js
export * from "./schema.js";
then I import the schema in the app
// app.js
import * as schema from '@app/db/schema.js'

const options = { ... }

const db = drizzle(postgres(options), { logger: true, schema })
// app.js
import * as schema from '@app/db/schema.js'

const options = { ... }

const db = drizzle(postgres(options), { logger: true, schema })
3 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
@Claire_Kinde I tried https://auth0.com/docs/quickstart/backend/nodejs/01-authorization Can I achieve the same using Kinde?
10 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
@Claire_Kinde Are you able to guide me on this? 🥹
10 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
Hi, I try to summarize what I did in the GitHub repository at https://github.com/tjhoo/kinde-client-credentials and the steps I performed in README.md
10 replies
DTDrizzle Team
Created by TJ on 4/24/2024 in #help
Access MariaDB in Drizzle using node-mysql2?
Uh ... simply because of the compatibility issues? I think we just have to give up of MariaDB if we want to use Drizzle.
4 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
Hi, I have a Next.js application which I want the external applications to call the API using the access token obtain from the client credentials flow. I created one Next.js machine-to-machine application in Kinde. app/api/auth/[kindeAuth]/route.js
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";

export const GET = handleAuth();
import { handleAuth } from "@kinde-oss/kinde-auth-nextjs/server";

export const GET = handleAuth();
the protected API in app/api/payment/[id]/route.js
export const GET = (_, { params }) => Response.json({ message: params.id});
export const GET = (_, { params }) => Response.json({ message: params.id});
and protect the API in middleware.js
import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";

export const middleware = (req) => withAuth(req);

export const config = {
matcher: ["/api/payment/:path*"],
};
import { withAuth } from "@kinde-oss/kinde-auth-nextjs/middleware";

export const middleware = (req) => withAuth(req);

export const config = {
matcher: ["/api/payment/:path*"],
};
and I only defined these environment variables in my Next.js, .env.local
KINDE_CLIENT_ID=...
KINDE_CLIENT_SECRET=...
KINDE_ISSUER_URL=https://xxxx.kinde.com
KINDE_SITE_URL=http://localhost:3000
KINDE_CLIENT_ID=...
KINDE_CLIENT_SECRET=...
KINDE_ISSUER_URL=https://xxxx.kinde.com
KINDE_SITE_URL=http://localhost:3000
Now, I have requested an access token successfully,
curl --request POST \
--url $KINDE_ISSUER_URL/oauth2/token \
--header 'content-type: application/x-www-form-urlencoded' \
--header 'accept: application/json' \
--data grant_type=client_credentials \
--data client_id=$KINDE_CLIENT_ID \
--data client_secret=$KINDE_CLIENT_SECRET \
--data audience=test
curl --request POST \
--url $KINDE_ISSUER_URL/oauth2/token \
--header 'content-type: application/x-www-form-urlencoded' \
--header 'accept: application/json' \
--data grant_type=client_credentials \
--data client_id=$KINDE_CLIENT_ID \
--data client_secret=$KINDE_CLIENT_SECRET \
--data audience=test
but I got a 307 redirect when I called the API with the access token
curl --request GET \
--url 'http://localhost:3000/api/payment/b' \
--header 'content-type: application/json' \
--header 'authorization: Bearer xxx' -I
HTTP/1.1 307 Temporary Redirect
location: /api/auth/login
Date: Mon, 29 Apr 2024 10:09:12 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
curl --request GET \
--url 'http://localhost:3000/api/payment/b' \
--header 'content-type: application/json' \
--header 'authorization: Bearer xxx' -I
HTTP/1.1 307 Temporary Redirect
location: /api/auth/login
Date: Mon, 29 Apr 2024 10:09:12 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
Do you know what am I missing here?
10 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
No description
10 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
@Peter (Kinde) I think what is missing from the document is to create an API (e.g. m2m) under Settings, and add this m2m API to the machine-to-machine application.
10 replies
KKinde
Created by AlexanderO on 4/18/2024 in #💻┃support
How to protect APIs for SaaS with API-first approach?
Hi, in my use case I have a Next.js 14 application with route handlers. These route handlers are used by the Next.js pages. Now, I want to expose some of these route handlers to multiple external applications so that they can call the route handlers (or APIs) directly. How can I protect these route handlers?
7 replies