Skip to content

Feature/add api endpoint - #2

Merged
yduclospro-dev merged 9 commits into
developfrom
feature/add-api-endpoint
Jun 22, 2026
Merged

Feature/add api endpoint#2
yduclospro-dev merged 9 commits into
developfrom
feature/add-api-endpoint

Conversation

@yduclospro-dev

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings June 22, 2026 12:37
@yduclospro-dev yduclospro-dev self-assigned this Jun 22, 2026
@yduclospro-dev
yduclospro-dev requested a review from lorisnve June 22, 2026 12:38
@yduclospro-dev
yduclospro-dev merged commit 0bf3ca2 into develop Jun 22, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Tasks REST API to the TaskFlow API Express app, along with Jest/Supertest coverage and some healthcheck enhancements.

Changes:

  • Added /api/tasks CRUD endpoints (list/create/get/update/delete) backed by the existing Mongoose Task model.
  • Updated /health to return a structured payload including status, uptime, and version.
  • Added unit + integration tests and updated tooling/config (Jest timeout, Supertest, mongodb-memory-server, ESLint rules).

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/unit/tasks.test.js Adds Supertest-based unit tests for basic tasks route validation and list behavior.
tests/unit/health.test.js Adds unit test asserting the new health payload shape.
tests/integration/tasks.integration.test.js Adds an integration test using mongodb-memory-server to verify create + fetch-by-id flows.
src/routes/tasks.js Implements /api/tasks CRUD routes with basic validation and Mongoose operations.
src/routes/health.js Changes health response schema and includes app version/uptime.
src/index.js Mounts the new /api/tasks router.
package.json Adds Jest config and dev deps for integration testing (supertest, mongodb-memory-server).
package-lock.json Locks in new test dependencies (including node engine constraints).
.eslintrc.json Tightens lint rules (no-var, prefer-const, eqeqeq).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/routes/tasks.js
Comment on lines +9 to +13
const tasks = await Task.find().sort({ createdAt: -1 });
res.status(200).json(tasks);
} catch (err) {
res.status(500).json({ error: err.message });
}
Comment thread src/routes/tasks.js
Comment on lines +31 to +36
} catch (err) {
if (err.name === 'ValidationError') {
return res.status(400).json({ error: err.message });
}
return res.status(500).json({ error: err.message });
}
Comment thread src/routes/tasks.js
Comment on lines +18 to +28
const { title, description, status } = req.body || {};

if (typeof title !== 'string' || title.trim() === '') {
return res.status(400).json({ error: 'title is required' });
}

const task = await Task.create({
title: title.trim(),
...(description !== undefined && { description }),
...(status !== undefined && { status }),
});
Comment thread src/routes/tasks.js
Comment on lines +51 to +54
return res.status(200).json(task);
} catch (err) {
return res.status(500).json({ error: err.message });
}
Comment thread src/routes/tasks.js
Comment on lines +89 to +94
} catch (err) {
if (err.name === 'ValidationError') {
return res.status(400).json({ error: err.message });
}
return res.status(500).json({ error: err.message });
}
Comment thread src/routes/tasks.js
Comment on lines +72 to +73
if (description !== undefined) update.description = description;
if (status !== undefined) update.status = status;
Comment thread src/routes/tasks.js
Comment on lines +109 to +112
return res.status(204).send();
} catch (err) {
return res.status(500).json({ error: err.message });
}
Comment thread src/routes/tasks.js
Comment on lines +57 to +77
router.put('/:id', async (req, res) => {
try {
if (!mongoose.isValidObjectId(req.params.id)) {
return res.status(400).json({ error: 'invalid id' });
}

const { title, description, status } = req.body || {};
const update = {};

if (title !== undefined) {
if (typeof title !== 'string' || title.trim() === '') {
return res.status(400).json({ error: 'title must be a non-empty string' });
}
update.title = title.trim();
}
if (description !== undefined) update.description = description;
if (status !== undefined) update.status = status;

if (Object.keys(update).length === 0) {
return res.status(400).json({ error: 'no fields to update' });
}
Comment thread src/routes/health.js
Comment on lines 6 to +11
router.get('/', (req, res) => {
res.json({ status: 'OK', message: 'Server is running' });
res.status(200).json({
status: 'ok',
uptime: process.uptime(),
version,
});
Comment thread package.json
Comment on lines 29 to 35
"devDependencies": {
"eslint": "^8.45.0",
"jest": "^29.6.2",
"mongodb-memory-server": "^11.2.0",
"nodemon": "^3.0.1",
"jest": "^29.6.2"
"supertest": "^7.2.2"
}
@yduclospro-dev
yduclospro-dev deleted the feature/add-api-endpoint branch June 22, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants