Developer's Doc: How to setup and use Discussions-middleware
This document will help the developer ( or third-party vendors ) to set up and use Discussion-middleware.
Background:
This discussions-middleware works like an API proxy. All the discussions-forum related APIs will go via this proxy.
Git Repository:
https://github.com/Sunbird-Ed/discussions-middleware
Prerequisite:
Local nodebb should be installed ( or for a particular environment )
Note: Refer to this link for easy installation: https://docs.nodebb.org/installing/os/all the necessary plugins to be installed and activated for the nodebb to access certain APIs,
Steps to set up DMW locally :
Step-1 : Git clone:
> git clone git@github.com:Sunbird-Ed/discussions-middleware.git
> nvm use 12 (min node version 12)
> cd discussion-middleware
> yarn
Step-2: Add the following configuration in environmentVariablesHelper.js
'use strict'
const env = process.env
const __envIn = 'dev';
let localEnv = {
NODEBB_SERVICE_URL: 'http://localhost:4567',
Authorization: <master token>,
nodebb_api_slug: env.nodebb_api_slug || '/api'
}
module.exports = localEnv;
Replace the ‘<mater token>’ with your local NodeBB master token.
Q1. How to generate/get master token?
Ans. Local NodeBB should be running fine. Install the Write-API NodeBB plugin.
After successfull installation, generate the master token by refering below link.
Discussion Forum: Deployment | Step 5: Creating Nodebb Token
Start the application
> npm run start
middleware will be running on port 3002
URL: http”//localhost:3002
DMW setup using script
if you are doing the discussion middleware local setup for the first time, you can use the below script file.
Create
discussion_dmw.sh
file with below script and run the script with the commandbash discussion_dmw.sh
.
here you have give branch name to clone the repo. You see all available branch names here DMW-Branchs. Then follow this steps Step-2