parent
58371d22b6
commit
6cdca8ee5f
5 changed files with 49 additions and 0 deletions
@ -0,0 +1,33 @@ |
||||
import { RequestHandler } from 'express'; |
||||
|
||||
import buildGetRequestHandler from '../buildGetRequestHandler'; |
||||
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; |
||||
|
||||
export const getManifest: RequestHandler = buildGetRequestHandler( |
||||
(response, buildQueryOptions) => { |
||||
const query = ` |
||||
SELECT |
||||
manifest_uuid, |
||||
manifest_name |
||||
FROM manifests |
||||
ORDER BY manifest_name ASC;`;
|
||||
const afterQueryReturn: QueryResultModifierFunction | undefined = |
||||
buildQueryResultReducer<{ [manifestUUID: string]: ManifestOverview }>( |
||||
(previous, [manifestUUID, manifestName]) => { |
||||
previous[manifestUUID] = { |
||||
manifestName, |
||||
manifestUUID, |
||||
}; |
||||
|
||||
return previous; |
||||
}, |
||||
{}, |
||||
); |
||||
|
||||
if (buildQueryOptions) { |
||||
buildQueryOptions.afterQueryReturn = afterQueryReturn; |
||||
} |
||||
|
||||
return query; |
||||
}, |
||||
); |
@ -0,0 +1 @@ |
||||
export * from './getManifest'; |
@ -0,0 +1,9 @@ |
||||
import express from 'express'; |
||||
|
||||
import { getManifest } from '../lib/request_handlers/manifest'; |
||||
|
||||
const router = express.Router(); |
||||
|
||||
router.get('/', getManifest); |
||||
|
||||
export default router; |
@ -0,0 +1,4 @@ |
||||
type ManifestOverview = { |
||||
manifestName: string; |
||||
manifestUUID: string; |
||||
}; |
Loading…
Reference in new issue