Build installer and management site from spec
This commit is contained in:
31
src/server/routes/index.ts
Normal file
31
src/server/routes/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Router } from 'express'
|
||||
import path from 'node:path'
|
||||
import { manifestRootPath } from '../../shared/paths'
|
||||
import { fetchReleaseVersions } from '../../shared/mojang'
|
||||
import { loadRootManifest } from '../../shared/store'
|
||||
|
||||
export const indexRouter = Router()
|
||||
|
||||
indexRouter.get('/', async (_req, res, next) => {
|
||||
try {
|
||||
const manifest = await loadRootManifest()
|
||||
res.render('index', {
|
||||
packs: manifest.packs
|
||||
})
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
})
|
||||
|
||||
indexRouter.get('/manifest.json', (_req, res) => {
|
||||
res.sendFile(path.resolve(manifestRootPath))
|
||||
})
|
||||
|
||||
indexRouter.get('/api/releases', async (_req, res, next) => {
|
||||
try {
|
||||
const releases = await fetchReleaseVersions()
|
||||
res.json(releases)
|
||||
} catch (error) {
|
||||
next(error)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user