A boilerplate generator that uses ejs
to produce a redux-saga
CRUD based on the database structure of any rails
API that uses postgresql
.
Are you tired of manually coding every single form in your React components? Now you can generate them automatically. Formify detects the structure of your database and generates the necessary forms based on the tables and fields. You can then add or remove details from the generated boilerplate to fit your needs.
git clone
the repo, cd
to it and:
$ npm install
$ cd src/scripts
- Make sure
postgresql.json
contains your database credentials. $ ./generate.sh
$ npm start
This should generate all the necessary forms based on the postgresql.json
database. To use a different database name or credentials, modify the postgresql.json
file.
For example, a database from a rails
API with the following schema.rb
:
ActiveRecord::Schema.define(version: 2021_09_07_212158) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "testtypes", force: :cascade do |t|
t.binary "binary"
t.boolean "boolean"
t.date "date"
t.datetime "datetime"
t.decimal "decimal"
t.float "float"
t.integer "integer"
t.string "string"
t.text "text"
t.time "time"
t.datetime "timestamp"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
end
Will generate the following form through the /src/components/testtypes_form.json
"form object" file:
This form object is then loaded to the CRUD components in /src/components/
. For a better understanding of how these form objects work, visit the react-jsonschema-form playground, as well as their docs.
You can test the CRUD against formify_rails_api
. It's a typical unsecured Rails API with the schema.rb
from the example in this README
.
For more details about how the data pipeline from rails to react works, check out this experimental draft:
https://gist.github.com/voscarmv/cf4b126eed800a087d2f20a15f04265a
- Complete Sagas CRUD.
- Debug
formify.js
to produce working code. - Automate database structure extraction.
- Automate component generation and file distribution.
- Add Ui styles to forms.
- Secure with JWT (devise-jwt)