@tmlmobilidade/controllers 20260911.1742.59 → 20260914.1727.46

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.
@@ -1,28 +1 @@
1
- import { type FastifyReply, type FastifyRequest } from '@tmlmobilidade/go-clients-fastify';
2
- import { type CreateFileExportDto, type FileExport } from '@tmlmobilidade/go-types-downloads';
3
- export declare class ExporterSharedController {
4
- /**
5
- * Returns an Agency by ID.
6
- * @param request The request object
7
- * @param reply The reply object
8
- */
9
- static create(request: FastifyRequest<{
10
- Body: CreateFileExportDto<any>;
11
- }>, reply: FastifyReply<FileExport>): Promise<never>;
12
- /**
13
- * Downloads a FileExport by ID.
14
- * @param request The request object
15
- * @param reply The reply object
16
- */
17
- static download(request: FastifyRequest<{
18
- Params: {
19
- id: string;
20
- };
21
- }>, reply: FastifyReply<string>): Promise<never>;
22
- /**
23
- * Returns all FileExport sorted by ID.
24
- * @param request The request object
25
- * @param reply The reply object
26
- */
27
- static getAll(request: FastifyRequest, reply: FastifyReply<FileExport[]>): Promise<never>;
28
- }
1
+ export {};
@@ -1,70 +1,73 @@
1
- /* * */
2
- import { HTTP_STATUS, HttpException } from '@tmlmobilidade/consts';
3
- import { goDb } from '@tmlmobilidade/go-interfaces-godb';
4
- import { storageProvider } from '@tmlmobilidade/go-providers-storage';
5
- import { Logger } from '@tmlmobilidade/logger';
6
- /* * */
7
- export class ExporterSharedController {
8
- //
9
- /**
10
- * Returns an Agency by ID.
11
- * @param request The request object
12
- * @param reply The reply object
13
- */
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- static async create(request, reply) {
16
- const fileExportData = await goDb.core.exports.insertOne({
17
- ...request.body,
18
- created_by: request.me._id,
19
- processing_status: 'waiting',
20
- updated_by: request.me._id,
21
- });
22
- return reply.send({ data: fileExportData, error: null, statusCode: HTTP_STATUS.CREATED });
23
- }
24
- /**
25
- * Downloads a FileExport by ID.
26
- * @param request The request object
27
- * @param reply The reply object
28
- */
29
- static async download(request, reply) {
30
- //
31
- const { id } = request.params;
32
- const context = { action: 'download', feature: 'exporter', request, value: id };
33
- // Find file export by ID
34
- const fileExport = await goDb.core.exports.findById(id);
35
- if (!fileExport) {
36
- const error = new HttpException(HTTP_STATUS.NOT_FOUND, 'File export not found');
37
- Logger.issue({ context, level: 'error', messageOrError: error });
38
- throw error;
39
- }
40
- // Retrieve file data from storage
41
- const foundFileData = await storageProvider.findById(fileExport.file_id);
42
- const storageServiceResponse = await fetch(foundFileData.url);
43
- if (!storageServiceResponse.ok || !storageServiceResponse.body) {
44
- const error = new HttpException(HTTP_STATUS.INTERNAL_SERVER_ERROR, 'Could not fetch file');
45
- Logger.issue({ context, level: 'error', messageOrError: error });
46
- throw error;
47
- }
48
- // Set headers and pipe the response body to the client
49
- reply.header('Content-Disposition', `attachment; filename="${foundFileData.name}"`);
50
- reply.header('Content-Type', foundFileData.type);
51
- // Set content length if available
52
- const contentLength = storageServiceResponse.headers.get('Content-Length');
53
- if (contentLength)
54
- reply.header('Content-Length', contentLength);
55
- // Pipe the response body to the client
56
- return reply.send(storageServiceResponse.body);
57
- }
58
- /**
59
- * Returns all FileExport sorted by ID.
60
- * @param request The request object
61
- * @param reply The reply object
62
- */
63
- static async getAll(request, reply) {
64
- const filters = {
65
- created_by: request.me._id,
66
- };
67
- const allFileExport = await goDb.core.exports.findMany(filters);
68
- return reply.send({ data: allFileExport, error: null, statusCode: HTTP_STATUS.OK });
69
- }
70
- }
1
+ // /* * */
2
+ export {};
3
+ // import { HTTP_STATUS, HttpException } from '@tmlmobilidade/consts';
4
+ // import { type FastifyReply, type FastifyRequest } from '@tmlmobilidade/go-clients-fastify';
5
+ // import { goDb } from '@tmlmobilidade/go-interfaces-godb';
6
+ // import { storageProvider } from '@tmlmobilidade/go-providers-storage';
7
+ // import { type CreateFileExportDto, type FileExport } from '@tmlmobilidade/go-types-downloads';
8
+ // import { Logger } from '@tmlmobilidade/logger';
9
+ // /* * */
10
+ // export class ExporterSharedController {
11
+ // //
12
+ // /**
13
+ // * Returns an Agency by ID.
14
+ // * @param request The request object
15
+ // * @param reply The reply object
16
+ // */
17
+ // // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ // static async create(request: FastifyRequest<{ Body: CreateFileExportDto<any> }>, reply: FastifyReply<FileExport>) {
19
+ // const fileExportData = await goDb.core.exports.insertOne({
20
+ // ...request.body,
21
+ // created_by: request.me._id,
22
+ // processing_status: 'waiting',
23
+ // updated_by: request.me._id,
24
+ // });
25
+ // return reply.send({ data: fileExportData, error: null, statusCode: HTTP_STATUS.CREATED });
26
+ // }
27
+ // /**
28
+ // * Downloads a FileExport by ID.
29
+ // * @param request The request object
30
+ // * @param reply The reply object
31
+ // */
32
+ // static async download(request: FastifyRequest<{ Params: { id: string } }>, reply: FastifyReply<string>) {
33
+ // //
34
+ // const { id } = request.params;
35
+ // const context = { action: 'download', feature: 'exporter', request, value: id };
36
+ // // Find file export by ID
37
+ // const fileExport = await goDb.core.exports.findById(id);
38
+ // if (!fileExport) {
39
+ // const error = new HttpException(HTTP_STATUS.NOT_FOUND, 'File export not found');
40
+ // Logger.issue({ context, level: 'error', messageOrError: error });
41
+ // throw error;
42
+ // }
43
+ // // Retrieve file data from storage
44
+ // const foundFileData = await storageProvider.findById(fileExport.file_id);
45
+ // const storageServiceResponse = await fetch(foundFileData.url);
46
+ // if (!storageServiceResponse.ok || !storageServiceResponse.body) {
47
+ // const error = new HttpException(HTTP_STATUS.INTERNAL_SERVER_ERROR, 'Could not fetch file');
48
+ // Logger.issue({ context, level: 'error', messageOrError: error });
49
+ // throw error;
50
+ // }
51
+ // // Set headers and pipe the response body to the client
52
+ // reply.header('Content-Disposition', `attachment; filename="${foundFileData.name}"`);
53
+ // reply.header('Content-Type', foundFileData.type);
54
+ // // Set content length if available
55
+ // const contentLength = storageServiceResponse.headers.get('Content-Length');
56
+ // if (contentLength) reply.header('Content-Length', contentLength);
57
+ // // Pipe the response body to the client
58
+ // return reply.send(storageServiceResponse.body);
59
+ // }
60
+ // /**
61
+ // * Returns all FileExport sorted by ID.
62
+ // * @param request The request object
63
+ // * @param reply The reply object
64
+ // */
65
+ // static async getAll(request: FastifyRequest, reply: FastifyReply<FileExport[]>) {
66
+ // const filters = {
67
+ // created_by: request.me._id,
68
+ // };
69
+ // const allFileExport = await goDb.core.exports.findMany(filters);
70
+ // return reply.send({ data: allFileExport, error: null, statusCode: HTTP_STATUS.OK });
71
+ // }
72
+ // //
73
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/controllers",
3
- "version": "20260911.1742.59",
3
+ "version": "20260914.1727.46",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"