-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 805 Bytes
/
Copy pathserver.js
File metadata and controls
24 lines (19 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { handleRequest } from './src/SqliteAdmin.mjs'
const args = process.argv.slice(2)
if (args[0] === 'update') {
const { runUpdate } = await import('./src/update.mjs')
const ref = args.includes('--ref') ? args[args.indexOf('--ref') + 1] : undefined
const force = args.includes('--force')
try {
await runUpdate({ ref, force })
} catch (e) {
console.error('error:', e.message)
process.exit(1)
}
process.exit(0)
}
const argPort = args.includes('--port') ? args[args.indexOf('--port') + 1] : null
const port = parseInt(argPort ?? process.env.PORT ?? '4269', 10)
const routeBase = process.env.SQLITE_ADMIN_BASE_PATH ?? '/sqlite-admin'
const server = Bun.serve({ port, fetch: handleRequest })
console.log(`SQLite Admin running at http://localhost:${server.port}${routeBase}`)