website now works
This commit is contained in:
1 parent
ce56fcb91c
commit
3daa9f82e7
15 files changed
+241
-137
No files matched your search
@@ -1,19 +1,22 @@
|
||||
import express from 'express'
|
||||
import morgan from 'morgan'
|
||||
import * as z from 'zod'
|
||||
|
||||
import { Database } from './db'
|
||||
|
||||
const app = express()
|
||||
app.use(morgan('dev'))
|
||||
|
||||
const db = new Database({ readonly: true })
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
const { id } = z
|
||||
const { path } = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
path: z.string(),
|
||||
})
|
||||
.parse(req.query)
|
||||
|
||||
const r = db.get(id)
|
||||
const r = db.get(path)
|
||||
if (!r) {
|
||||
res.sendStatus(404)
|
||||
return
|
||||
@@ -55,4 +58,10 @@ app.get('/q', (req, res) => {
|
||||
)
|
||||
})
|
||||
|
||||
app.use((err: Error, _: express.Request, res: express.Response) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err.stack)
|
||||
res.status(500).send(err)
|
||||
})
|
||||
|
||||
export default app
|
||||
Reference in new issue
Block a user