Steemauto - backend improvement

in #utopian-io6 years ago

steemauto_bitpizza.gif

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

Sort:  

Thank you for your contribution. It is good to see you are improving your code and rewriting it in the newer technology. The code really looks good. The commit messages and comments are also good.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @codingdefined!

So far this week you've reviewed 4 contributions. Keep up the good work!

steemauto is an example of hard work which made the whole ecosystem a beeter place for growth and ease of use.

we all owe to you @mahdiyari
thanks for the great job 👏👏👏🙇‍♂️


BluePages_PromoBanner.jpg

Hi @mahdiyari, your @steemauto project has been listed in the new @steembluepages directory of useful things! Check out our listings if you have a moment. Hopefully @steembluepages can grow a following and drive further traffic your way. Keep up the great work, and we hope this helps the project!

Thanks! Appreciate the service.

Hey @mahdiyari
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Good post having a good knowledge. I have given you my witness vote plse upvote me also

Dear friend @mahdiyari, thank you for your support, certainly SteemAuto is a spectacular application. receive my affection.

Great work @mahdiyari ! Your efforts are impressive.

I am happy to hear some updates, I use steemauto. keep it up.

Why are my fan base up votes not working? I am above the limit and I am not paused. Several high value posts have been missed because they were not up voted by steemauto. I did manually up vote those I am folllowing, even though they should have already been up voted

Steemauto is up now

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.034
BTC 66258.39
ETH 3170.93
USDT 1.00
SBD 4.07