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 LTS.

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:

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.

DATABASE_USERNAME = "postgres"
DATABASE_DIALECT = "postgres"
DATABASE_PASSWORD = ""
DATABASE_DATABASE = "development"
DATABASE_HOST = "localhost"
DATABASE_LOGGING = "true"

For MySQL, use those settings:

DATABASE_USERNAME = "root"
DATABASE_DIALECT = "mysql"
DATABASE_PASSWORD = ""
DATABASE_DATABASE = "development"
DATABASE_HOST = "localhost"
DATABASE_LOGGING = "true"

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.

# Connection URL for Mongoose
# See https://mongoosejs.com/docs/index.html
DATABASE_CONNECTION = "mongodb://localhost:27017/development"
# In case you want to use ACID transactions, follow this doc:
# https://mongoosejs.com/docs/transactions.html
DATABASE_TRANSACTIONS = false

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.

# Secret used to Sign the JWT (Authentication) tokens.
AUTH_JWT_SECRET = "GENERATE_SOME_RANDOM_UUID_HERE"
# How long the JWT (Authentication) token takes to expire.
AUTH_JWT_EXPIRES_IN = "7 days"

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.

# Frontend Url.
# Ex.: http://localhost:<port>
FRONTEND_URL="http://localhost:<port>"
# Frontend URL with the subdomain for tenants.
# Works only for tenantMode=multi-with-subdomain
# Please use the variable [subdomain] on this URL.
FRONTEND_URL_WITH_SUBDOMAIN="http://[subdomain].localhost:<port>"

Email configuration

For the email configuration, follow the Emails with SendGrid section.

File Storage (Optional)

By default, files are stored on the localhost, but you can set Google Cloud Storage or Amazon S3 providers, by following the File Storage section.

Payments configuration (Optional)

For payments configuration, follow the Payments with Stripe section.

Installing the Dependencies

Go to the backend folder of your project and run:

npm install

You can ignore installation warnings.

Creating the database

Go to the backend folder of your project and run:

npm run db:create

For SQL: This command will create all the tables.

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:

npm start