24 lines
565 B
TypeScript
24 lines
565 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { BillingCycle } from '../../core/enums';
|
|
import { PrismaService } from '../../lib/postgres';
|
|
|
|
interface CreatePlanInput {
|
|
name: string;
|
|
priceCents: number;
|
|
billingCycle: BillingCycle;
|
|
softLimit?: number;
|
|
hardLimit?: number;
|
|
}
|
|
|
|
@Injectable()
|
|
export class PlanService {
|
|
constructor(private readonly prisma: PrismaService) {}
|
|
|
|
create(data: CreatePlanInput) {
|
|
return this.prisma.plan.create({ data });
|
|
}
|
|
|
|
list() {
|
|
return this.prisma.plan.findMany({ orderBy: { createdAt: 'desc' } });
|
|
}
|
|
}
|