This microservice provides access to and interaction with Topcoder Academy learning path certification and course content.
- TBD
- Production API
- NodeJS (v16)
- DynamoDB
- Docker
- Docker Compose
Configuration for the application is at config/default.js.
The following parameters can be set in config files or in env variables:
- READONLY: sets the API in read-only mode. POST/PUT/PATCH/DELETE operations will return 403 Forbidden
- LOG_LEVEL: the log level, default is 'debug'
- PORT: the server port, default is 3000
- AUTH_SECRET: The authorization secret used during token verification.
- VALID_ISSUERS: The valid issuer of tokens.
- AUTH0_URL: AUTH0 URL, used to get M2M token
- AUTH0_PROXY_SERVER_URL: AUTH0 proxy server URL, used to get M2M token
- AUTH0_AUDIENCE: AUTH0 audience, used to get M2M token
- TOKEN_CACHE_TIME: AUTH0 token cache time, used to get M2M token
- AUTH0_CLIENT_ID: AUTH0 client id, used to get M2M token
- AUTH0_CLIENT_SECRET: AUTH0 client secret, used to get M2M token
- AMAZON.AWS_ACCESS_KEY_ID: The Amazon certificate key to use when connecting. Use local dynamodb you can set fake value
- AMAZON.AWS_SECRET_ACCESS_KEY: The Amazon certificate access key to use when connecting. Use local dynamodb you can set fake value
- AMAZON.AWS_REGION: The Amazon certificate region to use when connecting. Use local dynamodb you can set fake value
- AMAZON.IS_LOCAL_DB: Use Amazon DynamoDB Local or server
- AMAZON.DYNAMODB_URL: The local url if using Amazon DynamoDB Local
- HEALTH_CHECK_TIMEOUT: health check timeout in milliseconds
- SCOPES: the configurable M2M token scopes, refer
config/default.jsfor more details - M2M_AUDIT_HANDLE: the audit name used when perform create/update operation using M2M token
You can find sample .env files inside the /docs directory.
- Drop/delete DynamoDB tables:
npm run drop-tables - Create DynamoDB tables:
npm run create-tables - Seed/Insert data into DynamoDB tables:
npm run seed-tables - Initialize/Clear database in default environment:
npm run init-db - View table data in default environment:
npm run view-data <ModelName>, ModelName can beCertification,Course, orLearningResourceProvider - Start all the depending services for local deployment:
npm run services:up - Stop all the depending services for local deployment:
npm run services:down - Check the logs of all the depending services for local deployment:
npm run services:logs - Initialize the local environments:
npm run local:init - Reset the local environments:
npm run local:reset
- The seed data are located in
src/scripts/seed
-
Make sure to use Node v16+ -- check with command
node -v. We recommend using NVM to quickly switch to the right version specified in the included.nvmrcfile:nvm use
-
📦 Install npm dependencies
npm install
-
⚙ Local config
In thelearning-paths-apiroot directory create an.envfile with the following environment variables. Values for Auth0 config should be shared with you on the forum.# Auth0 config AUTH0_URL= AUTH0_PROXY_SERVER_URL= AUTH0_AUDIENCE= AUTH0_CLIENT_ID= AUTH0_CLIENT_SECRET= # Locally deployed services (via docker-compose) IS_LOCAL_DB=true DYNAMODB_URL=http://localhost:8000
- Values from this file would be automatically used by many
npmcommands. ⚠️ Never commit this file or its copy to the repository!
- Values from this file would be automatically used by many
-
🚢 Use docker-compose to start the services required to run the API locally (DynamoDB).
npm run services:up
-
♻ Create empty DynamoDB tables.
npm run create-tables # Use `npm run drop-tables` to drop tables. -
♻ Initialize the local database.
npm run local:init
This command will do 2 things:
- Initialize the database by deleting all the existing records.
- Seed the database with data from the JSON seed files
-
🚀 Start the learning paths API.
npm start
The Topcoder Learning Paths API will be served on
http://localhost:3000
To start with ExpressJS debug logging turned on, runnpm start:debug.
- TBD
Test configuration is at config/test.js. You don't need to change them.
The following test parameters can be set in config file or in env variables:
- ADMIN_TOKEN: admin token
- COPILOT_TOKEN: copilot token
- USER_TOKEN: user token
- EXPIRED_TOKEN: expired token
- INVALID_TOKEN: invalid token
- M2M_FULL_ACCESS_TOKEN: M2M full access token
- M2M_READ_ACCESS_TOKEN: M2M read access token
- M2M_UPDATE_ACCESS_TOKEN: M2M update (including 'delete') access token
- Start Local services in docker.
- Create DynamoDB tables.
- Various config parameters should be properly set.
Seeding db data is not needed.
To run unit tests alone
npm run testTo run unit tests with coverage report
npm run test:covTo run integration tests alone
npm run e2eTo run integration tests with coverage report
npm run e2e:covRefer to the verification document Verification.md
Several utilities exist to support this API. Read more about them on their READMEs.