-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement payment APIs with lemonsqueezy #396
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocker: Seems like lockfile from Bun wasn't updated and there are other issues mentioned in comments. Nothing serious though.
libs/payments/src/index.ts
Outdated
|
||
const data = JSON.parse(rawBody) | ||
|
||
if (data.meta.event_name === 'order_created' && data.data.status === 'paid') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: What should be here? Seem like something is needed to add.
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is an install script?Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts. Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
rawBody, | ||
request, | ||
customData: { | ||
callback: () => void console.log('user granted lifetime access'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check that product_name
is Lifetime
as specified here:
https://docs.lemonsqueezy.com/guides/developer-guide/webhooks#example-webhook-data
I already created package called "Lifetime", so it should be easier to handle like this.
bb35b49
to
f21ba5c
Compare
not sure why they keep being readded
a307102
to
5b3ff6b
Compare
apps/coursition/prisma/index.ts
Outdated
@@ -0,0 +1,2 @@ | |||
import { PrismaClient } from '@prisma/client' | |||
export default new PrismaClient() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocker: Default exports should not be used. Also it would be better to have this specified like this:
import { PrismaClient } from "@prisma/client"
declare global {
var prisma: PrismaClient // This must be a `var` and not a `let / const`
}
export const prisma = global.prisma || new PrismaClient()
if (process.env.NODE_ENV !== "production") {
global.prisma = prisma
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for this? 🤔
My guess isso that we dont always have to import it, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Default exports are bad. We should avoid them as much as possible.
- As for the global client, there's article about it:
https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/nextjs-prisma-client-dev-practices
They suggest a bit different code (which breaks default export, so that should be changed):
import { PrismaClient } from '@prisma/client'
const prismaClientSingleton = () => {
return new PrismaClient()
}
declare const globalThis: {
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
} & typeof global;
const prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
export default prisma
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma
apps/coursition/prisma/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocker: index.ts files are confusing, it is much better to give it name like "prismaClient.ts" so that it's self-explanatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what naming convention should be adopted for the files, i think we can add that to the readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I don't like generic names like "index.ts" because it's hard to navigate through files with search. Will add updating README as a task for the future. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why empty files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why empty files?
import { PrismaClient } from '@prisma/client' | ||
|
||
declare global { | ||
var prisma: PrismaClient | ||
} | ||
|
||
// biome-ignore lint/suspicious/noRedeclare: <explanation> | ||
export const prisma = global.prisma || new PrismaClient() | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
global.prisma = prisma | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { PrismaClient } from '@prisma/client' | |
declare global { | |
var prisma: PrismaClient | |
} | |
// biome-ignore lint/suspicious/noRedeclare: <explanation> | |
export const prisma = global.prisma || new PrismaClient() | |
if (process.env.NODE_ENV !== 'production') { | |
global.prisma = prisma | |
} | |
import { PrismaClient } from '@prisma/client' | |
const prismaClientSingleton = () => { | |
return new PrismaClient() | |
} | |
declare const globalThis: { | |
prismaGlobal: ReturnType<typeof prismaClientSingleton>; | |
} & typeof global; | |
export const prisma = globalThis.prismaGlobal ?? prismaClientSingleton() | |
if (process.env.NODE_ENV !== 'production') globalThis.prismaGlobal = prisma |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build fails with some weird error, which I meet from time to time with Prisma. Not sure why that happens. Can you check it, @devodii? :)
Failed to compile.
./src/app/api/payments/route.ts:2:10
Type error: Module '"@prisma/client"' has no exported member 'PaymentStatus'.
1 | import { webhookEventHandler } from '@nmit-coursition/payments'
> 2 | import { PaymentStatus } from '@prisma/client'
| ^
3 | import { revalidatePath } from 'next/cache'
4 | import { type NextRequest, NextResponse } from 'next/server'
5 |
Warning: command "next build" exited with non-zero status code
NX Running target build for project coursition failed
Failed tasks:
- coursition:build
Hint: run the command with --verbose for more details.
Error: Command "bunx --bun nx build coursition --prod --verbose" exited with 1
No description provided.