Follow the steps below to set up and run the Car Proximity App API on your local machine.
Ensure you have the following installed on your computer:
-
Clone the Repository
Clone the repository to your local machine using the following command:
git clone <repository-url>
-
Navigate to the Project Directory
Change your directory to the project folder:
cd Car-Proximity-App-API
-
Install Dependencies
Install the required dependencies by running:
npm install
-
Create a
.env
FileCreate a
.env
file in the root directory of the project and add the following configuration:PORT=3000 MONGO_URI=mongodb://localhost:27017/proximityCarDB JWT_SECRET=jwt_secret_key PROXIMITY_THRESHOLD=500 SEARCH_RADIUS=1500 GOOGLE_MAPS_API_KEY=<API-KEY>
-
Set Up the Database
To set up the database and seed it with test data, run the following command:
npm run setup
This command will execute the
setup.ts
script, which connects to the database and runs theseed.ts
file to populate it with initial data. -
Run the Server
After the setup is complete, you can run the server using:
npm run dev
Your server should now be running on http://localhost:3000.
You can access the API and verify that the server is running by navigating to the following URL in your web browser:
- If you encounter any issues during the setup, ensure that MongoDB is running and accessible at the specified URI.
- Make sure to check your console for any error messages, which can provide guidance for troubleshooting.