Cboard is an augmentative and alternative communication (AAC) web application, allowing users with speech and language impairments (autism, cerebral palsy) to communicate by symbols and text-to-speech. This repo supports the CBoard front-end, providing backend functionality and persistence.
Learn more about the Cboard project.
Before installing and running the Cboard API, be sure you have locally installed the following tools:
Use the following commands to check that you have them successfully installed, and/or to double-check your versions:
node -v
mongo --version
Clone the repository and install npm dependencies:
$ git clone https://github.com/cboard-org/cboard-api.git
$ cd cboard-api
$ npm install
Start MongoDB. (See MongoDB docs, if needed).
$ mongod
The Cboard API is a cloud service, and it needs access to several cloud services as well, like user authentication, email sending, etc. This is all configured using environment variables on the platform the API is running. Following are the mandatory variables to be defined:
- AZURE_STORAGE_CONNECTION_STRING
- FACEBOOK_APP_ID
- FACEBOOK_APP_SECRET
- FACEBOOK_CALLBACK_URL
- GCLOUD_PROJECT
- GOOGLE_APP_ID
- GOOGLE_APP_SECRET
- GOOGLE_APPLICATION_CREDENTIALS
- GOOGLE_CALLBACK_URL
- JWT_SECRET
- MONGO_URL
- REACT_APP_DEV_API_URL
- SENDGRID_API_KEY
In a separate terminal tab/window, run the project server.
$ npm run dev
For automatically restarting the server when file changes in the directory are detected
or
$ npm run start
Both of them start a server process listening on port 10010. You will now be able to make calls to the API.
(If you are having trouble, make sure you have successfully installed the pre-requisites -- see "Pre-requisites" section above.)
Swagger provides an interactive, browser-based editor. To visualize available API endpoints:
$ localhost:10010/docs/
That show API swagger editor (as shown below):
When a new user is created using the API, some verification emails are generated. To use a specific SMPT server, locally edit the following file to use values for an SMTP server you own: config/env/development.js And look for following config block:
emailTransport: {
from: '[email protected]',
host: 'smtp.sendgrid.net',
port: 465,
secure: true,
service: 'Sendgrid',
auth: {
user: 'apikey',
pass: process.env.SENDGRID_API_KEY
}
}
There are two types of tests in the repository, that can help you with the development and the debugging of the api service:
- Postman tests
- Mocha tests
Postman is a scalable API testing tool, and we mainly use it for debugging and testing during the development process. These tests are loocated under the following folder:
cboard-api/test/postman
There, you can find a postman collection file. This file can be imported as a new collection into Postman and you will see a list of requests and tests that you can use to exercise the cboard API. Note: you will need a deployed and well configured cboard-api instance running on your server to execute the tests against to.
Mocha is a javascript framework for Node.js which allows Asynchronous testing. We have developed a few Mocha test suites that are running everytime a new Pull Request is created / updated. The goal of these tests is to verify that all of the api calls are functional and you are not introducing regression bugs into the code base. The command to run the Mocha tests is simply:
npm test