nj-campaign-server v1.1.0
Campaign Server
express stack based campaign server for viber integration
Table Of Contents
Notes
The API documentation is also available in the git hub repo
Setup and installation
Pre-requirements
gitand at least read permission for the repositorynodeinstall v6.8.0 or laternpmv3.10.8 or later
Installation
$ git clone git@github.com:gitnooji/quiz-express.git
$ npm install
$ cp env.local .env - env file config for localhost
or
$ cp env.ec2 .env - env file config for ec2 instance.
Post installation tests
The command below is a simple test to make sure the test framework is operational
$ npm run test-mocha
Now run basic unit tests to make sure the product is installed properly
$ npm test
The server needs to be running for the API tests to work.
$ npm start
open a separate terminal and run the api tests as shown below to make sure the server is correctly configured and receiving messages.
$ npm run api-test-local
congratulations you now have a working campaign-server
Documentation
building the documentation
The following scripts will build the documentation
$ npm run docs(clear and re-create all documentation)$ npm run api-docs(create only the api documentation)$ npm run coverage-docs(create only the coverage reports)
To view the created documentation run the documentation server as shown below and navigate to the displayed url.
$ npm run doc-server
Starting up http-server, serving docs
Available on:
http://127.0.0.1:8082
http://10.1.10.111:8082
Hit CTRL-C to stop the serverScripts
The following scripts are defined in package.json
start up
$ npm startstart quiz-express$ npm run start-devstart inside nodejs-dashboard$ npm run start-debugstart quiz-express in debug mode with attached devtools. open chrome at the URI provided and enjoy chrome tools debugging
testing
$ npm testrun basic test suite$ npm run test-mochasmoke test to make sure mocha is configured$ npm run test-autowatch for file changes and rerun tests$ npm run test-babelrun test suite with.babelrcsettings
code coverage
$ npm run coveragerun the code coverage tool. coverage reports are written to the docs folder.
documentation
$ npm run docsbuild all the docs.$ npm run doc-serverstart the local documentation server.
clean up
$ npm cleanclean everything and reinstall npm modules$ npm run clean-testclean test artifacts$ npm run clean-docsclean documentation artifacts$ npm run clean-npmremove and re-install npm modules
Environment variables
Environment control vars are defined in the .env file in the root folder of the project. env.local and env.ec2 can be editted and copied to .env
| Variable | Usage |
|---|---|
API_PORT | The port to run on (default: 8000). |
API_URL | The url of the endpoint |
API_COMPRESSION | Enables gzip compression when set to "1". |
API_GRACEFUL_SHUTDOWN | Wait for connections to close before stopping server when set to "1". |
API_SESSION_MAXAGE | The time in ms until the session ID cookie should expire (default: 2 hours).This is just a tracking cookie, no session storage is used here. |
API_REV_PROXY | The server is behind a reverse proxy when set to "1". |
API_SSL | Use a HTTPS server when set to "1". Enforces HTTPS by redirecting HTTP users when used with a reverse HTTP/HTTPS proxy. |
API_SSL_KEY | Path to the SSL key file. |
API_SSL_CERT | Path to the SSL cert file. |
VIBER_URI | Nooji |
VIBER_DEEPLINK | viber://pa?chatURI=Nooji |
VIBER_AUTH_TOKEN | SECRET |
VIBER_WEBHOOK | / |
VIBER_API_URL | https://chatapi.viber.com/pa |
VIBER_SENDER_AVATAR | url |
Miscellanea
Dependencies
The production module dependencies can be viewed with the following command
$ npm ls -l -depth=0 --prod
sample output.
quiz-express@1.1.0
│ /home/davey/Code/nooji.io/quiz-express
│ express stack based quiz engine for viber integration
│ git+https://github.com/gitnooji/quiz-express.git
│ https://github.com/gitnooji/quiz-express#readme
├── body-parser@1.15.2
│ Node.js body parsing middleware
│ git+https://github.com/expressjs/body-parser.git
│ https://github.com/expressjs/body-parser#readme
├── chalk@1.1.3
│ Terminal string styling done right. Much color.
│ git+https://github.com/chalk/chalk.git
│ https://github.com/chalk/chalk#readme
├── dotenv@2.0.0
│ Loads environment variables from .env file
│ git://github.com/motdotla/dotenv.git
│ https://github.com/motdotla/dotenv#readme
├── express-api-server@0.0.8
│ An opinionated Express Web API server library
│ git+https://github.com/cgmartin/express-api-server.git
│ https://github.com/cgmartin/express-api-server
└── node-fetch@1.6.3
A light-weight module that brings window.fetch to node.js and io.js
git+https://github.com/bitinn/node-fetch.git
https://github.com/bitinn/node-fetchDevelopment dependencies
You can view the development dependencies of the project with the following command
$ npm ls -depth=0 --dev
References
9 years ago