mirror of
https://github.com/directus/directus.git
synced 2026-02-06 08:45:02 -05:00
added to item for POV
This commit is contained in:
@@ -77,7 +77,7 @@ app.use('/auth', authRouter)
|
||||
.use('/fields', fieldsRouter)
|
||||
.use('/files', filesRouter)
|
||||
.use('/folders', foldersRouter)
|
||||
.use('/items', itemsRouter)
|
||||
.use('/items', itemsRouter, responseManager)
|
||||
.use('/permissions', permissionsRouter)
|
||||
.use('/presets', presetsRouter)
|
||||
.use('/relations', relationsRouter)
|
||||
|
||||
@@ -29,7 +29,7 @@ router.get(
|
||||
'/:collection',
|
||||
collectionExists,
|
||||
sanitizeQuery,
|
||||
asyncHandler(async (req, res) => {
|
||||
asyncHandler(async (req, res, next) => {
|
||||
const service = new ItemsService(req.collection, { accountability: req.accountability });
|
||||
const metaService = new MetaService({ accountability: req.accountability });
|
||||
|
||||
@@ -39,10 +39,12 @@ router.get(
|
||||
|
||||
const meta = await metaService.getMetaForQuery(req.collection, req.sanitizedQuery);
|
||||
|
||||
return res.json({
|
||||
res.locals.data = {
|
||||
meta: meta,
|
||||
data: records || null,
|
||||
});
|
||||
};
|
||||
|
||||
return next();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -50,7 +52,7 @@ router.get(
|
||||
'/:collection/:pk',
|
||||
collectionExists,
|
||||
sanitizeQuery,
|
||||
asyncHandler(async (req, res) => {
|
||||
asyncHandler(async (req, res, next) => {
|
||||
if (req.singleton) {
|
||||
throw new RouteNotFoundException(req.path);
|
||||
}
|
||||
@@ -58,10 +60,11 @@ router.get(
|
||||
const service = new ItemsService(req.collection, { accountability: req.accountability });
|
||||
const primaryKey = req.params.pk.includes(',') ? req.params.pk.split(',') : req.params.pk;
|
||||
const result = await service.readByKey(primaryKey as any, req.sanitizedQuery);
|
||||
|
||||
return res.json({
|
||||
res.locals.data = {
|
||||
data: result || null,
|
||||
});
|
||||
};
|
||||
|
||||
return next();
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ const responseManager: RequestHandler = asyncHandler(async (req, res, next) => {
|
||||
|
||||
const fieldsOut = Object.keys(exportData);
|
||||
const csv = await json2csv.parse(exportData, fieldsOut);
|
||||
|
||||
// will this be ok for larger files?
|
||||
res.setHeader('Content-disposition', 'attachment; filename=export.csv');
|
||||
res.set('Content-Type', 'text/csv');
|
||||
res.status(200).send(csv);
|
||||
|
||||
Reference in New Issue
Block a user