This repository was archived by the owner on Nov 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathcategory-controller.js
More file actions
66 lines (49 loc) · 1.65 KB
/
category-controller.js
File metadata and controls
66 lines (49 loc) · 1.65 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import CategoryService from './../services/category-services.js'
class CategoryController {
static createCategory = (require, response) => {
CategoryService.createCategory(require)
.then(success => {
response.status(201).send({message:'Successfully create category'})
})
.catch(err => {
response.status(500).send({ message: err.message})
})
}
static getCategories = (require, response) => {
CategoryService.getCategories()
.then(categories => {
response.status(200).send(categories)
})
.catch(err => {
response.status(400).send({ message: err.message })
})
}
static getCategory = (require, response) => {
CategoryService.getCategory(require)
.then(category => {
response.status(200).send(category)
})
.catch(err => {
response.status(400).send({ message: err.message })
})
}
static updateCategory = (require, response) => {
CategoryService.updateCategory(require)
.then(success => {
response.status(200).send({ message: "Successfully update category" })
})
.catch(err => {
response.status(500).send({message: err.message})
})
}
static deleteCategory = (require, response) => {
CategoryService.deleteCategory(require)
.then(success => {
response.status(200).send({message: "Successfully delete category"})
})
.catch(err => {
response.status(500).send({message: err.message})
})
}
}
export default CategoryController