Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is it installed if i wanted to make changes in the API #25

Closed
ryhill opened this issue Feb 10, 2018 · 6 comments
Closed

Where is it installed if i wanted to make changes in the API #25

ryhill opened this issue Feb 10, 2018 · 6 comments

Comments

@ryhill
Copy link

ryhill commented Feb 10, 2018

Where are the files installed on the server if i wanted to make changes in the API

@o1lab
Copy link
Member

o1lab commented Feb 11, 2018

If I am not wrong - I understand the question as programmatic use of Xmysql where one can have methods to override or have hooks before/after for each API. This is something which is being considered in the future releases.

@o1lab o1lab closed this as completed Mar 11, 2018
@clancye
Copy link

clancye commented Sep 12, 2018

@o1lab I've been thinking about this because I want to perform some backend input validation on the fields before xmysql includes them in a query. Did you have a potential implementation for the hooks? Would we have to write these in a separate JS file to be referenced by xmysql?

One possible workaround that doesn't involve any xmysql development is to have two backend layers: validation and xmysql. Validation layer receives HTTP requests from front end, checks the input data against certain business rules to make sure it will be a valid query, and then sends the request to the xmysql server to execute the query.

Another solution would be to make xmysql a library we can use inside our own Node app to generate an instance of a xmysql class and use its methods. This would allow the backend server to receive a request from the frontend, run some checks on the input fields according to business rules, and then call some xmysql methods to alter the database. This would simplify the backend architecture in comparison to my other suggestion. Here's the general idea:

const app = require('express')  
const xmysql = require('xmysql')

xmysql.initialize(host, user, dbname)

app.post('/table_name', (req, res) =>{
  if(postPrecheck(table_name, req, res) === false){
    res.send(500)
  } else {
    xmysql.xctrl.create(req)
    res.send(200)
  }
})

postPrecheck() would be filled out by the user. It's a work in progress, but wanted to share my thoughts.

@o1lab
Copy link
Member

o1lab commented Sep 12, 2018

@clancye please refer to auth issue which is open. Im addressing it there in future.

@neo7-studio-web
Copy link

If I am not wrong - I understand the question as programmatic use of Xmysql where one can have methods to override or have hooks before/after for each API. This is something which is being considered in the future releases.

I understand this :
Is xmysql generating some code (e.g. expressjs files) for the api that we could get somewhere and manually change for using on another expressjs. xmysql would be used as an api "generator" for express.

@o1lab
Copy link
Member

o1lab commented Sep 15, 2018

Is xmysql generating some code (e.g. expressjs files) for the api that we could get somewhere and manually change for using on another expressjs

Currently, xmysql is not generating code in any files. Its all within data structures in memory.

@clancye : sorry I could not come back other day completely as I was on mobile. I am reconsidering some aspect to give hooks given how easy it is now to just run xmysql as docker.

Having apis in files makes it easy to develop on.
Having hooks will make it easy to say from docker point of view.

I would be happy to keep both if possible. Any suggestions from docker point of view and hooks are welcome.

@BaseD75
Copy link

BaseD75 commented Jul 24, 2019

Regarding the comment of @karelnet and @o1lab his answer:
I was looking on the net for a way to generate API code given some mySQL tables and found this project (which is great by the way :-).

But now I do not quite understand the answer. Will there (maybe) be a feature in te future to only generate code instead of immediately running the express server so I can use it as a starting point for further developement? Or maybe there is already something else that makes this possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants