feat: implement permissions and actions management
- Add permissions logic for status options in corrective actions. - Create tests for permissions functionality. - Implement queries for user authentication and actions management. - Develop Actions page to display and manage corrective actions. - Create authentication pages for login, setup, and password reset. - Add IncidentDetail page to view incident details and associated actions. - Implement Settings page for user management and password changes.
This commit is contained in:
1 parent
708da6b9f7
commit
3f6dff5f24
94 files changed
+7213
-643
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const KEY_PATTERN = /^[0-9a-f-]{36}\.[a-z]{3,4}$/
|
||||
|
||||
/** Stores uploaded files on local disk under random names. */
|
||||
export class FileStorage {
|
||||
readonly dir: string
|
||||
|
||||
constructor(dir: string) {
|
||||
this.dir = dir
|
||||
}
|
||||
|
||||
async save(data: Uint8Array, extension: string): Promise<string> {
|
||||
await mkdir(this.dir, { recursive: true })
|
||||
const key = `${randomUUID()}.${extension}`
|
||||
await writeFile(this.path(key), data, { flag: 'wx' })
|
||||
return key
|
||||
}
|
||||
|
||||
read(key: string): Promise<Buffer> {
|
||||
return readFile(this.path(key))
|
||||
}
|
||||
|
||||
async remove(key: string): Promise<void> {
|
||||
await rm(this.path(key), { force: true })
|
||||
}
|
||||
|
||||
private path(key: string) {
|
||||
if (!KEY_PATTERN.test(key)) throw new Error(`Invalid storage key: ${key}`)
|
||||
return join(this.dir, key)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user