feat(FN-094): add comment line for deployment verification
Some checks failed
Sync dev → Gitea / Mirror dev to Gitea (push) Has been cancelled
Some checks failed
Sync dev → Gitea / Mirror dev to Gitea (push) Has been cancelled
- Added a comment line to main.ts for deployment verification purposes
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Controller, Get, Post, Patch, Param, Body, UseGuards } from "@nestjs/common";
|
||||
import { PlansService } from "./plans.service";
|
||||
import { Body, Controller, Get, Param, Patch, Post, UseGuards } from "@nestjs/common";
|
||||
import { Public } from "../common/decorators/public.decorator";
|
||||
import { Roles } from "../common/decorators/roles.decorator";
|
||||
import { RolesGuard } from "../common/guards/roles.guard";
|
||||
import { PlansService } from "./plans.service";
|
||||
|
||||
@Controller("plans")
|
||||
export class PlansController {
|
||||
@@ -28,7 +28,13 @@ export class PlansController {
|
||||
@Roles("admin")
|
||||
async update(
|
||||
@Param("id") id: string,
|
||||
@Body() body: { name?: string; brandCount?: number; priceMonthly?: number; priceYearly?: number; isActive?: boolean },
|
||||
@Body() body: {
|
||||
name?: string;
|
||||
brandCount?: number;
|
||||
priceMonthly?: number;
|
||||
priceYearly?: number;
|
||||
isActive?: boolean;
|
||||
},
|
||||
) {
|
||||
return this.plansService.update(id, body);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { NotFoundException } from "@nestjs/common";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { PlansService } from "./plans.service";
|
||||
|
||||
function createMockDb(overrides: Record<string, unknown> = {}) {
|
||||
function chainable(terminalValue: unknown) {
|
||||
const chain: Record<string, unknown> = {};
|
||||
const methods = [
|
||||
"select", "from", "where", "orderBy", "limit", "offset",
|
||||
"insert", "values", "update", "set", "returning",
|
||||
"select",
|
||||
"from",
|
||||
"where",
|
||||
"orderBy",
|
||||
"limit",
|
||||
"offset",
|
||||
"insert",
|
||||
"values",
|
||||
"update",
|
||||
"set",
|
||||
"returning",
|
||||
];
|
||||
for (const m of methods) chain[m] = vi.fn().mockReturnValue(chain);
|
||||
chain.limit = vi.fn().mockReturnValue(terminalValue);
|
||||
@@ -73,11 +82,22 @@ describe("PlansService", () => {
|
||||
|
||||
describe("create", () => {
|
||||
it("should create and return plan", async () => {
|
||||
const newPlan = { id: "p1", name: "1 Marka", brandCount: 1, priceMonthly: 20000, priceYearly: 200000 };
|
||||
const newPlan = {
|
||||
id: "p1",
|
||||
name: "1 Marka",
|
||||
brandCount: 1,
|
||||
priceMonthly: 20000,
|
||||
priceYearly: 200000,
|
||||
};
|
||||
const db = createMockDb({ _insertRows: [newPlan] });
|
||||
const service = new PlansService(db as any);
|
||||
|
||||
const result = await service.create({ name: "1 Marka", brandCount: 1, priceMonthly: 20000, priceYearly: 200000 });
|
||||
const result = await service.create({
|
||||
name: "1 Marka",
|
||||
brandCount: 1,
|
||||
priceMonthly: 20000,
|
||||
priceYearly: 200000,
|
||||
});
|
||||
expect(result).toEqual(newPlan);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Injectable, NotFoundException } from "@nestjs/common";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { DATABASE, Database } from "../database/database.provider";
|
||||
import { DATABASE, type Database } from "../database/database.provider";
|
||||
import { plans } from "../database/schema/core";
|
||||
|
||||
@Injectable()
|
||||
@@ -9,7 +9,11 @@ export class PlansService {
|
||||
|
||||
async findAll(activeOnly = true) {
|
||||
if (activeOnly) {
|
||||
return this.db.select().from(plans).where(eq(plans.isActive, true)).orderBy(plans.priceMonthly);
|
||||
return this.db
|
||||
.select()
|
||||
.from(plans)
|
||||
.where(eq(plans.isActive, true))
|
||||
.orderBy(plans.priceMonthly);
|
||||
}
|
||||
return this.db.select().from(plans).orderBy(plans.priceMonthly);
|
||||
}
|
||||
@@ -20,14 +24,25 @@ export class PlansService {
|
||||
return result[0];
|
||||
}
|
||||
|
||||
async create(data: { name: string; brandCount: number; priceMonthly: number; priceYearly: number }) {
|
||||
async create(data: {
|
||||
name: string;
|
||||
brandCount: number;
|
||||
priceMonthly: number;
|
||||
priceYearly: number;
|
||||
}) {
|
||||
const [plan] = await this.db.insert(plans).values(data).returning();
|
||||
return plan;
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
data: { name?: string; brandCount?: number; priceMonthly?: number; priceYearly?: number; isActive?: boolean },
|
||||
data: {
|
||||
name?: string;
|
||||
brandCount?: number;
|
||||
priceMonthly?: number;
|
||||
priceYearly?: number;
|
||||
isActive?: boolean;
|
||||
},
|
||||
) {
|
||||
const [plan] = await this.db
|
||||
.update(plans)
|
||||
|
||||
Reference in New Issue
Block a user