StickyBoard
Search…
Back-end Customization

Database

You have to set your own relational database(MySQL or MariaDB) to use StickyBoard.
You can change database end-point by modifying .env file.
When you run StickyBoard, it will create default tables below.
ERD of StickyBoard

API

You can add your own API to StickyBoard back-end server.
Let's see how you can add custom API.
First of all, you must create route file like below.
You would add Sequelize query or other processing method here.
src/models/MySQL/UserLayoutRoute.js
1
var StatusCode = require('../../../../../network/StatusCode');
2
3
var UserLayout = require('../UserLayout')
4
var User = require('../User')
5
6
var UserLayoutRoute = {
7
// Create
8
create: function (req, res) {
9
var userId = req.params.userId;
10
var route = req.body.route;
11
var layout = req.body.layout;
12
13
UserLayout.find({
14
where: {
15
user_id: userId,
16
route: route,
17
}
18
})
19
.then(function (result) {
20
if (result !== null) {
21
res.status(StatusCode.CONFLICT).json({msg: 'Error'})
22
} else {
23
UserLayout.create({
24
user_id: userId,
25
route: route,
26
layout: layout,
27
})
28
.then(function (result) {
29
res.json(result)
30
})
31
.catch(function (err) {
32
console.log(err)
33
})
34
}
35
})
36
},
37
38
// Read
39
read: function (req, res) {
40
...
41
},
42
43
// Update
44
update: function (req, res) {
45
...
46
},
47
48
// Delete
49
delete: function (req, res) {
50
...
51
}
52
}
53
54
module.exports = UserLayoutRoute
55
Copied!
And next, import the route file and add a routing code like below.
app.js
1
...
2
3
var UserLayoutRoute = require('./src/database/models/MySQL/User/routes/UserLayoutRoute');
4
5
...
6
7
var router = Express.Router();
8
9
/******************
10
API routing
11
******************/
12
...
13
14
// User Layout
15
router.post('/user/:userId/layout/#x27;, function (req, res) { UserLayoutRoute.create(req, res) });
16
router.get('/user/:userId/layout/#x27;, function (req, res) { UserLayoutRoute.read(req, res) });
17
router.put('/user/:userId/layout/#x27;, function (req, res) { UserLayoutRoute.update(req, res) });
18
router.delete('/user/:userId/layout/#x27;, function (req, res) { UserLayoutRoute.delete(req, res) });
19
20
...
Copied!
It's all done! Test your newly added API.
Last modified 2yr ago
Copy link
Contents
Database
API