const WebSocket = require('ws');
const gpio = require('rpi-gpio')

const wss = new WebSocket.Server({ port: 8080 });

var power = false;

wss.on('connection', function connection(ws) {
    this.gpio.setMode(this.gpio.MODE_BCM);

    ws.on('message', function incoming(message) {
        if (message == 'powerToggle') {
            this.power = !this.power;
            
            this.gpio.setup(18, this.gpio.DIR_OUT, write);

            function write() {
                this.gpio.write(18, this.power, function (err) {
                    if (err) throw err;
                    console.log('Written to pin 18');
                });
            }
        }

    });

    ws.send('something');
});
@@ -178,29 +178,24 @@
 n(ws) %7B%0A    
-this.
 gpio.setMode
@@ -195,21 +195,16 @@
 setMode(
-this.
 gpio.MOD
@@ -314,21 +314,16 @@
         
-this.
 power = 
@@ -323,21 +323,16 @@
 ower = !
-this.
 power;%0A 
@@ -351,29 +351,24 @@
             
-this.
 gpio.setup(1
@@ -370,21 +370,16 @@
 tup(18, 
-this.
 gpio.DIR
@@ -440,21 +440,16 @@
         
-this.
 gpio.wri
@@ -459,13 +459,8 @@
 18, 
-this.
 powe
@@ -656,8 +656,9 @@
 g');%0A%7D);
+%0A

Fix gpio reference