Last Updated: 06 June 2023
- Introduction
- Prerequisites
- Configuring Environment Variables
- Running the CRDC DataHub Backend API
- List of API Endpoints
This API is used to store and query data related to the CRDC DataHub pre-submission form workflow.
- Node.js version 18.16.0 is installed on the runtime environment
- A MongoDB deployment is accessible, running, and a user has been created for this API
Environment variables can either be set in the runtime environment or specified using a .env file.
- VERSION - The API version
- DATE - The date that the API was built
- MONGO_DB_USER - The MongoDB username for this API connection
- MONGO_DB_PASSWORD - The MongoDB password for this API connection
- MONGO_DB_HOST - The MongoDB deployment host address
- MONGO_DB_PORT - The MongoDB connection port
- SESSION_SECRET - A session secret key, this must match in all services that will share a session
- SESSION_TIMEOUT_SECONDS - The number of seconds before a session created or updated by this service will expire
- EMAIL_SMTP_HOST: email server hostname
- EMAIL_SMTP_PORT: email server port number
- EMAIL_USER: email server's username as an additional parameter
- EMAIL_PASSWORD: email server's password as an additional parameter
- EMAIL_URL: the website URL in the email template sent to the user.
- EMAILS_ENABLED: If not set to "true", then the email notifications will be disabled
- SCHEDULE_JOB: Set a time expression to schedule a cron job
- SUBMISSION_DOC_URL: Set the url for submission documentation
- Locate the env.template file and create a copy
- Rename the copy to .env
- Replace the variable values in the ".env" file with the correct values for your target runtime environment
- Save the .env file
- Verify that all the prerequisites listed in this document are satisfied
- Set up the required runtime environment variables
- Install dependencies with npm using the following command:
npm install
- Run the CRDC DataHub Backend API with the following command:
npm start
Note: Steps 1-3 are only required the first time that you are running this program. If there are no changes to the code, then this can be re-run using only step 4.
- /version - Accepts
GET
requests and returns the values of the VERSION and DATE environment variables in JSON format - /ping - Accepts
GET
requests and returns the string "pong", used primarily to check if this API is running - /api/graphql - Accepts
POST
requests containing GraphQL queries and returns the query results