Skip to content

Commit

Permalink
refactor: migrate mediasoup WebRTC server from JavaScript to TypeScri…
Browse files Browse the repository at this point in the history
…pt (#29)
  • Loading branch information
gabrielmatau79 authored Jan 15, 2025
1 parent 9f0add4 commit 11a455f
Show file tree
Hide file tree
Showing 50 changed files with 10,436 additions and 15,675 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Continuous Integration

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled]
push:
branches: [main]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout webrtc-server
uses: actions/checkout@v4

- name: Setup node v22
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install dependencies
run: |
yarn install
- name: Check Format
run: |
yarn format
- name: Check Types
run: |
yarn check-types
- name: Unit tests
run: |
yarn test
- name: E2E tests
run: |
yarn test:e2e
38 changes: 36 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
node_modules
certs
# compiled output
/dist
/node_modules
/certs

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"semi": false,
"singleQuote": true
}
52 changes: 32 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
# Stage 0, build the Webrtc Server
FROM node:18-slim

# Install DEB dependencies and others.
RUN \
set -x \
&& apt-get update \
&& apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*

WORKDIR /server

COPY package.json .
COPY package-lock.json .
RUN npm install
COPY server.js .
COPY config.js .
COPY lib lib
ADD start.sh .

CMD ["sh", "/server/start.sh"]
# Stage 0, build the Webrtc Server
FROM node:22-slim as builder

# Install DEB dependencies and others.
RUN \
set -x \
&& apt-get update \
&& apt-get install -y python3 python3-pip && rm -rf /var/lib/apt/lists/*

# MPR Setup
WORKDIR /app

# Copy package.json and yarn.lock first to leverage Docker layer caching
COPY package.json package.json
COPY yarn.lock yarn.lock

# Run yarn install after copying only dependency files
RUN yarn install

# Copy other dependencies and configuration files
COPY ./src ./src
COPY tsconfig.json tsconfig.json
COPY tsconfig.build.json tsconfig.build.json

# Build the project
RUN yarn build

# Define a volume for external configuration files
VOLUME /app/dist/config

# Command to start the application when the container runs
CMD ["yarn", "start"]

201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

Loading

0 comments on commit 11a455f

Please sign in to comment.