refactor: little light renaming

This commit is contained in:
Andy Burke 2025-06-24 16:17:00 -07:00
parent eef7b29223
commit 6f69695758
7 changed files with 31 additions and 31 deletions

View file

@ -1,7 +1,7 @@
import { PASSWORD_ENTRY, PASSWORD_ENTRY_STORE } from '../../../../models/password_entry.ts';
import { PASSWORD_ENTRIES, PASSWORD_ENTRY } from '../../../../models/password_entry.ts';
import { SESSIONS } from '../../../../models/session.ts';
import { USER, USER_STORE } from '../../../../models/user.ts';
import { USER_PERMISSIONS, USER_PERMISSIONS_STORE } from '../../../../models/user_permissions.ts';
import { USER, USERS } from '../../../../models/user.ts';
import { PERMISSIONS_STORE, USER_PERMISSIONS } from '../../../../models/user_permissions.ts';
import parse_body from '../../../../utils/bodyparser.ts';
export const PERMISSIONS: Record<string, (req: Request, meta: Record<string, any>) => Promise<boolean>> = {};
@ -16,7 +16,7 @@ PERMISSIONS.GET = (_req: Request, meta: Record<string, any>): Promise<boolean> =
};
export async function GET(_req: Request, meta: Record<string, any>): Promise<Response> {
const user_id: string = meta.params?.id?.toLowerCase().trim() ?? '';
const user: USER | null = user_id.length === 49 ? await USER_STORE.get(user_id) : null; // lurid is 49 chars as we use them, eg: "also-play-flow-want-form-wide-thus-work-burn-same"
const user: USER | null = user_id.length === 49 ? await USERS.get(user_id) : null; // lurid is 49 chars as we use them, eg: "also-play-flow-want-form-wide-thus-work-burn-same"
if (!user) {
return Response.json({
@ -60,7 +60,7 @@ PERMISSIONS.PUT = (_req: Request, meta: Record<string, any>): Promise<boolean> =
export async function PUT(req: Request, meta: { params: Record<string, any> }): Promise<Response> {
const now = new Date().toISOString();
const id: string = meta.params.id ?? '';
const existing = await USER_STORE.get(id);
const existing = await USERS.get(id);
if (!existing) {
return Response.json({
@ -84,7 +84,7 @@ export async function PUT(req: Request, meta: { params: Record<string, any> }):
}
};
await USER_STORE.update(updated);
await USERS.update(updated);
return Response.json(updated, {
status: 200
});
@ -111,7 +111,7 @@ PERMISSIONS.DELETE = (_req: Request, meta: Record<string, any>): Promise<boolean
export async function DELETE(_req: Request, meta: { params: Record<string, any> }): Promise<Response> {
const user_id: string = meta.params.id ?? '';
const user: USER | null = await USER_STORE.get(user_id);
const user: USER | null = await USERS.get(user_id);
if (!user) {
return Response.json({
error: {
@ -123,13 +123,13 @@ export async function DELETE(_req: Request, meta: { params: Record<string, any>
});
}
const password_entry: PASSWORD_ENTRY | null = await PASSWORD_ENTRY_STORE.get(user_id);
const password_entry: PASSWORD_ENTRY | null = await PASSWORD_ENTRIES.get(user_id);
if (password_entry) {
await PASSWORD_ENTRY_STORE.delete(password_entry);
await PASSWORD_ENTRIES.delete(password_entry);
}
const user_permissions: USER_PERMISSIONS | null = await USER_PERMISSIONS_STORE.get(user_id);
const user_permissions: USER_PERMISSIONS | null = await PERMISSIONS_STORE.get(user_id);
if (user_permissions) {
await USER_PERMISSIONS_STORE.delete(user_permissions);
await PERMISSIONS_STORE.delete(user_permissions);
}
const sessions = await SESSIONS.find({
@ -139,7 +139,7 @@ export async function DELETE(_req: Request, meta: { params: Record<string, any>
await SESSIONS.delete(session);
}
await USER_STORE.delete(user);
await USERS.delete(user);
return Response.json({
deleted: true