[mirotalksfu] - add swagger
هذا الالتزام موجود في:
@@ -95,8 +95,13 @@ $ docker-compose down
|
||||
```bash
|
||||
# The response will give you a entrypoint / Room URL for your meeting.
|
||||
$ curl -X POST "http://localhost:3010/api/v1/meeting" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json"
|
||||
$ curl -X POST "https://sfu.mirotalk.org/api/v1/meeting" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json"
|
||||
```
|
||||
|
||||
## API Documentation
|
||||
|
||||
The API documentation uses [swagger](https://swagger.io/) at https://localhost:3010/api/v1/docs or check it on live [here](https://sfu.mirotalk.org/api/v1/docs).
|
||||
|
||||
## Notes
|
||||
|
||||
- Run the project on a `Linux or Mac` system as the `mediasoup` installation could have issues on `Windows`.
|
||||
|
||||
47
app/api/swagger.yaml
Normal file
47
app/api/swagger.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
swagger: '2.0'
|
||||
|
||||
info:
|
||||
title: MiroTalk SFU API
|
||||
description: API description for external applications that integrates with MiroTalk SFU.
|
||||
version: 1.0.0
|
||||
|
||||
basePath: /api/v1
|
||||
|
||||
schemes:
|
||||
- https
|
||||
- http
|
||||
|
||||
paths:
|
||||
/meeting:
|
||||
post:
|
||||
tags:
|
||||
- 'meeting'
|
||||
summary: 'Create meeting'
|
||||
description: 'Create meeting'
|
||||
consumes:
|
||||
- 'application/json'
|
||||
produces:
|
||||
- 'application/json'
|
||||
security:
|
||||
- secretApiKey: []
|
||||
responses:
|
||||
'200':
|
||||
description: 'Meeting created'
|
||||
schema:
|
||||
$ref: '#/definitions/MeetingResponse'
|
||||
'403':
|
||||
description: 'Unauthorized!'
|
||||
|
||||
securityDefinitions:
|
||||
secretApiKey:
|
||||
type: 'apiKey'
|
||||
name: 'authorization'
|
||||
in: 'header'
|
||||
description: 'Format like this: authorization: {API_KEY_SECRET}'
|
||||
|
||||
definitions:
|
||||
MeetingResponse:
|
||||
type: 'object'
|
||||
properties:
|
||||
meeting:
|
||||
type: 'string'
|
||||
@@ -14,6 +14,9 @@ const Peer = require('./Peer');
|
||||
const ServerApi = require('./ServerApi');
|
||||
const Logger = require('./Logger');
|
||||
const log = new Logger('Server');
|
||||
const yamlJS = require('yamljs');
|
||||
const swaggerUi = require('swagger-ui-express');
|
||||
const swaggerDocument = yamlJS.load(path.join(__dirname + '/../api/swagger.yaml'));
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -26,6 +29,9 @@ const httpsServer = https.createServer(options, app);
|
||||
const io = require('socket.io')(httpsServer);
|
||||
const host = 'https://' + 'localhost' + ':' + config.listenPort; // config.listenIp
|
||||
|
||||
const apiBasePath = '/api/v1'; // api endpoint path
|
||||
const api_docs = host + apiBasePath + '/docs'; // api docs
|
||||
|
||||
// all mediasoup workers
|
||||
let workers = [];
|
||||
let nextMediasoupWorkerIdx = 0;
|
||||
@@ -97,6 +103,9 @@ app.get('/join/*', (req, res) => {
|
||||
// Api parse body data as json
|
||||
app.use(express.json());
|
||||
|
||||
// api docs
|
||||
app.use(apiBasePath + '/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
|
||||
|
||||
// request meeting room endpoint
|
||||
app.post(['/api/v1/meeting'], (req, res) => {
|
||||
// check if user was authorized for the api call
|
||||
@@ -138,6 +147,7 @@ async function ngrokStart() {
|
||||
log.debug('Listening on', {
|
||||
server: host,
|
||||
tunnel: tunnel,
|
||||
api_docs: api_docs,
|
||||
});
|
||||
} catch (err) {
|
||||
log.error('Ngrok Start error: ', err);
|
||||
@@ -170,6 +180,7 @@ httpsServer.listen(config.listenPort, () => {
|
||||
}
|
||||
log.debug('Listening on', {
|
||||
server: host,
|
||||
api_docs: api_docs,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
"mediasoup-client": "^3.6.42",
|
||||
"ngrok": "^4.2.2",
|
||||
"socket.io": "^4.2.0",
|
||||
"uuid": "8.3.2"
|
||||
"swagger-ui-express": "^4.1.6",
|
||||
"uuid": "8.3.2",
|
||||
"yamljs": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-fetch": "^3.0.0",
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم