modified api.ts to directly incorporate swagger-ui-express code
This commit is contained in:
		@@ -44,7 +44,14 @@ router.put('/template/:collection(measurement|condition|material)/' + IdValidate
 | 
			
		||||
  const {error, value: template} = TemplateValidate.input(req.body, 'change');
 | 
			
		||||
  if (error) return res400(error, res);
 | 
			
		||||
 | 
			
		||||
  const templateData = await model(req).findById(req.params.id).lean().exec().catch(err => {next(err);}) as any;
 | 
			
		||||
  // find given template
 | 
			
		||||
  const templateRef = await model(req).findById(req.params.id).lean().exec().catch(err => {next(err);}) as any;
 | 
			
		||||
  if (templateRef instanceof Error) return;
 | 
			
		||||
  if (!templateRef) {
 | 
			
		||||
    return res.status(404).json({status: 'Not found'});
 | 
			
		||||
  }
 | 
			
		||||
  // find latest version
 | 
			
		||||
  const templateData = await model(req).findOne({first_id: templateRef.first_id}).sort({version: -1}).lean().exec().catch(err => {next(err);}) as any;
 | 
			
		||||
  if (templateData instanceof Error) return;
 | 
			
		||||
  if (!templateData) {
 | 
			
		||||
    return res.status(404).json({status: 'Not found'});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user