mirror of
https://api.glitch.com/git/yaswvc
synced 2026-01-11 23:18:11 +00:00
./views/index.ejs:5975361/314 ./server.js:5975361/214 ./package.json:5975361/798 ./public/main.js:5975361/45
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
// server.js
|
|
// where your node app starts
|
|
require('dotenv').config();
|
|
|
|
// we've started you off with Express (https://expressjs.com/)
|
|
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
|
|
const express = require("express");
|
|
const { ExpressPeerServer } = require("peer");
|
|
const app = express();
|
|
|
|
// make all the files in 'public' available
|
|
// https://expressjs.com/en/starter/static-files.html
|
|
app.use(express.static("public"));
|
|
app.set('view engine', 'ejs');
|
|
|
|
// https://expressjs.com/en/starter/basic-routing.html
|
|
app.get("/", (request, response) => {
|
|
// response.sendFile(__dirname + "/public/index.html");
|
|
response.render('index', {
|
|
TURN_USER: process.env.TURN_USER,
|
|
TURN_PW: process.env.TURN_PW,
|
|
TURN_URL: process.env.TURN_URL
|
|
});
|
|
});
|
|
|
|
// listen for requests :)
|
|
const listener = app.listen(process.env.PORT, () => {
|
|
console.log("Your app is listening on port " + listener.address().port);
|
|
});
|
|
|
|
// peerjs server
|
|
const peerServer = ExpressPeerServer(listener, {
|
|
debug: true,
|
|
path: '/myapp'
|
|
});
|
|
|
|
app.use('/peerjs', peerServer);
|