Documentation Discord MIT License Register

Sample backend app for Node.js

This is a sample backend app built on Node.js with Express.js middleware and the 100ms REST APIs. Exposed endpoints

  • Create room
  • Get auth token to join the room
  • Get usage analytics

Get started

Deploy directly to Render using this button. But don't forget to add the environment variables specified in .env.example to Render or the build will fail!

Deploy to Render

Installation

  1. Clone the repo

    git clone https://github.com/100mslive/100ms-sample-backend-nodejs.git
    
  2. Install the dependencies

    npm i
    
  3. Rename the .env.example to .env and add your credentials

    APP_ACCESS_KEY=<YOUR_APP_ACCESS_KEY>
    APP_SECRET=<YOUR_APP_SECRET>
    
  4. Run the app

    Running in dev mode (hot reload on file changes):

    npm run start:dev
    

    Running in production:

    npm run start
    

    Run with Docker Compose

    docker compose up --build
    

Usage

This sample exposes the following endpoints

Endpoint Method Parameters Description
/create-room POST JSON body
{
  "name": "new-room-1",
  "description": "Sample description",
  "template_id": "6318xxxxxxxxxxxxxxxc60"
}
Create a new room with room params (docs)
/auth-token POST JSON body
{
  "room_id": "632ecxxxxxxxxxxxxxxxx764",
  "role": "host",
  "user_id":"test_user"
}
Generate an auth token for a peer to join a room (docs)
/session-analytics-by-room GET Query params
?room_id=633dxxxxxxxxxxxxxxx7d1d2
Usage analytics for a specific session (docs)
/session-list-by-room GET Query params
?room_id=633dxxxxxxxxxxxxxxx7d1d2
Get list of all sessions associated with a room (docs)

Docs

Refer to the 100ms server-side docs to get started on your custom backend.