Timestamp Microservice - Tests

I am trying to complete the Timestamp Microservice challenge but when I submit it, all the tests are checked but there is no complete message

I’m running this project locally, but this is the source code:

var express = require('express');
var app = express();

var cors = require('cors');
app.use(cors({ optionsSuccessStatus: 200 })); 

app.use(express.static('public'));

app.get("/", function(req, res) {
  res.sendFile(__dirname + '/views/index.html');
});

app.get("/api/hello", function(req, res) {
  res.json({ greeting: 'hello API' });
});

function jsonReturnFactory(date) {
  return {
    unix: date.getTime(),
    utc: date.toUTCString()
  }
}

app.get("/api/:date?", function(req, res) {
  let date = !isNaN(req.params.date)
    ? new Date(Number(req.params.date))
    : new Date(req.params.date);

  if (!req.params.date) {
    date = new Date()
  }

  if (isNaN(date.getTime())) {
    res.json({ error: "Invalid Date" });
    return;
  }

  res.json(jsonReturnFactory(date));
});

// listen for requests :)
var listener = app.listen(process.env.PORT, function() {
  console.log('Your app is listening on port ' + listener.address().port);
});

These are the requests:

Welcome there,

I cannot reproduce any issues submitting a passing project. Have you tried a different browser?

1 Like

You should see this message.

Remember to submit a publicly visible app URL.

You have to use a live URL, it can not be submitted running locally for the certificate projects.

Sorry for the delay in responding, but here’s what was going on:

Some tests related to timestamp were not working as in this project
‘Timestamp Microservice’ and ‘Chain Middleware to Create a Time Server’, probably due to UTC problems, the way I solved it was by submitting the urls by cell phone.

In the case of this question I opened, the problem really was that I was submitting a local url (localhost:3000) and not a public one like the replit

it worked when I sent the public url generated by replit and sent by cell phone :partying_face:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.