mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 02:29:09 +00:00
33 lines
882 B
TypeScript
33 lines
882 B
TypeScript
import { Request, Response } from 'express';
|
|
import * as Sentry from '@sentry/node';
|
|
import { SecretSnapshot } from '../../models';
|
|
|
|
/**
|
|
* Return secret snapshot with id [secretSnapshotId]
|
|
* @param req
|
|
* @param res
|
|
* @returns
|
|
*/
|
|
export const getSecretSnapshot = async (req: Request, res: Response) => {
|
|
let secretSnapshot;
|
|
try {
|
|
const { secretSnapshotId } = req.params;
|
|
|
|
secretSnapshot = await SecretSnapshot
|
|
.findById(secretSnapshotId)
|
|
.populate('secretVersions');
|
|
|
|
if (!secretSnapshot) throw new Error('Failed to find secret snapshot');
|
|
|
|
} catch (err) {
|
|
Sentry.setUser({ email: req.user.email });
|
|
Sentry.captureException(err);
|
|
return res.status(400).send({
|
|
message: 'Failed to get secret snapshot'
|
|
});
|
|
}
|
|
|
|
return res.status(200).send({
|
|
secretSnapshot
|
|
});
|
|
} |