Skip to content

Repository files navigation

Agora Flat Server

Project flat-server is a Node.js server for the Agora Flat open source classroom.

中文

Features

  • Login via
  • Wechat
  • Github
  • Google
  • Room scheduling
    • Ordinary rooms
    • Periodic rooms
  • Signing tokens for Whiteboard, Real-time video/audio chat(RTC), Real-time messaging(RTM)
  • Cloud recording and replaying
  • Cloud Storage for multi-media courseware

Develop Locally

Execute the following steps to run flat-server:

Installation

yarn install --frozen-lockfile

Setup Environment

  1. Create files config/development.local.yaml.
  2. Add environment variables following the config/defaults.yaml format.

Run the Project

  1. Execute at project root:
 yarn run start
  1. Open another terminal and execute at project root:
 node ./dist/index.js

You should see ready on http://0.0.0.0:80 if everything is OK.

Deployment

Deployment is not needed for local development. If you want to bring the server up online, deploy anyway you like.

Warning If you have deployed this project before, please see the migration documentation

Environment Variables Reference

server:
# Server portport: 80redis:
# Redis hosthost:
# Redis portport:
# Redis usernameusername:
# Redis passwordpassword:
# Redis db namedb:
# Redis-based implementation of the deferred queue db namequeueDB:
mysql:
# MySQL hosthost:
# MySQL portport:
# MySQL usernameusername:
# MySQL passwordpassword:
# MySQL databasedb:
jwt:
# JWT secretsecret:
# JWT crypto algorithms, see: https://github.com/auth0/node-jsonwebtoken/tree/d71e383862fc735991fd2e759181480f066bf138#algorithms-supportedalgorithms:
# Front-end addresswebsite: https://flat-web-dev.whiteboard.agora.iolog:
# Log path name, see: https://github.com/netless-io/flat-server/blob/main/src/utils/EnvVariable.tspathname: "{{PROJECT_DIR}}/logs"# Log file name, see: https://github.com/netless-io/flat-server/blob/main/src/utils/EnvVariable.tsfilename: "{{DAY_DATE}}"cloud_storage:
# Maximum count of Cloud Storage uploading files. Default: 3concurrent: 3# Maximum size of a Cloud Storage file. Default: 500Msingle_file_size: 524288000# Maximum Cloud Storage size of a user. Default: 2Gtotal_size: 2147483648# Cloud Storage upload path prefix. Default: cloud-storage (No / prefix or suffix)prefix_path: cloud-storage# Cloud Storage supported file extensionsallow_file_suffix:
- ppt
- pptx
- doc
- docx
- pdf
- png
- jpg
- jpeg
- gif
- mp3
- mp4user:
avatar:
# Maximum size. Default: 5Msize: 5242880# User supported upload image file extensionsallow_suffix:
- png
- jpg
- jpegoauth:
logo:
# Upload logo path prefix. Default: oauth-logo (No / prefix or suffix)prefix_path: oauth-logo# Maximum size. Default: 5Msize: 5242880# Logo supported upload image file extensionsallow_suffix:
- png
- jpg
- jpeglogin:
wechat:
# See: https://developers.weixin.qq.com/doc/oplatform/Website_App/WeChat_Login/Wechat_Login.htmlweb:
# Whether to enable WeChat login on the web/desktop sideenable: false# App IDapp_id:
# App Secretapp_secret:
# See: https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Development_Guide.htmlmobile:
# Whether to enable WeChat login on the mobile sideenable: false# App IDapp_id:
# App Secretapp_secret:
# See: https://docs.github.com/cn/developers/apps/building-oauth-apps/authorizing-oauth-appsgithub:
# Whether to enable GitHub loginenable: false# GitHub Client IDclient_id:
# GitHub Client Secretclient_secret:
# In development, see: https://developers.google.com/identity/protocols/oauth2google:
# Whether to enable Google loginenable: false# Google Client IDclient_id:
# Google Client Secretclient_secret:
# Redirect URIredirect_uri:
apple:
# Whether to enable Apple loginenable: false# Not open to the public at the momentagora:
# Whether to enable Agora loginenable: false# Agora Client IDclient_id:
# Agora Client Secretclient_secret:
# Phone message loginsms:
# Whether to enable SMS loginenable: true# Is force binding phoneforce: false# Test user (Only valid if server.env is dev)# You need to run MYSQL yourself to insert the user# INSERT INTO user_phone (version, user_uuid, user_name, phone_number) VALUES (1, 'uuid', 'name', 'phone');# INSERT INTO users (version, user_uuid, user_name, user_password, avatar_url) VALUES (1, 'uuid', 'name', '', 'url');test_users:
- phone:
code:
chinese_mainland:
# see: https://help.aliyun.com/document_detail/419273.htm?spm=a2c4g.11186623.0.0.34371d58IYPbs3access_id:
access_secret:
template_code:
sign_name:
# Hong Kong, Macao and Taiwan regions of Chinahmt:
access_id:
access_secret:
template_code:
sign_name:
global:
access_id:
access_secret:
template_code:
sign_name:
agora:
# For RTC and RTM. See: https://docs.agora.io/en/Agora%20Platform/get_appid_token?platform=All%20Platformsapp:
# Agora App IDid:
# Agora App Certificatecertificate:
# For classroom replaying. See: https://docs.agora.io/en/cloud-recording/faq/restful_authentication?platform=All%20Platformsrestful:
# Agora RESTful IDid:
# Agora RESTful Secretsecret:
# For storing RTC Cloud Recording media files. See: https://docs.agora.io/en/cloud-recording/restfulapi/# Path: Cloud Recording Start -> Schema -> clientRequest -> storageConfigoss:
access_id:
access_secret:
vendor:
region:
bucket:
folder:
prefix:
# Video screenshot service# See: https://docs.agora.io/en/cloud-recording/cloud_recording_screen_capture?platform=RESTfulscreenshot:
enable: falseoss:
access_id:
access_secret:
vendor:
region:
bucket:
folder:
prefix:
# Message notification service# See: https://docs-preprod.agora.io/en/Agora%20Platform/ncsmessageNotification:
enable: falseevents:
# Currently only supported `productID: 3` and `eventType: 45`
- productID:
eventType:
secret:
# See: https://docs.agora.io/en/whiteboard/generate_whiteboard_token_at_app_server?platform=RESTfulwhiteboard:
# Whiteboard AKaccess_key:
# Whiteboard SKsecret_access_key:
# Convert Region# "cn-hz" | "us-sv" | "sg" | "in-mum" | "gb-lon"convert_region:
# Storage Servicestorage_service:
# Currently, only supported OSStype: ossoss:
access_key:
secret_key:
endpoint:
bucket:
region:
# Content censorshipcensorship:
# Need to configure screenshot and messageNotification services under agora# messageNotification needs to be added: productID: 3 and eventType: 45 (see: https://docs.agora.io/en/cloud-recording/cloud_recording_callback_rest)# The principle is to take a screenshot of all the video streams in the room at regular intervals, get the screenshot address through the message notification service, and call a third party (e.g. AliCloud) to review the API to check itvideo:
enable: false# Current only support aliCloudtype: aliCloud# See: https://www.alibabacloud.com/help/en/content-moderation/latest/development-preparations-1aliCloud:
access_id:
access_secret:
endpoint:
# See: https://docs.agora.io/cn/cloud-recording/audio_inspect_restful?platform=RESTful# NOTE: No English description available at the momentvoice:
enable: false# Current only support aliCloudtype: aliCloudaliCloud:
uid:
access_id:
access_secret:
callback_address:
text:
enable: false# Current only support aliCloudtype: aliCloud# See: https://www.alibabacloud.com/help/en/content-moderation/latest/development-preparations-1aliCloud:
access_id:
access_secret:
endpoint:

If deployment is required then you need to ensure that the following variables are present in the environment variables for deployment:

Variable NameDescriptionNote
METRICS_ENABLEDWhether to enable metrics monitoring
METRICS_ENDPOINTmetrics url pathe.g.: /metrics
METRICS_PORTmetrics porte.g.: 9193

Tech Stack

Disclaimer

You may use Flat for commercial purposes but please note that we do not accept customizational commercial requirements and deployment supports. Nor do we offer customer supports for commercial usage. Please head to Flexible Classroom for such requirements.

About

A Node.js server for the Agora Flat open source classroom.

Topics

Resources

Stars

684 stars

Watchers

18 watching

Forks

Releases

Packages

Used by

Contributors

Languages