mirror of
https://api.glitch.com/git/yaswvc
synced 2026-01-12 06:48:11 +00:00
🚀☂️ Checkpoint
./server.js:3115263/491
This commit is contained in:
parent
461dedf9dd
commit
b255207d21
1 changed files with 7 additions and 13 deletions
20
server.js
20
server.js
|
|
@ -3,16 +3,10 @@
|
||||||
|
|
||||||
// we've started you off with Express (https://expressjs.com/)
|
// 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`.
|
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
|
||||||
|
const { ExpressPeerServer } = require("peer");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
// our default array of dreams
|
|
||||||
const dreams = [
|
|
||||||
"Find and count some sheep",
|
|
||||||
"Climb a really tall mountain",
|
|
||||||
"Wash the dishes"
|
|
||||||
];
|
|
||||||
|
|
||||||
// make all the files in 'public' available
|
// make all the files in 'public' available
|
||||||
// https://expressjs.com/en/starter/static-files.html
|
// https://expressjs.com/en/starter/static-files.html
|
||||||
app.use(express.static("public"));
|
app.use(express.static("public"));
|
||||||
|
|
@ -22,13 +16,13 @@ app.get("/", (request, response) => {
|
||||||
response.sendFile(__dirname + "/views/index.html");
|
response.sendFile(__dirname + "/views/index.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
// send the default array of dreams to the webpage
|
|
||||||
app.get("/dreams", (request, response) => {
|
|
||||||
// express helps us take JS objects and send them as JSON
|
|
||||||
response.json(dreams);
|
|
||||||
});
|
|
||||||
|
|
||||||
// listen for requests :)
|
// listen for requests :)
|
||||||
const listener = app.listen(process.env.PORT, () => {
|
const listener = app.listen(process.env.PORT, () => {
|
||||||
console.log("Your app is listening on port " + listener.address().port);
|
console.log("Your app is listening on port " + listener.address().port);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const peerServer = ExpressPeerServer(listener, {
|
||||||
|
path: '/myapp'
|
||||||
|
});
|
||||||
|
|
||||||
|
app.use('/peerjs', peerServer);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue