{"size": 660, "ext": "js", "max_stars_repo_path": "repositories/backend/nodejs/src/interface_adapters/controllers/userController/create.js", "max_stars_repo_name": "EliFuzz/dbnr", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "repositories/backend/nodejs/src/interface_adapters/controllers/userController/create.js", "max_issues_repo_name": "EliFuzz/dbnr", "max_issues_repo_issues_event_min_datetime": "2020-03-16T08:19:07.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-24T17:16:53.000Z", "max_forks_repo_path": "repositories/backend/nodejs/src/interface_adapters/controllers/userController/create.js", "max_forks_repo_name": "EliFuzz/dbnr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 10, "max_forks_count": null, "avg_line_length": 26.4, "max_line_length": 92, "alphanum_fraction": 0.6575757576}
const userRepository = require("../../storage/userRepositoryMongoDb");
const httpResponse = require("../../../frameworks_drivers//webserver/helpers/httpResponse");

const createUser = require("../../../application_business_rules/use_cases/user/create");

const create = async request => {
  try {
    const { firstName, lastName } = request.body;

    const user = await createUser({ userRepository }, firstName, lastName);

    return httpResponse({
      statusCode: 200,
      data: { user }
    });
  } catch (error) {
    return httpResponse({
      statusCode: 400,
      data: `UserController: ${error.message}`
    });
  }
};

module.exports = create;
