Show HN: Auto generate REST API from Mongoose schemas

17 points by aciswhat 5 years ago | 8 comments
  • _bxg1 5 years ago
    For a long time I've thought that the idea of having an entire, Turing-complete layer between the database and the HTTP API felt like overkill. You know your collections, you know the shape of your data, auth doesn't vary much between orgs. Unless you're doing interesting computations after querying, why do you have to program those endpoints over and over again for each entity in each project? It just seems silly.

    I'm honestly surprised there aren't more projects like this

    • xgenecloud 5 years ago
      >> why do you have to program those endpoints over and over again for each entity in each project? It just seems silly. I'm honestly surprised there aren't more projects like this

      This is exactly what got us started - we are solving automatic REST-GraphQL API endpoint creation for all SQL databases. Check us out https://github.com/xgenecloud/xgenecloud

      • aciswhat 5 years ago
        Wow this looks awesome!
      • SOLAR_FIELDS 5 years ago
        There are quite a few projects like this, though this is the first one I’ve seen for Mongo specifically. The most well known is probably PostgREST, though I recently saw a project on here that encapsulates the other relational DB providers as well (MSSQL, MariaDB, etc)
      • aciswhat 5 years ago
        Hello Hacker News! This is something I quickly prototyped yesterday to automatically generate a REST API from existing Mongoose schemas. It's incredibly useful for mocking your exact backend, or just spinning up an MVP backend.

        Authentication is also built in (currently only supports email/password, but more in the works). I implemented granular permissions for API routes that can be set via configuration really easily, which uses JWTs from the user login.

        • xgenecloud 5 years ago
          >> Creates a hot-reloading server that auto-updates whenever models are updated or created.

          This is neat.

          Does this mean - if your generator finds a new model in mongodb, it autogenerates model file within the folder and vice-versa it creates APIs if there is a new model file within model folder ?

          • aciswhat 5 years ago
            Yes, if it finds a new model in the `./models` folder, it'll automatically create those endpoints!
        • 5986043handy 5 years ago
          This seems pretty useful! Will try out for my next side project.