Unable to connect to the sync gateway on backend using Node.js

node.js script fails to do anything aka (Swagger fails to connect?). Note that this is my first time setting up a node.js backend server to connect with my couchbase server database (via the sync gateway). I have followed some online tutorials and read up a bit. Even though my js script appears to run without any errors and it is syntactically correct, it runs through the .js file, prints the following console.logs, and then just stops. I cannot find any process running (ps -e) or anything for it.

“END of file”

What I would have expected is that 1) some background swagger process for monitoring changes from the two channels listed in the code below would be running, and 2) when the sync gateway changes for those channels, my other console.logs would print. Instead, nothing happens.

Can anyone see from my .config and node.js script what is going wrong. Greatly appreciated. Thank you. Two things to note… 1) Yes, my database is named “sync_gateway”, I’ll choose a better name later. 2) I was only able to find the sync-gateway-spec in yaml, so I converted it to .json via an online converter.

Here is my js script that runs on node.js.

const swagger = require('swagger-client');
const spec = require('./sync-gateway-spec.json');

const SYNC_GATEWAY_HOST = 'http://<username>:<password>@localhost:4984';
spec.host = SYNC_GATEWAY_HOST;

let query = {
  db: 'sync_gateway',
  filter: 'sync_gateway/bychannel',
  channels: ['new_msg_notification', 'userchannels'],
  active_only: true,
  include_docs: true,
  feed: 'longpoll',
  timeout: 0

console.log("MADE IT HERE!");

// Setup to use swagger syncronously
let client = new swagger({
  //url: 'http://developer.couchbase.com/mobile/swagger/sync-gateway-public/spec.json',
  spec: spec,
  success: function() {
  function(error) {
    console.log('client error: ', error.statusText);

function monitor(client) 
  console.log("MADE IT TO MONITOR");
  client.database.get_db_changes(query, message);

function message(response) 
  console.log("MADE IT TO MESSAGE");
  query.since = response.obj.last_seq;

console.log("END of file");

And here is my sync_gateway_config.json

   "CORS": {
		"Origin": ["http://localhost:8091"],
		"LoginOrigin": ["http://localhost:8091"],
		"Headers": ["Content-Type","authorization"],
		"MaxAge": 17280000
         "users": {
				"<username>": {"password": "<password>", "admin_roles": ["admin"]}
			"roles": {
				"user": {},
				"admin": {}
         "enable_shared_bucket_access": true,
         "enable_extended_attributes": true,
            function (doc, oldDoc) 
            { ...