DEV Community

Carlos Estrada
Carlos Estrada

Posted on

Backend Challenge #3

Welcome to the third entry of this series to practice and learn more about backend development.

In the first post we challenge you to create a single endpoint, to perform the core four actions in each application (CREATE, READ, UPDATE, DELETE) with no database connection. However in the second post we stick with a single endpoint but add a connection with a database.

Today we will go a little further and make this a little bit more challenging, so let’s jump to see today’s challenge.

1 Save a message to a plain text file

Project description

Our friend Oscar, ask us if from the next request we can make a little program that does the next

// Oscar example request
// POST http://localhost/messages
{
    "sender": "Caresle",
    "message": "This is my message"
}
Enter fullscreen mode Exit fullscreen mode
  • Save the param message of the JSON body into a plain text file
  • The text file should be named as follow [id]_[sender].txt
  • We need to save the next information in a database
    • Sender of the message
    • Path of the file
  • Display the information as follow, the link to consult the information must require the id of the message that they want to consult. For example: /1 o /2
{
    "sender": "Caresle",
    "message": "This is my message"
}
Enter fullscreen mode Exit fullscreen mode

Notes

The message must not be saved in the database (no matter if it’s small)

You need to create the tables that you need alongside with the structure for creating and retrieving the information

You not need to implement a PUT or DELETE method

Conclusion

This will be the last easy challenge, from here we will start doing a little more complex things, and a bit more difficult.

Top comments (0)