Skip to content

Commit f7d45fd

Browse files
author
Mofizur Rahman
authored
Merge pull request #1 from jeffswartz/lint-v1.0.0
And lint script and lint code to ES6 (airbnb-base)
2 parents 5c6da72 + bfb2415 commit f7d45fd

File tree

7 files changed

+1380
-2643
lines changed

7 files changed

+1380
-2643
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/public/js/opentok-layout.js

.eslintrc.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "airbnb-base",
3+
"globals": {
4+
"alert": "readonly",
5+
"document": "readonly",
6+
"fetch": "readonly",
7+
"initLayoutContainer": "readonly",
8+
"localStorage": "readonly",
9+
"OT": "readonly",
10+
"window": "readonly"
11+
},
12+
"rules": {
13+
"no-alert": "off",
14+
"no-console": "off"
15+
}
16+
}

index.js

+33-34
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,93 @@ require('dotenv').config();
22
const express = require('express');
33
const path = require('path');
44
const OpenTok = require('opentok');
5+
56
const port = process.env.port || 3000;
67

78
const app = express();
89
const opentok = new OpenTok(process.env.API_KEY, process.env.API_SECRET);
910

1011
app.use(express.urlencoded({ extended: true }));
1112
app.use(express.json());
12-
app.use(express.static(__dirname + '/public'));
13+
app.use(express.static(`${__dirname}/public`));
1314

1415
app.get('/', (req, res) => {
15-
res.sendFile(path.join(__dirname + '/public/index.html'));
16-
})
16+
res.sendFile(path.join(`${__dirname}/public/index.html`));
17+
});
1718

1819
app.get('/session/:sessionId', (req, res) => {
19-
const sessionId = req.params.sessionId;
20-
res.sendFile(path.join(__dirname + '/public/call.html'));
21-
})
20+
res.sendFile(path.join(`${__dirname}/public/call.html`));
21+
});
2222

2323
app.post('/api/create', (req, res) => {
2424
opentok.createSession(
2525
{
26-
mediaMode: "routed"
26+
mediaMode: 'routed',
2727
},
28-
function (err, session) {
28+
(err, session) => {
2929
if (err) {
30-
res.status(500).send({error: 'createSession error'});
30+
res.status(500).send({ error: 'createSession error' });
3131
return;
3232
}
33-
token = opentok.generateToken(session.sessionId);
3433
res.setHeader('Content-Type', 'application/json');
3534
res.send({
3635
sessionId: session.sessionId,
3736
});
38-
}
37+
},
3938
);
4039
});
4140

4241
app.post('/api/credentials', (req, res) => {
43-
const sessionId = req.body.sessionId;
42+
const { sessionId } = req.body;
4443
const token = opentok.generateToken(sessionId);
4544
res.send({
46-
sessionId: sessionId,
45+
sessionId,
4746
apiKey: process.env.API_KEY,
48-
token: token
47+
token,
4948
});
50-
})
49+
});
5150

5251
app.post('/api/archive/start/:sessionId', (req, res) => {
53-
const sessionId = req.params.sessionId;
52+
const { sessionId } = req.params;
5453
const time = new Date().toLocaleString();
55-
let archiveOptions = {
54+
const archiveOptions = {
5655
name: `archive-${time}`,
5756
outputMode: 'composed',
5857
layout: {
59-
type: "bestFit",
60-
screenshareType: "pip"
61-
}
62-
}
58+
type: 'bestFit',
59+
screenshareType: 'pip',
60+
},
61+
};
6362

64-
opentok.startArchive(sessionId, archiveOptions, function(err, archive) {
65-
if(err) {
63+
opentok.startArchive(sessionId, archiveOptions, (err, archive) => {
64+
if (err) {
6665
return res.status(500).send(err);
6766
}
6867
return res.json(archive);
6968
});
70-
})
69+
});
7170

7271
app.post('/api/archive/:archiveId/stop', (req, res) => {
73-
const archiveId = req.params.archiveId;
74-
opentok.stopArchive(archiveId, function(err, archive) {
75-
if(err) {
72+
const { archiveId } = req.params;
73+
opentok.stopArchive(archiveId, (err, archive) => {
74+
if (err) {
7675
return res.status(500).send({
77-
archiveId: archiveId,
78-
error: err
76+
archiveId,
77+
error: err,
7978
});
8079
}
8180
return res.json(archive);
8281
});
83-
})
82+
});
8483

8584
app.get('/api/archive/list', (req, res) => {
86-
opentok.listArchives({count: 10}, function(err, archive, count) {
87-
if(err) {
85+
opentok.listArchives({ count: 10 }, (err, archive) => {
86+
if (err) {
8887
return res.status(500).send(err);
8988
}
9089
return res.json(archive);
91-
})
92-
})
90+
});
91+
});
9392

9493
app.listen(port, () => {
9594
console.log(`App running on port: ${port}`);

0 commit comments

Comments
 (0)