This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backend/.env.example | |
NODE_ENV=development | |
PORT=8080 | |
STREAM_API_KEY=your stream API key goes here | |
STREAM_API_SECRET=your stream API secret goes here | |
HUBSPOT_API_KEY=your Hubspot API key goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//frontend/src/App.js:7 | |
function App() { | |
const [email, setEmail] = useState(''); | |
const [firstName, setFirstName] = useState(''); | |
const [lastName, setLastName] = useState(''); | |
//... | |
return ( | |
<div className="App container"> | |
<form className="card" onSubmit={register}> | |
<label>First Name</label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//frontend/src/App.js:15 | |
const register = async (e) => { | |
try { | |
e.preventDefault(); | |
var response = await fetch('http://localhost:8080/registrations', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backend/routes/index.js:1 | |
const express = require('express'); | |
const router = express.Router(); | |
const StreamChat = require('stream-chat'); | |
const Hubspot = require('hubspot'); | |
require('dotenv').config(); | |
const apiKey = process.env.STREAM_API_KEY; | |
const apiSecret = process.env.STREAM_API_SECRET; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backend/routes/index.js:46 | |
router.post('/registrations', async (req, res, next) => { | |
try { | |
await createHubspotContact(firstName, lastName) | |
const client = new StreamChat.StreamChat(apiKey, apiSecret); | |
[customer, supporter] = createUsers(firstName, lastName) | |
await client.upsertUsers([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backend/routes/index.js:10 | |
async function createHubspotContact(firstName, lastName) { | |
const hubspot = new Hubspot({ | |
apiKey: process.env.HUBSPOT_API_KEY, | |
checkLimit: false | |
}) | |
const contactObj = { | |
properties: [ | |
{ property: 'firstname', value: firstName }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createUsers(firstName, lastName) { | |
const customer = { | |
id: `${firstName}-${lastName}`.toLowerCase(), | |
name: firstName, | |
role: 'user', | |
}; | |
const supporter = { | |
id: 'adminId', | |
name: 'unique-admin-name', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//frontend/App.js:7 | |
function App() { | |
//... | |
const [chatClient, setChatClient] = useState(null); | |
const [channel, setChannel] = useState(null); | |
const register = async (e) => { | |
try { | |
e.preventDefault(); | |
var response = await fetch('http://localhost:8080/registrations', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//frontend/App.js | |
import { Chat, Channel, ChannelHeader, MessageInput, MessageList, Thread, Window, } from 'stream-chat-react'; | |
import { StreamChat } from 'stream-chat'; | |
import 'stream-chat-react/dist/css/index.css' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//backend/.env | |
NODE_ENV=development | |
PORT=8080 | |
STREAM_API_KEY= your Stream API key here | |
STREAM_API_SECRET= your Stream API secret here | |
HUBSPOT_API_KEY=your HubSpot API key here |
OlderNewer