Skip to content

Commit 4ed29fe

Browse files
committed
Split remaining controllers into separate files. Added iOS homescreen icon. Removed additional logging from weather module.
1 parent 88694c7 commit 4ed29fe

32 files changed

+418
-312
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
data
33
public
4+
!client/public
45
build.sh

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v1.7.4 (TBA)
2+
- Added iOS "Add to homescreen" icon ([#131](https://github.com/pawelmalak/flame/issues/131))
3+
14
### v1.7.3 (2021-10-28)
25
- Fixed bug with custom CSS not updating
36

9.36 KB
Loading
7.41 KB
Loading
7.14 KB
Loading
11.3 KB
Loading
19.8 KB
Loading
2.52 KB
Loading
3.23 KB
Loading
3.96 KB
Loading
2.52 KB
Loading
File renamed without changes.

client/public/index.html

+45-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,51 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="icon" href="%PUBLIC_URL%/icons/favicon.ico" />
6+
<link
7+
rel="apple-touch-icon"
8+
href="%PUBLIC_URL%/icons/apple-touch-icon.png"
9+
/>
10+
<link
11+
rel="apple-touch-icon"
12+
sizes="57x57"
13+
href="%PUBLIC_URL%/icons/apple-touch-icon-57x57.png"
14+
/>
15+
<link
16+
rel="apple-touch-icon"
17+
sizes="72x72"
18+
href="%PUBLIC_URL%/icons/apple-touch-icon-72x72.png"
19+
/>
20+
<link
21+
rel="apple-touch-icon"
22+
sizes="76x76"
23+
href="%PUBLIC_URL%/icons/apple-touch-icon-76x76.png"
24+
/>
25+
<link
26+
rel="apple-touch-icon"
27+
sizes="114x114"
28+
href="%PUBLIC_URL%/icons/apple-touch-icon-114x114.png"
29+
/>
30+
<link
31+
rel="apple-touch-icon"
32+
sizes="120x120"
33+
href="%PUBLIC_URL%/icons/apple-touch-icon-120x120.png"
34+
/>
35+
<link
36+
rel="apple-touch-icon"
37+
sizes="144x144"
38+
href="%PUBLIC_URL%/icons/apple-touch-icon-144x144.png"
39+
/>
40+
<link
41+
rel="apple-touch-icon"
42+
sizes="152x152"
43+
href="%PUBLIC_URL%/icons/apple-touch-icon-152x152.png"
44+
/>
45+
<link
46+
rel="apple-touch-icon"
47+
sizes="180x180"
48+
href="%PUBLIC_URL%/icons/apple-touch-icon-180x180.png"
49+
/>
650
<meta name="viewport" content="width=device-width, initial-scale=1" />
751
<meta
852
name="description"
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const Category = require('../../models/Category');
3+
const loadConfig = require('../../utils/loadConfig');
4+
5+
// @desc Create new category
6+
// @route POST /api/categories
7+
// @access Public
8+
const createCategory = asyncWrapper(async (req, res, next) => {
9+
const { pinCategoriesByDefault: pinCategories } = await loadConfig();
10+
11+
let category;
12+
13+
if (pinCategories) {
14+
category = await Category.create({
15+
...req.body,
16+
isPinned: true,
17+
});
18+
} else {
19+
category = await Category.create(req.body);
20+
}
21+
22+
res.status(201).json({
23+
success: true,
24+
data: category,
25+
});
26+
});
27+
28+
module.exports = createCategory;
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const ErrorResponse = require('../../utils/ErrorResponse');
3+
const Category = require('../../models/Category');
4+
const Bookmark = require('../../models/Bookmark');
5+
6+
// @desc Delete category
7+
// @route DELETE /api/categories/:id
8+
// @access Public
9+
const deleteCategory = asyncWrapper(async (req, res, next) => {
10+
const category = await Category.findOne({
11+
where: { id: req.params.id },
12+
include: [
13+
{
14+
model: Bookmark,
15+
as: 'bookmarks',
16+
},
17+
],
18+
});
19+
20+
if (!category) {
21+
return next(
22+
new ErrorResponse(
23+
`Category with id of ${req.params.id} was not found`,
24+
404
25+
)
26+
);
27+
}
28+
29+
category.bookmarks.forEach(async (bookmark) => {
30+
await Bookmark.destroy({
31+
where: { id: bookmark.id },
32+
});
33+
});
34+
35+
await Category.destroy({
36+
where: { id: req.params.id },
37+
});
38+
39+
res.status(200).json({
40+
success: true,
41+
data: {},
42+
});
43+
});
44+
45+
module.exports = deleteCategory;
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const Category = require('../../models/Category');
3+
const Bookmark = require('../../models/Bookmark');
4+
const { Sequelize } = require('sequelize');
5+
const loadConfig = require('../../utils/loadConfig');
6+
7+
// @desc Get all categories
8+
// @route GET /api/categories
9+
// @access Public
10+
const getAllCategories = asyncWrapper(async (req, res, next) => {
11+
const { useOrdering: orderType } = await loadConfig();
12+
13+
let categories;
14+
15+
if (orderType == 'name') {
16+
categories = await Category.findAll({
17+
include: [
18+
{
19+
model: Bookmark,
20+
as: 'bookmarks',
21+
},
22+
],
23+
order: [[Sequelize.fn('lower', Sequelize.col('Category.name')), 'ASC']],
24+
});
25+
} else {
26+
categories = await Category.findAll({
27+
include: [
28+
{
29+
model: Bookmark,
30+
as: 'bookmarks',
31+
},
32+
],
33+
order: [[orderType, 'ASC']],
34+
});
35+
}
36+
37+
res.status(200).json({
38+
success: true,
39+
data: categories,
40+
});
41+
});
42+
43+
module.exports = getAllCategories;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const ErrorResponse = require('../../utils/ErrorResponse');
3+
const Category = require('../../models/Category');
4+
const Bookmark = require('../../models/Bookmark');
5+
6+
// @desc Get single category
7+
// @route GET /api/categories/:id
8+
// @access Public
9+
const getSingleCategory = asyncWrapper(async (req, res, next) => {
10+
const category = await Category.findOne({
11+
where: { id: req.params.id },
12+
include: [
13+
{
14+
model: Bookmark,
15+
as: 'bookmarks',
16+
},
17+
],
18+
});
19+
20+
if (!category) {
21+
return next(
22+
new ErrorResponse(
23+
`Category with id of ${req.params.id} was not found`,
24+
404
25+
)
26+
);
27+
}
28+
29+
res.status(200).json({
30+
success: true,
31+
data: category,
32+
});
33+
});
34+
35+
module.exports = getSingleCategory;

controllers/categories/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
createCategory: require('./createCategory'),
3+
getAllCategories: require('./getAllCategories'),
4+
getSingleCategory: require('./getSingleCategory'),
5+
updateCategory: require('./updateCategory'),
6+
deleteCategory: require('./deleteCategory'),
7+
reorderCategories: require('./reorderCategories'),
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const Category = require('../../models/Category');
3+
// @desc Reorder categories
4+
// @route PUT /api/categories/0/reorder
5+
// @access Public
6+
const reorderCategories = asyncWrapper(async (req, res, next) => {
7+
req.body.categories.forEach(async ({ id, orderId }) => {
8+
await Category.update(
9+
{ orderId },
10+
{
11+
where: { id },
12+
}
13+
);
14+
});
15+
16+
res.status(200).json({
17+
success: true,
18+
data: {},
19+
});
20+
});
21+
22+
module.exports = reorderCategories;
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const asyncWrapper = require('../../middleware/asyncWrapper');
2+
const ErrorResponse = require('../../utils/ErrorResponse');
3+
const Category = require('../../models/Category');
4+
5+
// @desc Update category
6+
// @route PUT /api/categories/:id
7+
// @access Public
8+
const updateCategory = asyncWrapper(async (req, res, next) => {
9+
let category = await Category.findOne({
10+
where: { id: req.params.id },
11+
});
12+
13+
if (!category) {
14+
return next(
15+
new ErrorResponse(
16+
`Category with id of ${req.params.id} was not found`,
17+
404
18+
)
19+
);
20+
}
21+
22+
category = await category.update({ ...req.body });
23+
24+
res.status(200).json({
25+
success: true,
26+
data: category,
27+
});
28+
});
29+
30+
module.exports = updateCategory;

0 commit comments

Comments
 (0)