FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
unexcoder_server/controllers/apiController.js at main · unexCoder/unexcoder_server · GitHub
unexCoder
unexcoder_server
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
unexcoder_server
/
controllers
/
apiController.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
83 lines (74 loc) · 2.03 KB
Breadcrumbs
unexcoder_server
/
controllers
/
apiController.js
Copy path
File metadata and controls
83 lines (74 loc) · 2.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const
Album
=
require
(
'../models/album'
)
;
// get_albums
const
get_albums
=
(
req
,
res
)
=>
{
Album
.
find
(
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// get_albums_by_id
const
get_albums_by_id
=
(
req
,
res
)
=>
{
const
id
=
req
.
params
.
id
;
Album
.
findById
(
id
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// get_albums_by_title
const
get_albums_by_title
=
(
req
,
res
)
=>
{
const
title
=
req
.
params
.
title
;
Album
.
find
(
{
title
:
title
}
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// get_albums_by_year
const
get_albums_by_year
=
(
req
,
res
)
=>
{
const
year
=
req
.
params
.
year
;
Album
.
find
(
{
year
:
year
}
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// get_albums_by_tags
const
get_albums_by_tags
=
(
req
,
res
)
=>
{
const
tags
=
req
.
query
.
tags
;
Album
.
find
(
{
tags
:
{
$in
:
tags
}
}
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// post_album
const
post_album
=
(
req
,
res
)
=>
{
const
album
=
new
Album
(
req
.
body
)
;
album
.
save
(
)
.
then
(
(
result
)
=>
{
res
.
send
(
result
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// update_album
const
update_album
=
(
req
,
res
)
=>
{
const
id
=
req
.
params
.
id
;
Album
.
findByIdAndUpdate
(
id
,
req
.
body
)
.
then
(
(
result
)
=>
{
res
.
send
(
'updated object with id: '
+
id
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
// delete_album
const
delete_album
=
(
req
,
res
)
=>
{
const
id
=
req
.
params
.
id
;
Album
.
findByIdAndDelete
(
id
)
.
then
(
(
result
)
=>
{
res
.
send
(
'deleted object with id: '
+
id
)
;
}
)
.
catch
(
(
err
)
=>
console
.
log
(
err
)
)
}
module
.
exports
=
{
get_albums
,
get_albums_by_id
,
get_albums_by_title
,
get_albums_by_year
,
get_albums_by_tags
,
post_album
,
update_album
,
delete_album
}
Back
|
FazBrowse Home
|
New Git URL