Backend
The configuration for the backend is located at the backend/.env file.
Installing NodeJS
Make sure you have NodeJS installed on your machine. The recommended version is 16.
Is recommended that you use a Node Version Manager tool for you to be able to switch version if you need it in the future.
MacOS/Linux: https://github.com/nvm-sh/nvm
Windows: https://github.com/coreybutler/nvm-windows
Installing the Database
Please make sure you have the database of your choice installed and running on your machine.
Also, make sure you have access to that database using a database GUI tool.
ScaffoldHub supports:
PostgreSQL (for the SQL version)
MySQL (for the SQL version)
MongoDB (for the MongoDB version)
Configuring .env variables
The .env file is located at backend/.env and it stores the environment variables.
SQL version
If you are using the default PostgreSQL database on your localhost, you can leave the configuration as it is.
You must have the DATABASE_DATABASE
created on your localhost server. The default config uses development as the database name.
For MySQL, use those settings:
MongoDB version
For the MongoDB version, you must place the full connection URL.
The default example uses the localhost server and the development schema.
The standard localhost server does not support ACID transactions, but you probably want it enabled in production. You can rent a cloud-hosted MongoDB database, point your localhost to it, and enable the DATABASE_TRANSACTIONS
flag. That way you ensure you are developing on the same conditions of your future production environment.
JWT secret and expiration
The JWT secret is used to sign the JWT tokens. Please replace the JWT secret to some random and long UUID chain. For example: a40a8850-24b2-4023-85ce-1765d10c849b-758df0c2-b112-4851-960d-1b7163d3ccd6
The JWT expiration invalidates the tokens after a certain period that can be configurated on the AUTH_JWT_EXPIRES_IN
variable.
Frontend URL
For localhost, the frontend URLs will be:
http://localhost:3000 (for React)
http://localhost:8081 (for Vue)
http://localhost:4200 (for Angular)
Same ports for the FRONTEND_URL_WITH_SUBDOMAIN
. Please leave the [subdomain] as it is. Note: This works only for the multi-with-subdomain tenant mode.
Email configuration
For the email configuration, follow the Emails with SendGrid section.
File Storage
Localhost
By default, files are stored on the localhost.
Cloud
For the premium version, you can set Google Cloud Storage or Amazon S3 providers, by following the File Storage section.
Social Sign-in
Social sign-in is pre-configured for Google and Facebook. What you have to do is to fill the AUTHSOCIAL* env variables with the secrets you get on your Google and Facebook developer accounts.
Facebook: https://developers.facebook.com/
Payments configuration (Optional)
For payment configuration, follow the Payments with Stripe section.
Installing the Dependencies
Go to the backend folder of your project and run:
You can ignore installation warnings.
Creating the database
For the SQL version: ScaffoldHub disables foreign keys to avoid problems with recursivity that some modelings may have. To enable foreign keys, search by constraints: false
in the backend and change the flags to true
. Note: Relationships to models.file
must keep the constraints: false.
Go to the backend folder of your project and run:
For SQL: This command will create all the tables.
If the following error occurs, you need to set a password in your database and change the DATABASE_PASSWORD in the .env file with the created password.
If the following error occurs, you need to set a password in your database and change the DATABASE_PASSWORD in the .env file with the created password.
"TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of Buffer, TypedArray, DataView, or KeyObject. Received null"
For MongoDB: This command will create all the collections and the indexes. If you skip this step, the app will work, but throw errors where you have unique validation defined.
Running the backend server
Go to the backend folder of your project and run:
Last updated