@tmlmobilidade/controllers 20260222.2136.56 → 20260223.1747.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agencies/agencies.js +4 -4
- package/dist/rides/rides.js +6 -6
- package/dist/rides/watch.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* * */
|
|
2
|
-
import { HttpException,
|
|
2
|
+
import { HttpException, HTTP_STATUS } from '@tmlmobilidade/consts';
|
|
3
3
|
import { agencies } from '@tmlmobilidade/interfaces';
|
|
4
4
|
/* * */
|
|
5
5
|
export class AgenciesSharedController {
|
|
@@ -11,7 +11,7 @@ export class AgenciesSharedController {
|
|
|
11
11
|
*/
|
|
12
12
|
static async getAll(request, reply) {
|
|
13
13
|
const allAgencies = await agencies.findMany({}, { sort: { _id: 1 } });
|
|
14
|
-
reply.send({ data: allAgencies, error: null, statusCode:
|
|
14
|
+
reply.send({ data: allAgencies, error: null, statusCode: HTTP_STATUS.OK });
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Returns an Agency by ID.
|
|
@@ -21,7 +21,7 @@ export class AgenciesSharedController {
|
|
|
21
21
|
static async getById(request, reply) {
|
|
22
22
|
const agencyData = await agencies.findById(request.params.id);
|
|
23
23
|
if (!agencyData)
|
|
24
|
-
throw new HttpException(
|
|
25
|
-
reply.send({ data: agencyData, error: null, statusCode:
|
|
24
|
+
throw new HttpException(HTTP_STATUS.NOT_FOUND, 'Agency not found');
|
|
25
|
+
reply.send({ data: agencyData, error: null, statusCode: HTTP_STATUS.OK });
|
|
26
26
|
}
|
|
27
27
|
}
|
package/dist/rides/rides.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* * */
|
|
2
2
|
import { ridesChangeStream } from './watch.js';
|
|
3
|
-
import {
|
|
3
|
+
import { HTTP_STATUS } from '@tmlmobilidade/consts';
|
|
4
4
|
import { rides, ridesBatchAggregationPipeline } from '@tmlmobilidade/interfaces';
|
|
5
5
|
import { normalizeRide } from '@tmlmobilidade/normalizers';
|
|
6
6
|
import { GetRidesBatchQuerySchema, PermissionCatalog } from '@tmlmobilidade/types';
|
|
@@ -23,7 +23,7 @@ export class RidesSharedController {
|
|
|
23
23
|
// based on their permissions. If none, return an empty array.
|
|
24
24
|
const ridesPermission = PermissionCatalog.get(request.permissions, scope, action);
|
|
25
25
|
if (!ridesPermission['resources']?.agency_ids?.length)
|
|
26
|
-
return reply.send({ data: [], error: null, statusCode:
|
|
26
|
+
return reply.send({ data: [], error: null, statusCode: HTTP_STATUS.OK });
|
|
27
27
|
const allowAllAgencies = ridesPermission['resources'].agency_ids.includes(PermissionCatalog.ALLOW_ALL_FLAG);
|
|
28
28
|
//
|
|
29
29
|
// If search is provided, immediately try to find the ride by ID.
|
|
@@ -36,7 +36,7 @@ export class RidesSharedController {
|
|
|
36
36
|
});
|
|
37
37
|
if (foundRideById) {
|
|
38
38
|
const normalizedRide = normalizeRide(foundRideById);
|
|
39
|
-
return reply.send({ data: [normalizedRide], error: null, statusCode:
|
|
39
|
+
return reply.send({ data: [normalizedRide], error: null, statusCode: HTTP_STATUS.OK });
|
|
40
40
|
}
|
|
41
41
|
//
|
|
42
42
|
// Get the rides batch using native MongoDB cursor
|
|
@@ -69,7 +69,7 @@ export class RidesSharedController {
|
|
|
69
69
|
reply.send({
|
|
70
70
|
data: ridesBatch ?? [],
|
|
71
71
|
error: null,
|
|
72
|
-
statusCode:
|
|
72
|
+
statusCode: HTTP_STATUS.OK,
|
|
73
73
|
});
|
|
74
74
|
//
|
|
75
75
|
}
|
|
@@ -85,7 +85,7 @@ export class RidesSharedController {
|
|
|
85
85
|
// based on their permissions. If none, return an empty array.
|
|
86
86
|
const ridesPermission = PermissionCatalog.get(request.permissions, scope, action);
|
|
87
87
|
if (!ridesPermission['resources']?.agency_ids?.length)
|
|
88
|
-
return reply.send({ data: null, error: null, statusCode:
|
|
88
|
+
return reply.send({ data: null, error: null, statusCode: HTTP_STATUS.OK });
|
|
89
89
|
const allowAllAgencies = ridesPermission['resources'].agency_ids.includes(PermissionCatalog.ALLOW_ALL_FLAG);
|
|
90
90
|
//
|
|
91
91
|
// If search is provided, immediately try to find the ride by ID.
|
|
@@ -97,7 +97,7 @@ export class RidesSharedController {
|
|
|
97
97
|
});
|
|
98
98
|
if (foundRideById) {
|
|
99
99
|
const normalizedRide = normalizeRide(foundRideById);
|
|
100
|
-
return reply.send({ data: normalizedRide, error: null, statusCode:
|
|
100
|
+
return reply.send({ data: normalizedRide, error: null, statusCode: HTTP_STATUS.OK });
|
|
101
101
|
}
|
|
102
102
|
//
|
|
103
103
|
}
|
package/dist/rides/watch.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* - Clean subscription management per client
|
|
24
24
|
* - Reduced database load and network overhead
|
|
25
25
|
*/
|
|
26
|
-
import {
|
|
26
|
+
import { HTTP_STATUS } from '@tmlmobilidade/consts';
|
|
27
27
|
import { rides } from '@tmlmobilidade/interfaces';
|
|
28
28
|
import { normalizeRide } from '@tmlmobilidade/normalizers';
|
|
29
29
|
import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
@@ -102,7 +102,7 @@ class RidesChangeStreamManager {
|
|
|
102
102
|
const message = {
|
|
103
103
|
data: normalizedRide,
|
|
104
104
|
error: null,
|
|
105
|
-
statusCode:
|
|
105
|
+
statusCode: HTTP_STATUS.OK,
|
|
106
106
|
};
|
|
107
107
|
// Publish to all subscribers via EventEmitter
|
|
108
108
|
this.emitter.emit('change', message);
|