Created
March 11, 2020 23:24
-
-
Save rodcisal/15e51a04f5af5a1ee1eb4438b422403b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Meteor } from "meteor/meteor"; | |
import { Random } from "meteor/random"; | |
import { Atenciones } from "../collections/atencion"; | |
if (Meteor.isServer) { | |
const Api = new Restivus({ | |
useDefaultAuth: false, | |
prettyJson: true | |
}); | |
Api.addRoute( | |
"create_file", | |
{ authRequired: false }, | |
{ | |
post() { | |
const { body } = this.request; | |
if ( | |
!body.atencionId || | |
!body.fileKey || | |
!body.tipoPeriferico || | |
!body.registro | |
) { | |
return { | |
statusCode: 500, | |
body: { | |
message: | |
"Faltan atributos, chequear atributos atencionId, fileKey, tipoPeriferico o registro" | |
} | |
}; | |
} | |
const { atencionId, fileKey, tipoPeriferico, registro } = body; | |
const obj = { | |
id: Random.id(), | |
fileKey, | |
periferico: tipoPeriferico, | |
registryName: registro, | |
type: "S3" | |
}; | |
const response = Atenciones.update( | |
{ _id: atencionId }, | |
{ | |
$push: { medicalRecord: obj } | |
} | |
); | |
if (response) { | |
return { | |
statusCode: 200, | |
body: { | |
message: "Archivo agregado con exito!" | |
} | |
}; | |
} | |
} | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment