TJ
TJ
Explore posts from servers
DTDrizzle Team
Created by TJ on 7/17/2024 in #help
Error handling
Hi, Currently this how I handle the database error thrown from Drizzle,
try {
...
} catch (error) {
if (error.sqlMessage) {
// toast a message "There was database error, contact administrator"
} else {
...
}
}
try {
...
} catch (error) {
if (error.sqlMessage) {
// toast a message "There was database error, contact administrator"
} else {
...
}
}
Is this the correct way to check if it is a database error?
3 replies
DTDrizzle Team
Created by TJ on 6/16/2024 in #help
Conflicting peer dependency of react@18.2.0 when installing drizzle-orm@0.31.2 in Next.js 14.2.4
Hi I'm install drizzle-orm in a Next.js project initialized with create-next-app@14.2.4. This new project has dependency to React 18.3.1. Unfortunately, we encounter the following dependency error when install latest drizzle-orm
$ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: hello@0.1.0
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR! peer react@"^18.2.0" from next@14.2.4
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from react-dom@18.3.1
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from next@14.2.4
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from react-native@0.74.2
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/op-sqlite@6.0.6
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from drizzle-orm@0.31.2
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
$ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: hello@0.1.0
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR! peer react@"^18.2.0" from next@14.2.4
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from react-dom@18.3.1
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from next@14.2.4
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from react-native@0.74.2
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/op-sqlite@6.0.6
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from drizzle-orm@0.31.2
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
Do you have any idea of what could be the problem? Shall we use --force to workaround this error?
6 replies
DTDrizzle Team
Created by TJ on 5/8/2024 in #help
How to share Drizzle schema in multiple projects?
Hi, I have an Express.js application running with Drizzle ORM. The schemas are defined and migration are generated in this repository, no problem. and now I'm going to have another application written in Next.js and it is going to access the same database. How can I share the Drizzle schema in multiple projects? Currently, I'm duplicating the Drizzle's schema from the previous Express.js application repository and make sure I don't run the migration. Do you have a better suggestion?
3 replies
DTDrizzle Team
Created by TJ on 5/7/2024 in #help
How to share the transaction in multiple services?
Hi, This is more like a design question. I'm using Drizzle ORM in Express.js application. I have userService and auditService to update the database records. Before the database transaction, I basically call the services like this,
router.post('/', async (req, res) => {
userService.create('john')
auditService.log('Create user john')
})
router.post('/', async (req, res) => {
userService.create('john')
auditService.log('Create user john')
})
and then with the database transaction,
router.post('/', async (req, res) => {
await db.transaction(async (tx) => {
userService.create(tx, 'john')
auditService.log(tx, 'Create user john')
})
})
router.post('/', async (req, res) => {
await db.transaction(async (tx) => {
userService.create(tx, 'john')
auditService.log(tx, 'Create user john')
})
})
Note that in the above, I have to pass the tx transaction to every service function. Is there a more elegant way than passing the tx to every function?
3 replies
KKinde
Created by TJ on 4/26/2024 in #💻┃support
Revoke all access tokens from Kinde
Hi, May I know how to revoke all access tokens from Kinde?
2 replies
KKinde
Created by TJ on 4/25/2024 in #💻┃support
Protect Next.js route handlers with machine-to-machine application?
Hi, I want to expose the route handlers defined in Next.js 14 application for external applications to call using OAuth 2 client credentials flow. Can I do this with machine-to-machine application? I tried to get the access token like this,
curl --request POST \
--url $KINDE_ISSUER_URL/oauth/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=$KINDE_ISSUER_URL/api
curl --request POST \
--url $KINDE_ISSUER_URL/oauth/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=$KINDE_ISSUER_URL/api
but it failed with this error,
{"error":"invalid_request","error_description":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Requested audience 'https://xxxxx.kinde.com/api' has not been whitelisted by the OAuth 2.0 Client."}
{"error":"invalid_request","error_description":"The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Requested audience 'https://xxxxx.kinde.com/api' has not been whitelisted by the OAuth 2.0 Client."}
Do you know what could be the problem?
10 replies
DTDrizzle Team
Created by TJ on 4/24/2024 in #help
Access MariaDB in Drizzle using node-mysql2?
Hi, Drizzle ORM does not support MariaDB officially (see https://github.com/drizzle-team/drizzle-orm/pull/1692). However, I have seen discussions of using Drizzle to access MariaDB (using node-mysql2 driver). Is this recommended? Is there any compatibility issue?
4 replies
KKinde
Created by TJ on 11/28/2023 in #💻┃support
Kinde TypeScript type in Next.js middleware
Hi, With Next.js 14 and TypeScript, may I know how can I specify the type for req so that it recognizes req.kindeAuth,
export default withAuth(async function middleware(req) {
console.log("look at me", req.kindeAuth);
});
export default withAuth(async function middleware(req) {
console.log("look at me", req.kindeAuth);
});
Is there a type provided by Kinde?
2 replies