{"size": 1347, "ext": "js", "max_stars_repo_path": "examples/gcloud-pubsub/index.js", "max_stars_repo_name": "keithstric/cloud-sockets", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "examples/gcloud-pubsub/index.js", "max_issues_repo_name": "keithstric/cloud-sockets", "max_issues_repo_issues_event_min_datetime": "2020-01-30T21:20:33.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-23T18:19:39.000Z", "max_forks_repo_path": "examples/gcloud-pubsub/index.js", "max_forks_repo_name": "keithstric/cloud-sockets", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": null, "avg_line_length": 39.6176470588, "max_line_length": 97, "alphanum_fraction": 0.7654046028}
'use strict'
const express = require('express');
const http = require('http');
// Define your basic express setup
const app = express();
global.server = http.createServer(app);
// Define your middleware
global.server.use(express.json());
global.server.use(express.urlencoded({extended: true}));

// Setup you pubsub configuration
const pubSubFunctions = require('./cloud-sockets-impl');
/**
 * @property {function} pubsubListener - listens for messages from pubsub system
 * @property {function} pubsubPublisher - publishes message to pubsub system
 * @property {string} pubsubTopicName - The pubsub topic
 * @property {string} pubSubSubscriptionName
 * @property {string[]} pubsubMessageTypes - The types of messages to send through pubsub
 */
const socketOptions = {
	pubsubListener: pubSubFunctions.listenForPubSubMessages,
	pubsubPublisher: pubSubFunctions.publishPubSubMessages,
	pubsubTopicName: 'some-topic-name',
	pubSubSubscriptionName: 'api-service',
	pubsubMessageTypes: ['announceEvent']
};
// Define the cloud-sockets middleware after all your other middleware
const cloudSockets = require('../../index');
global.server.use(cloudSockets.socketServer({server: global.server, port: 8080}, socketOptions));
// Startup the express server
global.server.listen(3000, () =>{
	console.log(`gcloud-pubsub example listening on port 3000`);
});
