GithubHelp home page GithubHelp logo

wrannaman / generators Goto Github PK

View Code? Open in Web Editor NEW
236.0 3.0 30.0 2.4 MB

API Generator - instantly generate REST and GraphQL APIs (openapi (OAS) 3.0.0)

Home Page: https://noco.io

License: MIT License

JavaScript 100.00%
generator nodejs-server nodejs nodejs-development oasv3 oas api-generator swagger-codegen openapi-generator openapi openapi3 mit-license microservice microservice-framework rest graphql

generators's Introduction

Rest/GraphQL APIs + React Components Generator ๐Ÿ”ฅ

Buy Ligit License Follow on Twitter Average time to resolve an issue Percentage of issues still open npm package NPM Downloads

Sugar Generator - API Edition

App Demo

This project is sponsored by

SponsoredBy.dev

Quick Start

  1. Install the npm module
# install
npm i -g sugar-generate
  1. Create a json schema save, this to monkey.json
{
  "name": "monkey",
  "schema": {
    "name": {
      "type": "String",
      "default": ""
    },
    "alive": {
      "type": "Boolean",
      "default": false
    },
    "age": {
      "type": "Number",
      "default": false
    }
  }
}
  1. Generate your api and app
sugar-generate \
--schema monkey.json \
--destination ./my-monkeys

Boom, you now have:

API:

  • GraphQL API
  • REST API
  • Working Tests

APP:

  • React create item form
  • React table that supports
    • search
    • sort
    • filter
    • pagination
    • edit item
    • create item

Start the API

cd ./my-monkeys/api
npm i
npm run start

# http://localhost:7777

Start the APP

cd ./my-monkeys/app
npm i
npm run dev

# http://localhost:3000

Behold Magic

A fully functioning react table and form with searching sorting filtering, editing, adding, global search, download, and refresh.

SugarKubes Generated App

Links

GraphQL is on localhost:7777/graphql

Swagger is on localhost:7777

APP is on localhost:3000

API is on localhost:7777

Documentation

API Documentation (generated back end)

App Documentation (generated front end)

Experimental Embeddable Components

What if you could remotely update your components without having to push new code?

Thats one question we're exploring with the experimental embeddable react components. There are of course cool ways to serve single pages as serverless functions but what's cooler would be a way for even non-technical people to update a database schema and a form or table in real time without writing any code.

  • Each component comes out in an embeddable format under /embed
  • TBD - How to easily deploy these and use them.

Updates

  • 8/5/19 support for mongo arrays in documents

generators's People

Contributors

dependabot[bot] avatar wrannaman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

generators's Issues

Feature: PostGres

Any interest in adding PostGres support? Thinking of Postgres + Hasura.

Invalid schema

Im trying to use the generator using the schema from the readme but im getting "invalid schema error".

sugar-generate --type api --name monkey --schema D:\Demos\generator\monkey.json --destination D:\Demos\generator\

schema:

{ "schema": { "name": { "type": "String", "default": "" }, "isDead": { "type": "Boolean", "default": false }, "age": { "type": "Number", "default": false } }, "statics": {} }

Tryied with the schema on same folder. The error is the same.

Feature: Generate a server from an OpenAPI spec

It'd be good if this project could work from an OpenAPI spec, similar to what openapi-generator does. I think that project is heading towards generating servers, but this one already has the grounding for it. Of course, this would open up a lot of issues beyond the usual CRUD operations. Perhaps in the instance of getting the DB ready, it might still need a JSON schema.

invalid schema example

When i launch sugar-generate -s monkey.json with this monkey.json

{
"schema": {
"name": { "type": "String", "default": "" },
"isDead": { "type": "Boolean", "default": false },
"age": { "type": "Number", "default": false }
},
"statics": {}
}

My terminal return
Error => invalid schema. Schema requires a name

Is it normal ?

Failed prop type warning message

Hi,
the app runs successfully, however, there is a warning message returned

Warning: Failed prop type: Invalid prop actions[0]supplied toMaterialTable. in MaterialTable in Unknown in WithStyles(Component) (at ChannelTable.js:125) in div (at ChannelTable.js:124) in div (at ChannelTable.js:123) in div (at ChannelTable.js:122) in ChannelTable in WithStyles(ChannelTable) (at pages/index.js:68) in div (at pages/index.js:60) in div in ForwardRef(Grid) in WithStyles(ForwardRef(Grid)) (at pages/index.js:58) in div in ForwardRef(Grid) in WithStyles(ForwardRef(Grid)) (at pages/index.js:50) in div in Styled(MuiBox) (at pages/index.js:41) in div in ForwardRef(Container) in WithStyles(ForwardRef(Container)) (at pages/index.js:40) in Index (at _app.js:29) in Context.Provider in ThemeProvider (at _app.js:26) in Container (at _app.js:22) in MyApp (at _document.js:64) in Context.Provider in StylesProvider in Unknown in Context.Provider in Context.Provider in Context.Provider in Context.Provider

Cheers

Bug: Cannot install in Docker

Dockerfile:

FROM node:lts-alpine
RUN apk add --no-cache mongodb
WORKDIR /opt/generators
COPY monkey.json /opt/generators/monkey.json
RUN npm install -g sugar-generate
RUN sugar-generate --schema monkey.json --destination /opt/generators/generated-api
RUN cd /opt/generators/generated-api/api && npm install
# RUN cd /opt/generators/generated-api/app && npm install
EXPOSE 7777
CMD cd ./generate-api/api && npm run start

Build logs:

Sending build context to Docker daemon  107.5kB
Step 1/9 : FROM node:lts-alpine
lts-alpine: Pulling from library/node
e7c96db7181b: Pull complete
bbec46749066: Pull complete
89e5cf82282d: Pull complete
5de6895db72f: Pull complete
Digest: sha256:07897ec27318d8e43cfc6b1762e7a28ed01479ba4927aca0cdff53c1de9ea6fd
Status: Downloaded newer image for node:lts-alpine
 ---> 9dfa73010b19
Step 2/9 : WORKDIR /opt/generators
 ---> Running in e0ead4eefd62
Removing intermediate container e0ead4eefd62
 ---> be50ab18bb74
Step 3/9 : COPY monkey.json /opt/generators/monkey.json
 ---> b5abd25e2336
Step 4/9 : RUN npm install -g sugar-generate
 ---> Running in 62848a96fc74
/usr/local/bin/sugar-generate -> /usr/local/lib/node_modules/sugar-generate/index.js
npm WARN [email protected] requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.

+ [email protected]
added 60 packages from 45 contributors in 6.017s
Removing intermediate container 62848a96fc74
 ---> 8ac6d0775b0c
Step 5/9 : RUN sugar-generate --schema monkey.json --destination /opt/generators/generated-api
 ---> Running in 130bef8c5643
internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module './api/makeAPI'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/sugar-generate/index.js:5:17)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

I've checked that I'm running the same version locally (v10.6.0) and installing the same version (v0.1.5) in the container as I am on the host.

Of note is that there's a file in the folder it's looking in called makeApi.js (note the case). It's odd that locally, the case problem is ignored.

swagger-inline not automatically called

The swagger-inline is not being called automatically, so when the environment is running, no swagger.json file is located when browsing the web app.

The following line: swagger-inline './controller/*/*.js' './models/*.js' --base './swaggerBase.yaml' --out swagger.json has to be manually called from within the generated api folder.

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.