Create new basic backend tutorial for Ruby and update description of other backend tutorials
This commit is contained in:
parent
091b573e68
commit
189fa11fe8
@ -1,6 +1,6 @@
|
||||
# Basic Backend Java
|
||||
|
||||
Basic server application built with Spring Boot and Java. It internally uses [livekit-server-sdk-kotlin](https://github.com/livekit/server-sdk-kotlin).
|
||||
Basic server application built for Java with Spring Boot. It internally uses [livekit-server-sdk-kotlin](https://github.com/livekit/server-sdk-kotlin).
|
||||
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/java).
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<artifactId>basic-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>basic-java</name>
|
||||
<description>Basic server application built with Spring Boot and Java</description>
|
||||
<description>Basic server application built for Java with Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Basic Backend Node
|
||||
|
||||
Basic server application built with Node.js and Express. It internally uses [livekit-server-sdk-js](https://docs.livekit.io/server-sdk-js/).
|
||||
Basic server application built for Node.js with Express. It internally uses [livekit-server-sdk-js](https://docs.livekit.io/server-sdk-js/).
|
||||
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/node).
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "basic-node",
|
||||
"version": "1.0.0",
|
||||
"description": "Basic server application built with Node.js and Express",
|
||||
"description": "Basic server application built for Node.js with Express",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# Basic Backend Node
|
||||
|
||||
Basic server application built with Python and Flask. It internally uses [livekit-python-sdk](https://github.com/livekit/python-sdks).
|
||||
Basic server application built for Python with Flask. It internally uses [livekit-python-sdk](https://github.com/livekit/python-sdks).
|
||||
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/python).
|
||||
|
||||
|
||||
56
basic/backend/ruby/.gitignore
vendored
Normal file
56
basic/backend/ruby/.gitignore
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
# Used by dotenv library to load environment variables.
|
||||
# .env
|
||||
|
||||
# Ignore Byebug command history file.
|
||||
.byebug_history
|
||||
|
||||
## Specific to RubyMotion:
|
||||
.dat*
|
||||
.repl_history
|
||||
build/
|
||||
*.bridgesupport
|
||||
build-iPhoneOS/
|
||||
build-iPhoneSimulator/
|
||||
|
||||
## Specific to RubyMotion (use of CocoaPods):
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# vendor/Pods/
|
||||
|
||||
## Documentation cache and generated files:
|
||||
/.yardoc/
|
||||
/_yardoc/
|
||||
/doc/
|
||||
/rdoc/
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
Gemfile.lock
|
||||
# .ruby-version
|
||||
# .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
|
||||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
||||
# .rubocop-https?--*
|
||||
6
basic/backend/ruby/Gemfile
Normal file
6
basic/backend/ruby/Gemfile
Normal file
@ -0,0 +1,6 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'sinatra'
|
||||
gem 'sinatra-cors'
|
||||
gem 'puma'
|
||||
gem 'livekit-server-sdk'
|
||||
30
basic/backend/ruby/README.md
Normal file
30
basic/backend/ruby/README.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Basic Backend Node
|
||||
|
||||
Basic server application built for Ruby with Sinatra. It internally uses [livekit-server-sdk-ruby](https://github.com/livekit/server-sdk-ruby).
|
||||
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/basic/backend/ruby).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Ruby](https://www.ruby-lang.org/en/downloads/)
|
||||
|
||||
## Run
|
||||
|
||||
1. Download repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/OpenVidu/openvidu-livekit-tutorials.git
|
||||
cd openvidu-livekit-tutorials/basic/backend/ruby
|
||||
```
|
||||
|
||||
2. Install dependencies
|
||||
|
||||
```bash
|
||||
bundle install
|
||||
```
|
||||
|
||||
3. Run the application
|
||||
|
||||
```bash
|
||||
ruby app.rb
|
||||
```
|
||||
35
basic/backend/ruby/app.rb
Normal file
35
basic/backend/ruby/app.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require 'sinatra'
|
||||
require 'sinatra/cors'
|
||||
require 'livekit'
|
||||
require './env.rb'
|
||||
|
||||
SERVER_PORT = ENV['SERVER_PORT'] || 6080
|
||||
LIVEKIT_API_KEY = ENV['LIVEKIT_API_KEY'] || 'devkey'
|
||||
LIVEKIT_API_SECRET = ENV['LIVEKIT_API_SECRET'] || 'secret'
|
||||
|
||||
set :port, SERVER_PORT
|
||||
|
||||
register Sinatra::Cors
|
||||
set :allow_origin, "*"
|
||||
set :allow_methods, "POST,OPTIONS"
|
||||
set :allow_headers, "content-type"
|
||||
|
||||
post '/token' do
|
||||
content_type :json
|
||||
|
||||
body = JSON.parse(request.body.read)
|
||||
room_name = body['roomName']
|
||||
participant_name = body['participantName']
|
||||
|
||||
if room_name.nil? || participant_name.nil?
|
||||
status 400
|
||||
return 'roomName and participantName are required'
|
||||
end
|
||||
|
||||
token = LiveKit::AccessToken.new(api_key: LIVEKIT_API_KEY, api_secret: LIVEKIT_API_SECRET)
|
||||
token.identity = participant_name
|
||||
token.name = participant_name
|
||||
token.add_grant(roomJoin: true, room: room_name)
|
||||
|
||||
return token.to_jwt
|
||||
end
|
||||
3
basic/backend/ruby/env.rb
Normal file
3
basic/backend/ruby/env.rb
Normal file
@ -0,0 +1,3 @@
|
||||
ENV['SERVER_PORT'] = '6080'
|
||||
ENV['LIVEKIT_API_KEY'] = 'devkey'
|
||||
ENV['LIVEKIT_API_SECRET'] = 'secret'
|
||||
Loading…
x
Reference in New Issue
Block a user