initial commit

This commit is contained in:
equippedcoding-master
2025-09-17 09:37:06 -05:00
parent 86108ca47e
commit e2c98790b2
55389 changed files with 6206730 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import { createProject, findProject } from './project.service';
export const create = async (req, res, next) => {
try {
const response = await createProject(req.body);
res.status(200).json(response);
} catch (error) {
console.error(error);
res.status(400).send(error);
}
};
export const findAll = async (req, res, next) => {
const projects = await findProject({});
res.status(200).json(projects);
};

View File

@@ -0,0 +1,23 @@
const mongoose = require('mongoose');
const { Schema } = mongoose;
const Project = new mongoose.Schema(
{
name: {
type: String,
required: true,
trim: true,
maxlength: 25,
},
description: {
type: String,
},
logo: {
type: String,
},
},
{
timestamps: true,
},
);
export default mongoose.model('Projects', Project);

View File

@@ -0,0 +1,7 @@
import express from 'express';
import { create, findAll } from './project.controller';
const projectRoute = express.Router();
projectRoute.post('/', create);
projectRoute.get('/', findAll);
export default projectRoute;

View File

@@ -0,0 +1,19 @@
import Projects from './project.model';
export const createProject = async (body) => {
const projects = await findProject({ name: body.name });
console.log('projects :>> ', projects);
if (projects && projects.length > 0) {
throw new Error(`Project with name: ${body.name} already exists`);
}
console.log('jdjdjdjdjdjdjdjdjdjjd');
const project = new Projects(body);
console.log('project :>> ', project);
return await project.save();
};
export const findProjectByUuid = async (projectId) => {};
export const findProject = async (query) => {
const projects = await Projects.find(query);
return projects;
};