location controller updated with heading and created new models and controllers for remaining modules

This commit is contained in:
Shibi Chakkaravarthy
2026-05-04 20:57:03 +05:30
parent 1245e09111
commit 54d9508dc8
31 changed files with 2140 additions and 96 deletions
+39
View File
@@ -4,6 +4,42 @@ import {
getLocationByRadius,
} from "../models/Location/operations";
/*
Sample Location Payload
{
"extras": {},
"activity": {
"confidence": 100,
"type": "still"
},
"timestamp": "2026-04-25T17:31:25.320Z",
"battery": {
"level": 0.57,
"is_charging": false
},
"recorded_at": "2026-04-25T17:31:25.388Z",
"age": 0.074,
"is_moving": false,
"event": "motionchange",
"uuid": "4c476d94-b7db-4823-9270-805235ed0ec8",
"coords": {
"ellipsoidal_altitude": 0,
"altitude": 0,
"altitude_accuracy": 0.5,
"heading_accuracy": -1,
"heading": -1,
"speed": 0,
"accuracy": 5,
"longitude": 77.48675,
"speed_accuracy": 0.5,
"latitude": 9.9707883
},
"odometer_error": 0,
"odometer": 0
}
*/
export const createLocationController = async (req, res) => {
try {
const { user } = res.locals;
@@ -11,6 +47,9 @@ export const createLocationController = async (req, res) => {
const dbPayload = {
battery: location.battery.level,
coordinates: location.coords,
event: location.event,
heading: location.coords.heading,
activity: location?.activity?.type,
recorded_at: location.recorded_at,
};
const uploaded = await createLocation({ ...dbPayload, user: user?.id });