The following are the requirements before you begin setting up the project.
- Node version should be v14.15.4.
- Mongodb service must be running.
- Rocket Chat server must be running.
The following steps will help you setup RCforCommunity Project on your machine.
NOTE: RC4GIT refers to RC4Community only. This project was named RC4GIT earlier and then changed to RC4Community. There are places at which RC4GIT
term is used in constant vars.
After you have cloned the repository,
Client-side setup:
- Change your current working directory to
RC4Community/client
. - Do
npm install
to install all the client-side dependencies. - Create a
constants.js
file inclient/src/utils/
. - Copy the contents of
constants-expample.js
(You'll find this file in the same directory ->client/src/utils/
) toconstants.js
. - Setting up the constants:
- rcApiDomain is the domain of your running Rocket Chat server. In my case, it is
http://localhost:3000
. - githubApiDomain is the domain for making GitHub API requests. It is already set, there is no need to make any change.
- rc4gitDomain is the domain of your running rc4community client-side server. Since your client-side code will be served on
http://localhost:3002
, so there is no need to change the value as it is already set, until and unless you have explicitly changed the port in the package.json. - For githubClientID and githubAppSlug, you need to create your own GitHub App for authenticating users and authorizing RCforCommunity to create webhooks on the user's behalf for the real-time activity feature.
You can follow the below mentioned steps to create your own GitHub App.
- Go to GitHub settings > Developer Settings > New GitHub App.
- Set GitHub App Name of your own choice.
- Set Homepage URL as
http://localhost:3002
. (This must be the domain of your RCforCommunity client-side server) - Set Callback URL as
http://localhost:3002/login
. - Deselect "Expire user authorization tokens".
- Select "Request user authorization (OAuth) during installation" to allow people to authorize the app when they install it.
- Deselect "Active" option under the "Webhook" section.
- Set "Access: Read & Write" for "Webhooks" under Repository permissions section.
- Set "Access: Read-only" for "Email Addresses" under User permissions section.
- Select "Any Account" option to allow this integration to be installed by any user or organization.
- Click on Create GitHub App to get the Client ID and GitHub App Slug.(You can find the slug in the Public link of your Github App. For example, if my github app public link is
https://github.com/apps/myrcforcommunityapp
thenmyrcforcommunityapp
is the Github App slug.
- rcApiDomain is the domain of your running Rocket Chat server. In my case, it is
- Run your client-side server using
npm start
Server-side setup:
- Change your current working directory to
RC4Community/server
. - Do
npm install
to install all the server-side dependencies. - Create a
constants.js
file inserver/config/
. - Copy the contents of
constants-expample.js
(You'll find this file in the same directory ->server/config/
) toconstants.js
. - Setting up the constants:
- jwtSecret is the secret which can be anything of your own choice to encode the jwt token.
- algorithm is the algo used to encode. You can use
aes256
- key is the secret key used to encode. It can be of 32 characters. For example, "EXCHANGEPASSWORDEXCHANGEPASSWORD"
- iv is the initialization vector used to encode. It can be of 16 characters. For example, "abcdefghijklmnop"
- githubClientSecret is the secret which you need to generate by clicking on the
generate a new client secret
option in the above created GitHub App settings. - githubClientID is the client ID of your GitHub App which you set in the client constants as well.
- githubAuthURL is the URL to get the access_token from GitHub. It is already set, there is no need to make any change.
- githubAPIDomain is the domain for making GitHub API requests. It is already set, there is no need to make any change.
- rocketChatDomain is the domain of your running Rocket Chat server. In my case, it is
http://localhost:3000
. - mongodbURI is the URI to the RCforCommunity database. It is already set, there is no need to make any change.
- rc4gitApiURL is the publicly hosted API URL of RCforCommunity server. You can achieve this using ngrok. For example, "https://202acb62088a.ngrok.io/api". Here, "https://202acb62088a.ngrok.io" is the domain of your RCforCommunity server.
- For rc_uid and rc_token, you need to manually create a user who only has the access to get the stats of the RC server. After creating the user and assigning the role of reading the stats of RC server to the user, use RC REST API to login that user and get the rc_uid and rc_token.
- Run the server using
npm start
command.
Few Rocket Chat configurations need to be done before testing out the app
- You need to set API URL endpoint and iframe URL endpoint in the administration > accounts > iframe section to automatically authenticate a user on Rocket.Chat server when that user logs in to your web app.
- Toggle to turn on the enabled button.
- Set Iframe URL to
http://localhost:3002/redirect/login
- Set API URL to
http://localhost:8090/api/sso
- Set the API Method to
POST
- Allow anonymous Read in administration > accounts.
- Disable Restrict access inside any Iframe in administration > general.
- Enable Send and Receive in administration > general > Iframe Integration.
- Enable Cors in administration > general > REST API and set it to *