{"size": 633, "ext": "js", "max_stars_repo_path": "functions/adminFunctions/createEvent.function.js", "max_stars_repo_name": "officialjasonkim/BHacksLanding", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "functions/adminFunctions/createEvent.function.js", "max_issues_repo_name": "officialjasonkim/BHacksLanding", "max_issues_repo_issues_event_min_datetime": "2021-08-31T20:00:44.000Z", "max_issues_repo_issues_event_max_datetime": "2021-08-31T20:00:44.000Z", "max_forks_repo_path": "functions/adminFunctions/createEvent.function.js", "max_forks_repo_name": "officialjasonkim/BHacksLanding", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 23.4444444444, "max_line_length": 78, "alphanum_fraction": 0.6619273302}
const admin = require("firebase-admin");
const functions = require("firebase-functions");
const { v4: uuidv4 } = require("uuid");

const db = admin.firestore();

module.exports.createEvent = functions.https.onCall(async (data, context) => {
  if (!context.auth) {
    return { message: "Authentication Required!", code: 401 };
  }

  var uid = uuidv4();
  const events = db.collection("events").doc(uid);

  await events.set({
    uid: uid,
    title: data.title,
    location: data.location,
    startTime: data.startTime,
    finishTime: data.finishTime,
    description: data.description,
    type: data.type
  });

  return;
});
