@internetderdinge/api 1.229.7 → 1.229.9

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.
@@ -2,8 +2,6 @@
2
2
  import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
3
3
  import { Upload } from "@aws-sdk/lib-storage";
4
4
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
5
- import multer from "multer";
6
- import multerS3 from "multer-s3";
7
5
  import fs from "fs";
8
6
  import request from "request";
9
7
  const s3 = new S3Client({
@@ -52,20 +50,6 @@ export const fileFilter = (req, file, cb) => {
52
50
  cb(new Error("Invalid file type, only JPEG and PNG is allowed!"), false);
53
51
  }
54
52
  };
55
- export const uploadFile = multer({
56
- storage: multerS3({
57
- s3: s3,
58
- bucket: process.env.AWS_S3_BUCKET_NAME,
59
- contentType: multerS3.AUTO_CONTENT_TYPE,
60
- acl: "public-read",
61
- metadata(req, file, cb) {
62
- cb(null, { fieldName: file.fieldname });
63
- },
64
- key(req, file, cb) {
65
- cb(null, `${Date.now().toString()}-${file.originalname}`);
66
- },
67
- }),
68
- });
69
53
  const getPhoto = async (photoId, res) => {
70
54
  try {
71
55
  const params = {
@@ -116,7 +100,6 @@ const getPhotoFromUserImage = async (photoId, res) => {
116
100
  }
117
101
  };
118
102
  export default {
119
- uploadFile,
120
103
  uploadImage,
121
104
  getPhoto,
122
105
  getPhotoFromUserImage,
package/dist/src/index.js CHANGED
@@ -6,6 +6,7 @@ export { errorConverter, errorHandler } from "../src/middlewares/error";
6
6
  export { default as validate } from "../src/middlewares/validate";
7
7
  export { validateDevice, validateDeviceIsInOrganization, validateDeviceOrOrganizationQuery, validateDeviceQuery, } from "../src/middlewares/validateDevice";
8
8
  export { initI18n } from "../src/i18n/i18n";
9
+ export { default as i18n } from "../src/i18n/i18n";
9
10
  export { default as usersRoute } from "../src/users/users.route";
10
11
  export { default as accountsRoute } from "../src/accounts/accounts.route";
11
12
  export { default as accountsService } from "../src/accounts/accounts.service";
@@ -5,7 +5,7 @@ import AWS from "aws-sdk";
5
5
  import { deviceKindHasFeature } from "../utils/deviceUtils";
6
6
  import ApiError from "../utils/ApiError";
7
7
  import { getAuth0Token } from "../accounts/auth0.service";
8
- import { uploadImage, getSignedFileUrl, } from "../files/upload.service";
8
+ import { uploadImage, getSignedFileUrl } from "../files/upload.service";
9
9
  import { compareImages } from "../utils/comparePapers.service";
10
10
  import IotDevice from "./iotdevice.model";
11
11
  import { fileTypeFromBuffer } from "file-type";
@@ -20,10 +20,8 @@ const verifyCallback = (req, resolve, reject, requiredRights) => async (err, use
20
20
  resolve();
21
21
  };
22
22
  const auth = function authFactory(...requiredRights) {
23
- console.log("Creating auth middleware with required rights:", requiredRights);
24
23
  return async function authMiddleware(req, res, next) {
25
24
  try {
26
- console.log("Authenticating request:");
27
25
  // Check for custom token in X-API-Key header
28
26
  const apiKey = req.headers["x-api-key"];
29
27
  if (apiKey && apiKey.length === 64) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetderdinge/api",
3
- "version": "1.229.7",
3
+ "version": "1.229.9",
4
4
  "description": "Shared OpenIoT API modules",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -68,7 +68,6 @@
68
68
  "moment-timezone": "^0.6.0",
69
69
  "morgan": "^1.10.1",
70
70
  "multer": "^2.0.2",
71
- "multer-s3": "^3.0.1",
72
71
  "multiparty": "~4.2.3",
73
72
  "node-uuid": "~1.4.8",
74
73
  "nodemailer": "^8.0.1",
@@ -3,7 +3,6 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
3
3
  import { Upload } from "@aws-sdk/lib-storage";
4
4
  import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
5
5
  import multer from "multer";
6
- import multerS3 from "multer-s3";
7
6
  import fs from "fs";
8
7
  import request from "request";
9
8
 
@@ -82,21 +81,6 @@ export const fileFilter = (
82
81
  }
83
82
  };
84
83
 
85
- export const uploadFile = multer({
86
- storage: multerS3({
87
- s3: s3,
88
- bucket: process.env.AWS_S3_BUCKET_NAME!,
89
- contentType: multerS3.AUTO_CONTENT_TYPE,
90
- acl: "public-read",
91
- metadata(req, file, cb) {
92
- cb(null, { fieldName: file.fieldname });
93
- },
94
- key(req, file, cb) {
95
- cb(null, `${Date.now().toString()}-${file.originalname}`);
96
- },
97
- }),
98
- });
99
-
100
84
  const getPhoto = async (
101
85
  photoId: string,
102
86
  res: Express.Response,
@@ -161,7 +145,6 @@ const getPhotoFromUserImage = async (
161
145
  };
162
146
 
163
147
  export default {
164
- uploadFile,
165
148
  uploadImage,
166
149
  getPhoto,
167
150
  getPhotoFromUserImage,
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export {
11
11
  validateDeviceQuery,
12
12
  } from "../src/middlewares/validateDevice";
13
13
  export { initI18n } from "../src/i18n/i18n";
14
+ export { default as i18n } from "../src/i18n/i18n";
14
15
  export { default as usersRoute } from "../src/users/users.route";
15
16
  export { default as accountsRoute } from "../src/accounts/accounts.route";
16
17
  export { default as accountsService } from "../src/accounts/accounts.service";
@@ -5,11 +5,7 @@ import AWS from "aws-sdk";
5
5
  import { deviceKindHasFeature } from "../utils/deviceUtils";
6
6
  import ApiError from "../utils/ApiError";
7
7
  import { getAuth0Token } from "../accounts/auth0.service";
8
- import {
9
- uploadFile,
10
- uploadImage,
11
- getSignedFileUrl,
12
- } from "../files/upload.service";
8
+ import { uploadImage, getSignedFileUrl } from "../files/upload.service";
13
9
  import { compareImages } from "../utils/comparePapers.service";
14
10
  import IotDevice from "./iotdevice.model";
15
11
  import { fileTypeFromBuffer } from "file-type";
@@ -40,14 +40,12 @@ const verifyCallback: VerifyCallback =
40
40
  };
41
41
 
42
42
  const auth = function authFactory(...requiredRights: string[]) {
43
- console.log("Creating auth middleware with required rights:", requiredRights);
44
43
  return async function authMiddleware(
45
44
  req: AuthRequest,
46
45
  res: Response,
47
46
  next: NextFunction,
48
47
  ): Promise<void> {
49
48
  try {
50
- console.log("Authenticating request:");
51
49
  // Check for custom token in X-API-Key header
52
50
  const apiKey = req.headers["x-api-key"] as string | undefined;
53
51
  if (apiKey && apiKey.length === 64) {