- Clone the repository.
- Run
npm install
to install dependencies. - Create a
.env
file with the following contents:MONGODB_URI="your mongodb URI" MONGODB_URI_TEST="your test mongodb URI" PORT="port where backend is running"
- Start the server with
npm start
.
Creates a new sleep record.
-
Request:
- Body:
{ "userId": "user1", "hours": 8, "timestamp": "2023-05-18T10:00:00Z" }
- Body:
-
Response:
201 Created
:{ "_id": "60a6c45b21ab9d28e8d8f1f1", "userId": "user1", "hours": 8, "timestamp": "2023-05-18T10:00:00Z" }
Retrieves all sleep records for a user, sorted by timestamp.
- Response:
200 OK
:[ { "_id": "60a6c45b21ab9d28e8d8f1f1", "userId": "user1", "hours": 8, "timestamp": "2023-05-18T10:00:00Z" } ]
Deletes a sleep record by ID.
- Response:
204 No Content
To run the tests, add the following script to your package.json
:
"scripts": {
"test": "mocha"
}