Krenovator LMS (backend) is a collaborative learning platform.
- System requirements
- Installation
- Configuration File
- Database Migration
- System Architecture
- Troubleshooting
- NodeJS v12 or higher
- MySQL
- Code IDE - preferably Visual Studio, Vim
- IBM Loopbackframework - Version Loopback 4
- AWS Cloud S3
- SMTP Access
git clone
npm ci
- Create a file name
.env
file in root folder - Copy the syntax from
.env-example
to.env
and enter the information as below:
Key | Description | Example value |
---|---|---|
NODE_ENV | General code environment | production or development |
TOKEN_SECRET | JWT hasing salt | mylocal |
TOKEN_VALIDITY | JWT Expiration in milliseconds | 21600 |
MYSQL_HOST | Path to MYSQL instance | localhost |
MYSQL_DB | Name of the DB | obkreno |
MYSQL_USERNAME | username | root |
MYSQL_PASSWORD | password | |
SMTP_HOST | Handle outgoing email SMTP | [email protected] |
SMTP_SECURE | Handle outgoing email SMTP | true @ false |
SMTP_PORT | Handle outgoing email SMTP | 465 |
SMTP_USERNAME | Handle outgoing email SMTP | |
SMTP_PASSWORD | Handle outgoing email SMTP | |
OTP_ENABLE | Enable OTP (one-time-password) login | 0 or 1 |
SMS_URL | If OTP_ENABLE=1, SMS provider detail (optional) | |
SMS_API | If OTP_ENABLE=1, SMS Api Key (optional) | |
SMS_TAG | If OTP_ENABLE=1, SMS Tag (optional) | |
OTP_SECRET | If OTP_ENABLE=1, OTP code generation secret (optional) | |
OTP_VALIDITY | Define how long the token will be valid in milliseconds | |
ONESIGNAL_APPID | Optional, OneSignal | |
ONESIGNAL_APPKEY | Optional, OneSignal | |
STORAGE_PROVIDER | Optional, Storage | aws |
STORAGE_PROVIDER_KEY_ID | Optional, Storage | |
STORAGE_PROVIDER_KEY | Optional, Storage | |
STORAGE CONTAINER | Optional, Storage |
Database: MySQL
The model is built with SQL-query in mind. To change it, u need to update the datasource.
Database migration is a process to migrate models to database tables or collections. When a migration is finished, the dataset in the source databases resides in target databases.
Auto-migration helps the user create relational database schemas based on definitions of their models together with their relation.
Reference https://loopback.io/doc/en/lb4/Database-migrations.html
Create a new migration
- Create models
- Create repository
- Add model in
migrate.ts
Run migration
npm run build
npm run migrate
To reduce system complexity, the framework use cloud-based storage.
Reference Loopback-storage-components
- Go to file.datasource.ts, and change code for
const config
to below
const config = {
name: 'File',
connector: 'loopback-component-storage',
provider: 'aws',
key: <AWS_KEY>,
keyId: <AWS_KEY_PROVIDER>,
nameConflict: 'makeUnique',
makeUnique: true,
};
To get AWS_KEY you'll will need to register and go to AWS Console
To change to to local storage follow step belows:
- In root, create a new folder named
storage
- Change directory inside
./storage
and create another folder name similar as STORAGE CONTAINER - Go to file.datasource.ts, and change code for
const config
to below
const config = {
name: 'File',
connector: 'loopback-component-storage',
provider: 'filesystem',
root: './storage',
};
- Run application