How to deploy PeerJS?

Programming, error messages and sample code > Node.js
1. create app folder:
 
mkdir myapp
2. cd to folder myapp and run below below command to install PeerJS:
 
npm install express@latest peer@latest
3. upload the folder "myapp" to your site root
 
4. create server.js file with below content and save it to myapp:
 
const express = require('express');
const { ExpressPeerServer } = require('peer');
const app = express();

app.enable('trust proxy');

const PORT = process.env.PORT;
const server = app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

const peerServer = ExpressPeerServer(server, {
  path: '/'
});

app.use('/myapp', peerServer);

module.exports = app;
5. go to hosting control panel to enable NodeJS for this sub folder "myapp"
 
6. update web.config in myapp with below content:
 
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" />
        </handlers>
        <httpPlatform processPath="node" arguments="server.js" startupTimeLimit="20" startupRetryCount="2" stdoutLogEnabled="false" stdoutLogFile="log.txt">
            <environmentVariables>
                <environmentVariable name="PORT" value="%HTTP_PLATFORM_PORT%" />
                <environmentVariable name="NODE_ENV" value="production" />
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>
 
Open your browser with http://xxxx/myapp It should returns JSON with name, description and website fields.