Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
API Toucan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Damien Armillon
API Toucan
Commits
9347bc94
Commit
9347bc94
authored
6 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
On peut demander qu'un nombre limit de toucan
parent
8785eafa
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/routes/routesToucan.js
+4
-3
4 additions, 3 deletions
backend/routes/routesToucan.js
backend/utils/schema.js
+3
-2
3 additions, 2 deletions
backend/utils/schema.js
with
7 additions
and
5 deletions
backend/routes/routesToucan.js
+
4
−
3
View file @
9347bc94
...
...
@@ -3,17 +3,18 @@ var fs = require("fs");
var
path
=
require
(
"
path
"
);
var
{
celebrate
}
=
require
(
"
celebrate
"
);
var
{
newToucan
,
validId
}
=
require
(
"
../utils/schema
"
);
var
{
newToucan
,
validId
,
validLimit
}
=
require
(
"
../utils/schema
"
);
var
env
=
require
(
"
../.env
"
);
var
upload
=
require
(
"
../utils/fileSaver
"
);
var
Toucan
=
require
(
"
../models/modelToucan
"
);
var
router
=
express
.
Router
();
router
.
route
(
"
/toucans
"
)
// Une route qui
renvoie un json avec tous les toucans
.
get
(
function
(
req
,
res
)
{
// Une route qui renvoie un json avec tous les toucans
, si limit est défini et vaut n, on renvoie les n derniers toucans
.
get
(
celebrate
({
query
:
validLimit
}),
function
(
req
,
res
)
{
Toucan
.
find
()
.
sort
({
date
:
-
1
})
.
limit
(
req
.
query
.
limit
)
.
exec
(
function
(
err
,
toucans
)
{
if
(
err
)
{
res
.
send
(
err
);
...
...
This diff is collapsed.
Click to expand it.
backend/utils/schema.js
+
3
−
2
View file @
9347bc94
...
...
@@ -5,6 +5,7 @@ var newToucan = Joi.object({
date
:
Joi
.
date
().
required
()
});
var
validId
=
Joi
.
object
({
id
:
Joi
.
string
().
hex
().
length
(
24
)});
var
validId
=
Joi
.
object
({
id
:
Joi
.
string
().
hex
().
length
(
24
).
required
()});
var
validLimit
=
Joi
.
object
({
limit
:
Joi
.
number
().
integer
()});
module
.
exports
=
{
newToucan
,
validId
};
\ No newline at end of file
module
.
exports
=
{
newToucan
,
validId
,
validLimit
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment