This repository contains the backend code for a location tracking system built using Node.js.
- Node.js (v12.x or higher)
- npm (v6.x or higher)
- MongoDB
- Clone the repository:
git clone https://github.com/datmaiq/location-tracking-be.git cd location-tracking-be
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and add the following environment variables:# Add your environment variables here JWT_SECRET_KEY="<your secret here>" MONGO_URL="mongodb+srv://<user>:<password>@<url>/<db-name>"
- Run the application:
npm run server
The API server will start on http://localhost:8000
.
- URL:
/api/auth/sign-up
- Method:
POST
- Body Parameters:
username
:String
password
:String
- URL:
/api/auth/sign-in
- Method:
POST
- Body Parameters:
email
:String
password
:String
- URL:
/api/auth/authenticate
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/users/profile
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/locations
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
latitude
:Number
longitude
:Number
timestamp
:String
- URL:
/api/locations
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/locations/:id
- Method:
DELETE
- Headers:
Authorization
:Bearer token
- URL:
/api/friends
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
userId
:String
friendId
:String
- URL:
/api/friends/:userId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/friends/potential
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/friends/add
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
id
:String
- URL:
/api/friends/csv
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/messages
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
senderId
:String
receiverId
:String
message
:String
timestamp
:String
- URL:
/api/messages/:chatId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/messages/:messageId
- Method:
DELETE
- Headers:
Authorization
:Bearer token
- URL:
/api/autocomplete/:query
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/chats
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
senderId
:String
receiverId
:String
- URL:
/api/chats/:userId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/chats/:firstUserId/:secondUserId
- Method:
GET
- Headers:
Authorization
:Bearer token
This repository contains the backend code for a location tracking system built using Node.js.
- Node.js (v12.x or higher)
- npm (v6.x or higher)
- MongoDB
- Clone the repository:
git clone https://github.com/datmaiq/location-tracking-be.git cd location-tracking-be
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and add the following environment variables:# Add your environment variables here JWT_SECRET_KEY="<your secret here>" MONGO_URL="mongodb+srv://<user>:<password>@<url>/<db-name>"
- Run the application:
npm run server
The API server will start on http://localhost:8000
.
- URL:
/api/auth/sign-up
- Method:
POST
- Body Parameters:
username
:String
password
:String
- URL:
/api/auth/sign-in
- Method:
POST
- Body Parameters:
email
:String
password
:String
- URL:
/api/auth/authenticate
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/users/profile
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/locations
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
latitude
:Number
longitude
:Number
timestamp
:String
- URL:
/api/locations
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/locations/:id
- Method:
DELETE
- Headers:
Authorization
:Bearer token
- URL:
/api/friends
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
userId
:String
friendId
:String
- URL:
/api/friends/:userId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/friends/potential
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/friends/add
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
id
:String
- URL:
/api/friends/csv
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/messages
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
senderId
:String
receiverId
:String
message
:String
timestamp
:String
- URL:
/api/messages/:chatId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/messages/:messageId
- Method:
DELETE
- Headers:
Authorization
:Bearer token
- URL:
/api/autocomplete/:query
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/chats
- Method:
POST
- Headers:
Authorization
:Bearer token
- Body Parameters:
senderId
:String
receiverId
:String
- URL:
/api/chats/:userId
- Method:
GET
- Headers:
Authorization
:Bearer token
- URL:
/api/chats/:firstUserId/:secondUserId
- Method:
GET
- Headers:
Authorization
:Bearer token