fully-api
Version:
API framework for Fully Stacked, LLC REST-ful APIs
48 lines (37 loc) • 3.51 kB
Markdown
api framework for fully stacked LLC
You must create the database you wish to use with your fullyAPI project and set up the information for your default user in your settings file. Once you configure the appropriate base environment variables, you can boot the system and it will generate the default user and assocaited base api tables and records (users, session, user sessions, user auth). Sensitivie and auth related user data is stored in the table fsapi_user_auth to protect against sensitive user data getting out publically from the system in the event developers SELECT * from fsapi_user table.
### Configure your server options
Server options can be configured in the config.NODE_ENV.ts/confid.NODE_ENV.js files.
**Endpoints_ext Locations**
The file locations object in the configuration file specifies where the server should look to load all static files. The only one you should change is endpoints_ext. Changing math to any non-extension files should only be done with care, if you are intending to overright the core system static files.
**Utilities, DataAccess, AccessControl Extensions**
Each core service has an extension file that will be loaded and availible via Service.extensions.MethodName(). Do not mofidy core service files, as any changes will get overwritten by update releases. The server expects to load extension files from the same directory as your primary script. (Whereever the file you launch your pain process is located. hint: see package.json, "main" attribute.)
### DB Namespace:
all system generated tables are namespaced with the prefix fsapi_{{table_name}}.
Removing any existing columns from system generated tables may break internal functions. Adding new columns by different/new names to these tables is fine.
We recommend db migrate to manage all of your custom database table creation and mofifications. We recommend using the pre-installed extension for generating your primary keys to remain consistant with the system tables:
`id VARCHAR(36) NOT NULL DEFAULT uuid_generate_v1() primary key`
Example of a create table with foreign key references:
```
CREATE TABLE fsapi_user_session (
id VARCHAR(36) NOT NULL DEFAULT uuid_generate_v1() primary key,
user_id VARCHAR(36) NOT NULL references fsapi_user(id),
session_id VARCHAR(36) NOT NULL references fsapi_session(id),
rel_type VARCHAR(50) NOT NULL DEFAULT 'default',
created_at timestamp not null default current_timestamp,
data jsonb);
```
All system generated tables have a jsonb metadata column called data, should you need to store anything on the fly, that you do not with to make part of your relational table. We do not recommend storing any information you will query on or filter on frequently in this manner.
All environment variables needed for system boot are located in the config.js/config.ts file.
There are two endpoints related to account creation and authentication using SMS OTPs via twillio. These are POST sms_otp to send the one time passcode to the phone number provided. The other is POST otp_signIn to authenticate using the OTP. If no account is found, an account will be created with that phone number and authenticated using the phone number.
The following enviornment variables must be configured for this process with TWILIO to work
* TWILIO_ACCOUNT_SID
* TWILIO_AUTH_TOKEN
* TWILIO_SERVICE_ID