Giter Site home page Giter Site logo

Comments (6)

o1lab avatar o1lab commented on April 28, 2024 1

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.

from nocodb.

o1lab avatar o1lab commented on April 28, 2024

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.

from nocodb.

clancye avatar clancye commented on April 28, 2024

@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.

from nocodb.

o1lab avatar o1lab commented on April 28, 2024

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

from nocodb.

neo7-studio-web avatar neo7-studio-web commented on April 28, 2024

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.

from nocodb.

BaseD75 avatar BaseD75 commented on April 28, 2024

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?

from nocodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.