GitHub: https://github.com/mahdiyari/steemauto-backend
PR1: https://github.com/mahdiyari/steemauto-backend/pull/1 (merged)
PR2: https://github.com/mahdiyari/steemauto-backend/pull/2 (merged)
PR3: https://github.com/mahdiyari/steemauto-backend/pull/3 (under development)
Steemauto
I'm in a bad position in the real and I'm trying to work and improve Steemauto
I just need more time
Thanks for your great support
Explanation
As you know, Steemauto is written by PHP and it is hard to add more features to it!
I want to re-code Steemauto with Javascript (backend) and Angular 6 (frontend)
After re-coding Steemauto with Javascript, anyone will be able to contribute more features! Working with Javascript is easier in the Steemauto!
The backend is almost done!
Let's skip talking and jump to the codes:
Development
I will use StandardJS as a Javascript coding standard in this project. If you are interested in the development, please install StandardJS to your IDE.
I will use ExpressJS as API server for Steemauto
const express = require('express')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const app = express()
...
...
const port = process.env.PORT || 3001
const host = process.env.HOST || '127.0.0.1'
app.listen(port, host, () => {
console.log(`Application started on ${host}:${port}`)
})
File and URL structures are easy to follow and easy to understand. Also, I added enough comments to cover all part of this project.
For example, Curation Trail operations are available in the /api/v1/dashboard/curation_trail/OPERATION
OPERATION is one of the followings:
/follow
/unfollow
/settings
/become
/update
It is easy to add or change any operation by just editing one file (index.js)
in this example: 'curation_trail/index.js':
const express = require('express')
const app = express()
const followTrail = require('./follow_trail')
const unfollowTrail = require('./unfollow_trail')
const settingsTrail = require('./settings_trail')
const becomeTrail = require('./become_trail')
const updateTrail = require('./update_trail')
app.use('/follow', followTrail)
app.use('/unfollow', unfollowTrail)
app.use('/settings', settingsTrail)
app.use('/become', becomeTrail)
app.use('/update', updateTrail)
module.exports = app
Also, /server.js is used to declare the main routes:
...
app.use('/api/v1/dashboard/curation_trail', curationTrail)
app.use('/api/v1/dashboard/fanbase', fanbase)
app.use('/api/v1/dashboard/schedule_post', schedulePost)
...
I used a middleware (is_auth.js) to verify the identity of users. This middleware will only allow authorized users to use the backend.
router.use(async (req, res, next) => {
if (req && req.cookies && req.cookies.access_key && req.cookies.username) {
const username = req.cookies.username
const accessKey = req.cookies.access_key
const result = await con.query(
'SELECT `access_key` FROM `users` WHERE `user`=?',
[username]
)
if (result && result[0].access_key === accessKey) {
next()
} else {
res.json({
id: 0,
error: 'wrong auth provided'
})
}
} else {
res.json({
id: 0,
error: 'missed auth param'
})
}
})
Curation trail and Fanbase finished. I'm working on the Schedule Posts section (submitting posts already finished).
I think in a few weeks, you will see new features and options in the Steemauto!
Steem on and support Steemauto!
Thanks for your great support
This post is submitted to the https://utopian.io
Regards,
2018-08-27