This repo contains a sample address book application that demonstrates how to use the DreamFactory REST API. It includes new user registration, user login, and CRUD for related tables. Made using using Creat React App boierplate, Semantic UI React and React Data Table Component. There are two ways to interact with this application. You can either import it using the DreamFactory Admin Panel or run it locally from your hard drive. In both of those cases you will need a working DreamFactory instance.
You can create a free trial account or alternatively, you can download a open source version of DreamFactory here and run your own instance.
-
Create a default role for new users and enable open registration
- In the admin console, click the Roles tab then click Create in the left sidebar.
- Enter a name for the role and check the Active box.
- Click "Next" to go to the
Access tab
. - Add a new entry under
Service Access
(you can make it more restrictive later).- set
Service = All
- set
Component = *
- check all HTTP verbs under
Access
- set
Requester = API
- set
- Click
Save
. - Click the
Services
tab, then edit the user service. Go toConfig
.- Enable
Allow Open Registration
. - Set the
Open Reg Role Id
to the name of the role you just created. - Make sure
Open Reg Email Service Id
is blank, so that new users can register without email confirmation. - Save your changes.
- Enable
-
Make sure you have a SQL database service named
db
. Most DreamFactory instances have a defaultdb
service for SQLite. If you don't have one, you can add it by going to theServices
tab in the admin console and creating a newSQLite service
. Make sure you set the name todb
. -
Import the package file for the app.
- From the Apps tab in the admin console, click Import and click
Address Book for ReactJS
in the list of sample apps. The Address Book package contains the application description, source code, schemas, and sample data. - Leave
storage service
andfolder
blank
. It will use the default local file service namedfiles
. - Click the Import button. If successful, your app will appear on the Apps tab. You may have to refresh the page to see your new app in the list.
- From the Apps tab in the admin console, click Import and click
-
Edit your app API key and instance URL
- Use the file manager to edit
public/config.js
and setAPP_API_KEY
to the key for your new app. The API key is shown in the app details in the Apps tab of the admin console. LeaveINSTANCE_URL
empty.
- Use the file manager to edit
-
Make your app files public.
- Figure out where your app files are stored. If you used the default storage settings to import the app, it'll be the default local file service named
files
. - Go to the
Files
tab in the admin console. Find the folder for your app, e.g.,AddressBookForReact
. - Go to the Services tab in the admin console and click the
files
service. Click theConfig
tab and add the app folder nameAddressBookForReact
as a public path. - Save your changes.
- Figure out where your app files are stored. If you used the default storage settings to import the app, it'll be the default local file service named
- To start the application go to the
Apps
tab and clickplay
next to theAddress Book for React
. - Click the
Register
button to create a new account.
These accounts are managed inside the DreamFactory Users
tab. For security purposes, user registration is disabled by default therefore we had to enable the Allow Open Registration
in the user
service config
tab as descirbed in the instalation process.
- First install the app inside of DreamFactory by fallowing all the steps from the previous section. This way you will set up your instance properly and create all the necessary data.
- Clone this repository. Run
yarn
(ornpm i
).
$ git clone git@github.com:dreamfactorysoftware/df-react-example-application.git
$ cd df-react-example-application
$ yarn
- Edit
public/config.js
and setAPP_API_KEY
to the key for your new app. The API key is shown in the app details in the Apps tab of the admin console.INSTANCE_URL
should point to your instance.
window.appConfig = {
INSTANCE_URL: 'https://<INSTANCE_NAME>.apps.dreamfactory.com',
APP_API_KEY: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef',
};
- Start the application with
yarn start
.
$ yarn start
- Next, open your browser and navigate to
http://localhost:3000/
. Click theRegister
button to create a new account.