Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Polytech Todo Api Abouchtita
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BOUCHTITA Achraf
Polytech Todo Api Abouchtita
Merge requests
!1
Develop into main
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Develop into main
develop
into
main
Overview
0
Commits
5
Pipelines
1
Changes
6
Merged
Develop into main
BOUCHTITA Achraf
requested to merge
develop
into
main
4 months ago
Overview
0
Commits
5
Pipelines
1
Changes
6
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
f33d6e20
5 commits,
4 months ago
6 files
+
203
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
src/index.js
+
34
−
0
View file @ f33d6e20
Edit in single-file editor
Open in Web IDE
Show full file
@@ -21,6 +21,40 @@ app.get('/api/tasks', (req, res) => {
res
.
json
(
tasks
);
});
//
app
.
get
(
'
/api/tasks/:id
'
,
(
req
,
res
)
=>
{
const
id
=
req
.
params
.
id
;
const
task
=
taskService
.
getTaskById
(
id
);
if
(
task
)
{
res
.
json
(
task
);
}
else
{
res
.
status
(
404
).
json
({
error
:
'
Tâche non trouvée
'
});
}
});
app
.
post
(
'
/api/tasks
'
,
(
req
,
res
)
=>
{
const
{
description
}
=
req
.
body
;
if
(
!
description
)
{
return
res
.
status
(
400
).
json
({
error
:
'
La description est requise
'
});
}
try
{
const
newTask
=
taskService
.
addTask
(
description
);
res
.
status
(
201
).
json
(
newTask
);
}
catch
(
error
)
{
res
.
status
(
500
).
json
({
error
:
error
.
message
});
}
});
app
.
delete
(
'
/api/tasks/:id
'
,
(
req
,
res
)
=>
{
const
id
=
req
.
params
.
id
;
const
result
=
taskService
.
deleteTask
(
id
);
if
(
result
)
{
res
.
status
(
204
).
send
();
}
else
{
res
.
status
(
404
).
json
({
error
:
'
Tâche non trouvée
'
});
}
});
// Fonction pour démarrer le serveur
const
startServer
=
()
=>
{
const
server
=
app
.
listen
(
port
,
()
=>
{
Loading