astrotars / stream-chat-boilerplate-api

Stream Chat Boilerplate API for Token Generation

Home Page:https://getstream.io/chat/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stream Chat Boilerplate API

This API is not meant for production as there is no auth in place. Please use carefully in testing and development environments only!

Getting Started

To spin this up, clone it and run yarn install within the root directory, then run yarn start. Create a .env file within the main directory with the following environment variables found on https://getstream.io/dashboard:

NODE_ENV=production
PORT=8080

STREAM_API_KEY=<YOUR_API_KEY>
STREAM_API_SECRET=<YOUR_API_SECRET>

Note: You can reference .env.example.

To spin up the API, click the Deploy with Heroku button below!

Alternatively, you can spin up the API using Heroku. This Heroku deploy button will autodeploy the API as well as provision a chat trial with Stream. The environment variables will be automatically added to the project. This is by far the easiest way to get up and running.

Deploy

Project Structure

Full Breakdown

.
├── LICENSE
├── Procfile
├── README.md
├── app.json
├── env.example
├── package.json
├── src
│   ├── controllers
│   │   └── v1
│   │       └── token
│   │           ├── index.js
│   │           └── token.action.js
│   ├── index.js
│   ├── routes
│   │   └── token.js
│   └── utils
│       └── controllers.js
└── yarn.lock

Controllers:

.
└── v1
    └── token
        ├── index.js
        └── token.action.js

Token:

.
└── token.js

The file token.action.js is what holds all of the magic. It generates the token, adds the user, and responds with a payload. If you need to modify what you store in the user profile, this is the file that you will want to edit.

Retrieving a Token

To retrieve a token, hit the /v1/token endpoint with an HTTP POST with the following JSON payload:

{
    "email": "nparsons08@gmail.com",
    "name": "Nick Parsons"
}

Note: Don't forget to set the Content-Type header to application/json.

About

Stream Chat Boilerplate API for Token Generation

https://getstream.io/chat/

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 100.0%