@simitgroup/simpleapp-generator
v1.6.6-i-alpha
Published
frontend nuxtjs and backend nests code generator using jsonschema
Downloads
16
Readme
Introduction
SimpleApp generator is a typescript code generator for convert jsonschemas become workable frontend (nuxt) and backend (nest). There is plenty of benefit included:
- complex multi-tenancy data isolation structure which support tenant/organization/branches
- unified frontend and backend data validation according jsonschemas
- Auto generate frontend template, frontend developer freely modify layout without worry integration lose
- It design as easy to understand as possible, developer can work at frontend and backend separately after code generated.
- It design with concept allow unlimited regenerate without break your codes, schemas can change anytime and the impact should be minimal
- visualize as much as possible programming design, formula in jsonschemas, reduce burden of software audit and handover. included a. schemas b. additional api besides CRUD c. document status d. authorization e. formulas of specific fields f. data types and validations
- build in enterprise functionality included: a. document numbering [x] b. authentication and authorization [x] c. data modification audit trail [] d. SSO [x] e. openapi interface [x] f. pdf document [] g. document uploads[]
- BPMN workflow integration a. streamline business flow with BPMN b. implement philosophy of bpmn documentation is source code c. fill in minimal source code in generated listener to run whole bpmn process d. build in integrate between both frontend and backend e. declare workflow in jsonschema
- graphql
Documentation
- jsonschemas
- backend walk through
- frontend walk through
- End to End test
- BPMN walk through
- Language
- Viewer, with add, update. using event after and properties
paras
- Document Status
- Additional Api & define api schema 10.SimpleAppInputs 11.Role Base Access Control 12.graphql
Quick start
- Simpleapp implement database transaction, and require mongodb cluster, below setup 3 nodes
#create network
docker network create mongoCluster
#prepare node1
docker run -d -p 27017:27017 --name mongo1 --network mongoCluster mongo:6 mongod --replSet myReplicaSet --bind_ip localhost,mongo1
#prepare node2
docker run -d -p 27018:27017 --name mongo2 --network mongoCluster mongo:6 mongod --replSet myReplicaSet --bind_ip localhost,mongo2
#prepare node3
docker run -d -p 27019:27017 --name mongo3 --network mongoCluster mongo:6 mongod --replSet myReplicaSet --bind_ip localhost,mongo3
# build cluster
docker exec -it mongo1 mongosh --eval "rs.initiate({
_id: \"myReplicaSet\",
members: [
{_id: 0, host: \"mongo1\"},
{_id: 1, host: \"mongo2\"},
{_id: 2, host: \"mongo3\"}
]
})"
# set mongod1 high priority as primary server
docker exec -it mongo1 mongosh --eval "cfg = rs.conf()
cfg.members[0].priority = 50
cfg.members[1].priority = 1
cfg.members[2].priority = 1
rs.reconfig(cfg)"
#check cluster status
docker exec -it mongo1 mongosh --eval "rs.status()"
** you may need to append below code into your /etc/hosts
127.0.0.1 mongo1 mongo2 mongo3
- create project folder
mkdir ~/project1
cd ~/project1
- install latest simpleapp-generator
npm install -g @simitgroup/simpleapp-generator ts-node
- init project folder, it will create some samples too
simpleapp-generator -g init
# !important
# Modify value in config.json, it will copy over to both frontend and backend .env
- prepare backend
./build.sh backend
- update backend configurations file by modify
~/project1/backend/.env
, change mongodb, keycloak settings according your requirements - start backend:
cd ~/project1/backend
pnpm start:dev
- prepare frontend (i use pnpm cause faster)
./build.sh frontend
- modify frontend configuration by modify
~/project1/frontend/.env
, change keycloak settings
OAUTH2_BASEURL=https://server-url #keycloak server url
OAUTH2_CONFIGURL=https://server-url/realms/testingrealm
OAUTH2_REALM=testingrealm
OAUTH2_CLIENTID=client1
OAUTH2_CLIENTSECRET=aaaa-xxxxx-yyyy-zzzzz-www
[email protected] #if you have multiple, separate by ','
- start frontend:
cd ~/project1/frontend
pnpm dev
#or use production way
nuxi build
nuxi preview
Perform Development
- add some schemas at
~/project1/schemas
- then run
./build.sh updatebackend
./build.sh updatefrontend
- to add different user group permission, you may change
project1/groups
Error Troubleshoot
Cannot start backend due to Unable to connect to the database. Retryi...
- You may have wrong configuration of mongodb connection string, try use mongodb compass access your clusters using same connection string
- the mongodb primary node may switch to another host, try restart mongodb container
node2
,node3
until primary server atnode1
. monitor using
docker exec -it mongo1 mongosh --eval "rs.status()"
ERROR [worker reload] [worker init] Cannot find package 'memory-cache' imported
- nuxt seems have some issue, try install this package manually
cd ~/project1/frontend
pnpm install memory-cache