fix(csms): fix lint errors, clean up imports and improve code formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Hono } from "hono";
|
||||
import { desc, eq, sql, inArray } from "drizzle-orm";
|
||||
import { desc, eq, sql } from "drizzle-orm";
|
||||
import dayjs from "dayjs";
|
||||
import { useDrizzle } from "@/lib/db.js";
|
||||
import { chargePoint, connector } from "@/db/schema.js";
|
||||
@@ -81,12 +81,12 @@ app.post("/", async (c) => {
|
||||
if (body.feePerKwh !== undefined && (!Number.isInteger(body.feePerKwh) || body.feePerKwh < 0)) {
|
||||
return c.json({ error: "feePerKwh must be a non-negative integer" }, 400);
|
||||
}
|
||||
if (body.pricingMode !== undefined && !['fixed', 'tou'].includes(body.pricingMode)) {
|
||||
if (body.pricingMode !== undefined && !["fixed", "tou"].includes(body.pricingMode)) {
|
||||
return c.json({ error: "pricingMode must be 'fixed' or 'tou'" }, 400);
|
||||
}
|
||||
|
||||
const plainPassword = generateOcppPassword()
|
||||
const passwordHash = await hashOcppPassword(plainPassword)
|
||||
const plainPassword = generateOcppPassword();
|
||||
const passwordHash = await hashOcppPassword(plainPassword);
|
||||
|
||||
const [created] = await db
|
||||
.insert(chargePoint)
|
||||
@@ -175,21 +175,19 @@ app.patch("/:id", async (c) => {
|
||||
}
|
||||
set.registrationStatus = body.registrationStatus as "Accepted" | "Pending" | "Rejected";
|
||||
}
|
||||
if (body.chargePointVendor !== undefined) set.chargePointVendor = body.chargePointVendor.trim() || "Unknown";
|
||||
if (body.chargePointModel !== undefined) set.chargePointModel = body.chargePointModel.trim() || "Unknown";
|
||||
if (body.chargePointVendor !== undefined)
|
||||
set.chargePointVendor = body.chargePointVendor.trim() || "Unknown";
|
||||
if (body.chargePointModel !== undefined)
|
||||
set.chargePointModel = body.chargePointModel.trim() || "Unknown";
|
||||
if ("deviceName" in body) set.deviceName = body.deviceName?.trim() || null;
|
||||
if (body.pricingMode !== undefined) {
|
||||
if (!['fixed', 'tou'].includes(body.pricingMode)) {
|
||||
if (!["fixed", "tou"].includes(body.pricingMode)) {
|
||||
return c.json({ error: "pricingMode must be 'fixed' or 'tou'" }, 400);
|
||||
}
|
||||
set.pricingMode = body.pricingMode;
|
||||
}
|
||||
|
||||
const [updated] = await db
|
||||
.update(chargePoint)
|
||||
.set(set)
|
||||
.where(eq(chargePoint.id, id))
|
||||
.returning();
|
||||
const [updated] = await db.update(chargePoint).set(set).where(eq(chargePoint.id, id)).returning();
|
||||
|
||||
if (!updated) return c.json({ error: "Not found" }, 404);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import { desc, eq } from "drizzle-orm";
|
||||
import dayjs from "dayjs";
|
||||
import { useDrizzle } from "@/lib/db.js";
|
||||
import { idTag } from "@/db/schema.js";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
import { z } from "zod";
|
||||
import type { HonoEnv } from "@/types/hono.ts";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user