feat: implement incident reporting and management system
- Add incident reporting routes and logic to handle creation, updating, and retrieval of incidents. - Implement visibility rules for users based on roles (reporters, supervisors). - Create tests for incident reporting functionality to ensure correctness and reliability. - Introduce site and area management routes, including validation for area hierarchy. - Establish user management routes with role-based access control for creating and updating users. - Add setup routes for initializing the application with an organization and admin user. - Implement shared enums and schemas for consistent validation and data handling across the application. - Create a test helper for setting up an in-memory database and API client for testing. - Add TypeScript configuration for server-side code with strict type checking and module resolution.
This commit is contained in:
1 parent
a382fa904a
commit
c69eccb5c1
47 files changed
+6297
-45
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { serve } from '@hono/node-server'
|
||||
import { serveStatic } from '@hono/node-server/serve-static'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { createApp } from './app.ts'
|
||||
import { loadConfig } from './config.ts'
|
||||
import { openDatabase } from './db/client.ts'
|
||||
|
||||
const config = loadConfig()
|
||||
const database = await openDatabase(config.databaseUrl)
|
||||
const app = createApp({ db: database.db, config })
|
||||
|
||||
// In production the server also serves the built web app.
|
||||
if (existsSync(join(config.staticDir, 'index.html'))) {
|
||||
app.use(
|
||||
'/*',
|
||||
serveStatic({
|
||||
root: config.staticDir,
|
||||
onFound: (path, c) => {
|
||||
if (path.includes('/assets/')) c.header('Cache-Control', 'public, max-age=31536000, immutable')
|
||||
},
|
||||
}),
|
||||
)
|
||||
app.get('*', serveStatic({ path: join(config.staticDir, 'index.html') })) // client-side routes
|
||||
}
|
||||
|
||||
const server = serve({ fetch: app.fetch, port: config.port }, ({ port }) => {
|
||||
console.log(`Open SafetyLog EHS listening on port ${port}, public URL ${config.publicUrl} (database: ${config.databaseUrl.replace(/\/\/[^@]*@/, '//***@')})`)
|
||||
})
|
||||
|
||||
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
|
||||
process.on(signal, () => {
|
||||
server.close(async () => {
|
||||
await database.close()
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user