@internetderdinge/api 1.229.8 → 1.229.10
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/src/devices/devices.route.js +4 -1
- package/dist/src/files/upload.service.js +0 -17
- package/dist/src/index.js +1 -0
- package/dist/src/iotdevice/iotdevice.service.js +1 -1
- package/dist/src/middlewares/validateAdmin.js +0 -1
- package/package.json +1 -2
- package/src/devices/devices.route.ts +3 -0
- package/src/files/upload.service.ts +0 -17
- package/src/index.ts +1 -0
- package/src/iotdevice/iotdevice.service.ts +1 -5
- package/src/middlewares/validateAdmin.ts +0 -1
|
@@ -7,7 +7,7 @@ import { validateQuerySearchUserAndOrganization } from "../middlewares/validateQ
|
|
|
7
7
|
import { validateDevice } from "../middlewares/validateDevice.js";
|
|
8
8
|
import * as devicesController from "./devices.controller.js";
|
|
9
9
|
import { resetDevice } from "./devices.controller.js";
|
|
10
|
-
import { createDeviceSchema, queryDevicesSchema, getDeviceSchema, updateDeviceSchema, getEventsSchema, pingDeviceSchema, registerDeviceSchema, ledLightSchema, rebootDeviceSchema, getImageSchema, updateSingleImageMetaSchema, uploadSingleImageSchema, resetDeviceSchema, } from "./devices.validation.js";
|
|
10
|
+
import { createDeviceSchema, queryDevicesSchema, getDeviceSchema, updateDeviceSchema, deleteDeviceSchema, getEventsSchema, pingDeviceSchema, registerDeviceSchema, ledLightSchema, rebootDeviceSchema, getImageSchema, updateSingleImageMetaSchema, uploadSingleImageSchema, resetDeviceSchema, } from "./devices.validation.js";
|
|
11
11
|
import { deviceResponseSchema, devicesResponseSchema, eventResponseSchema, genericResponseSchema, imageResponseSchema, uploadResponseSchema, resetResponseSchema, } from "./devices.schemas.js";
|
|
12
12
|
import { validateOrganizationDelete, validateOrganizationUpdate, } from "../middlewares/validateAction.js";
|
|
13
13
|
export const devicesRouteSpecs = [
|
|
@@ -68,6 +68,9 @@ export const devicesRouteSpecs = [
|
|
|
68
68
|
{
|
|
69
69
|
method: "delete",
|
|
70
70
|
path: "/:deviceId",
|
|
71
|
+
validate: [auth("manageUsers"), validateDevice, validateOrganizationDelete],
|
|
72
|
+
requestSchema: deleteDeviceSchema,
|
|
73
|
+
responseSchema: genericResponseSchema,
|
|
71
74
|
handler: devicesController.deleteEntry,
|
|
72
75
|
summary: "Delete a device",
|
|
73
76
|
description: "Remove the specified device from the system.",
|
|
@@ -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
|
@@ -10,6 +10,7 @@ export { default as i18n } from "../src/i18n/i18n";
|
|
|
10
10
|
export { default as usersRoute } from "../src/users/users.route";
|
|
11
11
|
export { default as accountsRoute } from "../src/accounts/accounts.route";
|
|
12
12
|
export { default as accountsService } from "../src/accounts/accounts.service";
|
|
13
|
+
export { auth0 } from "../src/accounts/auth0.service";
|
|
13
14
|
export { default as organizationsRoute } from "../src/organizations/organizations.route";
|
|
14
15
|
export { default as organizationsService } from "../src/organizations/organizations.service";
|
|
15
16
|
export { default as Organization } from "../src/organizations/organizations.model";
|
|
@@ -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
|
|
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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetderdinge/api",
|
|
3
|
-
"version": "1.229.
|
|
3
|
+
"version": "1.229.10",
|
|
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",
|
|
@@ -105,6 +105,9 @@ export const devicesRouteSpecs: RouteSpec[] = [
|
|
|
105
105
|
{
|
|
106
106
|
method: "delete",
|
|
107
107
|
path: "/:deviceId",
|
|
108
|
+
validate: [auth("manageUsers"), validateDevice, validateOrganizationDelete],
|
|
109
|
+
requestSchema: deleteDeviceSchema,
|
|
110
|
+
responseSchema: genericResponseSchema,
|
|
108
111
|
handler: devicesController.deleteEntry,
|
|
109
112
|
summary: "Delete a device",
|
|
110
113
|
description: "Remove the specified device from the system.",
|
|
@@ -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
|
@@ -15,6 +15,7 @@ export { default as i18n } from "../src/i18n/i18n";
|
|
|
15
15
|
export { default as usersRoute } from "../src/users/users.route";
|
|
16
16
|
export { default as accountsRoute } from "../src/accounts/accounts.route";
|
|
17
17
|
export { default as accountsService } from "../src/accounts/accounts.service";
|
|
18
|
+
export { auth0 } from "../src/accounts/auth0.service";
|
|
18
19
|
export { default as organizationsRoute } from "../src/organizations/organizations.route";
|
|
19
20
|
export { default as organizationsService } from "../src/organizations/organizations.service";
|
|
20
21
|
export { default as Organization } from "../src/organizations/organizations.model";
|
|
@@ -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";
|
|
@@ -3,7 +3,6 @@ import ApiError from "../utils/ApiError";
|
|
|
3
3
|
import type { Request, Response, NextFunction } from "express";
|
|
4
4
|
|
|
5
5
|
const isAdmin = (user: Record<string, any> | undefined): boolean => {
|
|
6
|
-
return false;
|
|
7
6
|
if (!user) return false;
|
|
8
7
|
|
|
9
8
|
// return false; // TODO: Remove this line when the user object is properly defined
|