Back Seat Driver is a telematics-focused application designed to provide drivers with insights into their driving habits, vehicle performance, and recommendations for safer, more efficient driving. The Express API serves as the backend for user authentication, vehicle data management, and app-related functionalities. It uses JWT authentication, MySQL for data storage, and caching mechanisms for optimized performance.
- User authentication using JWT
- Secure password storage with bcrypt
- Vehicle data retrieval with caching for performance optimization
- CRUD operations for managing app-related data
- Search functionality for records
- Node.js with Express.js
- MySQL (using mysql2)
- JWT for authentication
- bcrypt for password hashing
- NodeCache for caching
- CORS for handling cross-origin requests
- Node.js installed
- MySQL database configured
- Environment variables set up for security
- Clone the repository:
git clone https://github.com/your-repo/backseatdriver-api.git
- Install dependencies:
cd backseatdriver-api npm install --force - Configure environment variables:
export JWT_SECRET=your_jwt_secret_key export DB_PASSWORD=your_database_password
- Start the server:
node index.js
POST /register
- Request Body:
{ "username": "user123", "password": "securepassword" } - Response:
{ "message": "User registered successfully" }
POST /login
- Request Body:
{ "username": "user123", "password": "securepassword" } - Response:
{ "token": "your_jwt_token" }
GET /vehicles
- Headers:
Authorization: Bearer your_jwt_token
- Response:
[ { "id": 1, "make": "Toyota", "model": "Corolla", "year": 2020 } ]
POST /app_endpoint
- Response:
[ { "id": 1, "name": "Sample App", "description": "An example entry." } ]
POST /app_endpoint_family
- Response:
[ { "id": 1, "name": "John Doe", "funeral_time": "2024-06-15" } ]
POST /api/app_list_family
- Request Body:
{ "Name": "John Doe", "Address": "123 Main St", "Time": "10:00 AM", "Description": "Funeral Service", "Personal_msg": "Loving father", "Family_flowers": "Yes", "Donations": "Charity", "Funeral_arrangement": "Private", "Date_published": "2024-06-14", "Funeral_time": "2024-06-15", "Image": "image_url" } - Response:
{ "message": "Data inserted successfully", "id": 1 }
GET /search_app
- Query Parameters:
firstname(optional)lastname(optional)
- Response:
[ { "id": 1, "name": "Jane Doe" } ]
POST /posttoapp
- Request Body:
{ "fullname": "Jane Doe", "county": "Galway" } - Response:
{ "message": "Record added successfully" }
- Ensure
JWT_SECRETandDB_PASSWORDare stored in environment variables - Implement rate limiting to prevent abuse
- Sanitize user input to prevent SQL injection
- Hash passwords using bcrypt
- Implement role-based access control
- Introduce logging and monitoring
- Optimize query performance
- Enhance caching mechanisms
Caolán Maguire - Final Year Project (Back Seat Driver)