Open JimOfLeisure opened 2 years ago
Since our challenges are currently a directory of directories, I guess the challenge ID will just be the challenge folder name for now, and for the moment we can assume the test will be named test.js
. Eventually what's in the folders will probably be MongoDB documents.
I refactored the repo layout. The server portion is now in the server folder, and the frontend is in server/frontend . In dev mode (if no process.env.PORT
is present), the frontend folder will be served with express.static(), but if process.env.PORT
is present, it won't as I intend to host the static frontend files separately in S3. I may end up changing my mind on that...we'll see.
But the good news is that npm run dev
and npm start
scripts are enabled with nodemon installed as a dev dependency for npm run dev
.
Using a node express server, create an API. I would suggest
/api/submission
for a route.The API should accept a JSON body with submission code, a challenge ID, and a user ID. (Data is not yet defined...this is early experimentation.) It should use the challenge ID to find the test.js and concatenate it to the submission and then either console.log it out for now or maybe pass it back as a response.
In the future, the concatenated submission/test will be sent in a message queue for task runners to run, and the API will wait for a return message. Come to think of it, we need a job ID generated for this tracking. This particular flow may evolve over time to return a 'job submitted' result and then the client can monitor a different route and be notified when the job returns...we'll have to see, but the basic order of operations will remain the same.
Create the API so that it would run on Heroku using the package.json
start
script, and if necessary abuild
script, and definitelyprocess.env.PORT
for port selection.