-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalbumController.js
More file actions
44 lines (36 loc) · 1.12 KB
/
albumController.js
File metadata and controls
44 lines (36 loc) · 1.12 KB
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
const albumService = require('./albumService');
const getAllAlbums = async (request, response) => {
const key = request.headers['authorization'];
const result = await albumService.getAllAlbums(key);
response.status(200).json(result);
};
const getAlbumById = async (request, response) => {
const id = parseInt(request.params.id);
const key = request.headers['authorization'];
const result = await albumService.getAlbumById(key, id);
response.status(200).json(result);
};
const addAlbum = async (request, response) => {
const result = await albumService.addAlbum(request.body);
response.status(200).json(result);
};
const updateAlbum = async (request, response) => {
const body = {
...request.body,
id: parseInt(request.params.id)
};
const result = await albumService.updateAlbum(body);
response.status(200).json(result);
};
const deleteAlbum = async (request, response) => {
const id = parseInt(request.params.id);
const result = await albumService.deleteAlbum(id);
response.status(200).json(result);
};
module.exports = {
getAllAlbums,
getAlbumById,
addAlbum,
updateAlbum,
deleteAlbum
};