a lot of things

This commit is contained in:
2026-02-20 11:46:30 -06:00
parent 987a1c8a6a
commit 70284bc14e
37 changed files with 1080 additions and 79 deletions
+1
View File
@@ -16,6 +16,7 @@ export default createRoute(
const schema = z.object({
name: z.string().min(1, "Name is required"),
notes: z.string().optional(),
typeId: z.string().min(1, "Type ID is required"),
companyId: z.string().min(1, "Company ID is required"),
fields: z.array(
+4
View File
@@ -5,9 +5,12 @@ import { default as update } from "./update";
import { default as updateFields } from "./updateFields";
import { default as fetchFields } from "./fetchFields";
import { default as readSecureValues } from "./readSecureValues";
import { default as readSecureValue } from "./readSecureValue";
import { default as deleteCredential } from "./delete";
import { default as valueTypes } from "./valueTypes";
export {
valueTypes,
fetch,
fetchByCompany,
create,
@@ -15,5 +18,6 @@ export {
updateFields,
fetchFields,
readSecureValues,
readSecureValue,
deleteCredential as delete,
};
+27
View File
@@ -0,0 +1,27 @@
import { Hono } from "hono/tiny";
import { createRoute } from "../../modules/api-utils/createRoute";
import { credentials } from "../../managers/credentials";
import { apiResponse } from "../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { authMiddleware } from "../middleware/authorization";
/* GET /v1/credential/credentials/:id/secure-values/:fieldId */
export default createRoute(
"get",
["/credentials/:id/secure-values/:fieldId"],
async (c) => {
const credential = await credentials.fetch(c.req.param("id"));
const fieldId = c.req.param("fieldId");
const value = await credential.readSecureFieldValue(fieldId);
const response = apiResponse.successful(
"Secure Value Fetched Successfully!",
{ fieldId, value },
);
return c.json(response, response.status as ContentfulStatusCode);
},
authMiddleware({
permissions: ["credential.fetch", "credential.secure_values.read"],
}),
);
+19 -1
View File
@@ -17,11 +17,29 @@ export default createRoute(
const schema = z.object({
name: z.string().optional(),
notes: z.string().nullable().optional(),
fields: z
.array(
z.object({
fieldId: z.string(),
value: z.string(),
}),
)
.optional(),
});
const data = schema.parse(body);
await credential.update(data);
if (data.fields) {
await credential.validateAndUpdateFields(data.fields);
}
if (data.name !== undefined || data.notes !== undefined) {
await credential.update({
...(data.name !== undefined && { name: data.name }),
...(data.notes !== undefined && { notes: data.notes }),
});
}
const response = apiResponse.successful(
"Credential Updated Successfully!",
-1
View File
@@ -18,7 +18,6 @@ export default createRoute(
const schema = z.object({
fields: z.array(
z.object({
id: z.string(),
fieldId: z.string(),
value: z.string(),
}),
+22
View File
@@ -0,0 +1,22 @@
import { createRoute } from "../../modules/api-utils/createRoute";
import { apiResponse } from "../../modules/api-utils/apiResponse";
import { ContentfulStatusCode } from "hono/utils/http-status";
import { ValueType } from "../../modules/credentials/credentialTypeDefs";
import { authMiddleware } from "../middleware/authorization";
/* GET /v1/credential/valuetypes */
export default createRoute(
"get",
["/valuetypes"],
async (c) => {
const valueTypes = Object.values(ValueType);
const response = apiResponse.successful(
"Value Types Fetched Successfully!",
valueTypes,
);
return c.json(response, response.status as ContentfulStatusCode);
},
authMiddleware(),
);