This is a simple JavaScript API built with Node.js and MongoDB. It uses Jest for testing and an in-memory MongoDB database for integration tests.
Before you start, make sure you have Node.js and npm installed on your machine.
- Clone this repository:
git clone https://github.com/yourusername/my-js-api.git
- Navigate to the project directory:
cd my-js-api
- Install the dependencies:
npm install
To run the application, use the following command:
npm start
The application will start and listen on port 3000.
This project uses Jest for testing. There are two types of tests: unit tests and integration tests.
To run the unit tests, use the following command:
npm run test:unit
To run the integration tests, use the following command:
npm run test:integration
The application has the following endpoints:
GET /
: Returns a welcome message.POST /data
: Creates a new data entry.GET /data
: Returns all data entries.GET /data/:id
: Returns a specific data entry.PUT /data/:id
: Updates a specific data entry.DELETE /data/:id
: Deletes a specific data entry.
Contributions are welcome. Please make sure to update tests as appropriate.