Challenge Overview
Attention! This is a fast challenge! All phases are shorter than usual.
Challenge Objectives
-
Wrap the existing CLI into an API.
Tech Stack
-
Node.js
-
Swagger
-
DynamoDB
-
ElasticSearch
Project Background
In this series of challenges, we will build the version 5 (V5) of the challenge API.
Code Access
Legacy Challenge Migration Script
Repo: https://github.com/topcoder-platform/legacy-challenge-migration-script
Branch: develop
Detailed requirements
As part of this very simple challenge, you need to create a simple API using Express.js that will expose the functionality of the `npm run migrate` command. We should be able to use the migration script both as a CLI app (the current project as is) and as a deployable API.
Requirement 1
The API must have the following endpoints:
POST /v5/challenges/migrations
This should trigger the migration. The same that currently happens right now when we run `npm run migrate`.
You need to ensure we’re only running the migration once at a time.
If the migration is already in progress and the endpoint gets called, throw a 409 Conflict.
GET /v5/challenges/migrations
This endpoint should return the following response object:
{
status: “String”
}
Where the status will be either “Running” or “Idle” based on whether the migration is running or not.
The API must start by running `npm start`.
Requirement 2
Using the https://www.npmjs.com/package/node-schedule module, you need to automatically trigger the migration. Use a configurable variable (default 5 minutes) for the interval.
Update all existing documentation to include information about setting up and running the API both locally and on Docker.
Should you have any questions, feel free to ask on the challenge forum!
What to Submit
Submit a git patch file for the latest commit in the develop branch.
Make sure to mention the exact commit you used so we can apply your patch without issues.