Skip to content

Instantly share code, notes, and snippets.

@rodcisal
Created March 11, 2020 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodcisal/15e51a04f5af5a1ee1eb4438b422403b to your computer and use it in GitHub Desktop.
Save rodcisal/15e51a04f5af5a1ee1eb4438b422403b to your computer and use it in GitHub Desktop.
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