saas-backend-kit 1.0.1 → 1.0.2
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/README.md +38 -6
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +1 -1
- package/dist/auth/index.mjs.map +1 -1
- package/dist/index.js +49 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -41
- package/dist/index.mjs.map +1 -1
- package/dist/rate-limit/index.js +1 -0
- package/dist/rate-limit/index.js.map +1 -1
- package/dist/rate-limit/index.mjs +1 -0
- package/dist/rate-limit/index.mjs.map +1 -1
- package/dist/response/index.js +51 -40
- package/dist/response/index.js.map +1 -1
- package/dist/response/index.mjs +51 -40
- package/dist/response/index.mjs.map +1 -1
- package/jest-output.json +72 -0
- package/jest.config.js +19 -0
- package/package.json +9 -7
- package/src/auth/jwt.ts +1 -1
- package/src/rate-limit/express.ts +1 -0
- package/src/response/index.ts +49 -40
- package/tests/auth.test.ts +134 -0
- package/tests/config.test.ts +36 -0
- package/tests/logger.test.ts +47 -0
- package/tests/notifications.test.ts +19 -0
- package/tests/rate-limit.test.ts +50 -0
- package/tests/upload.test.ts +33 -0
- package/tsconfig.test.json +14 -0
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { Queue, Worker } from 'bullmq';
|
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
5
|
import bcrypt from 'bcryptjs';
|
|
6
6
|
import nodemailer from 'nodemailer';
|
|
7
|
-
import { Response } from 'express';
|
|
8
7
|
import { S3Client, PutObjectCommand, DeleteObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
|
|
9
8
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
10
9
|
|
|
@@ -438,6 +437,7 @@ var init_express = __esm({
|
|
|
438
437
|
cleanupInterval;
|
|
439
438
|
constructor() {
|
|
440
439
|
this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
|
|
440
|
+
this.cleanupInterval.unref();
|
|
441
441
|
}
|
|
442
442
|
cleanup() {
|
|
443
443
|
const now = Date.now();
|
|
@@ -568,7 +568,7 @@ var JWTService = class {
|
|
|
568
568
|
return jwt.verify(token, this.refreshSecret);
|
|
569
569
|
}
|
|
570
570
|
refreshTokens(refreshToken) {
|
|
571
|
-
const payload = this.verifyRefreshToken(refreshToken);
|
|
571
|
+
const { iat, exp, nbf, ...payload } = this.verifyRefreshToken(refreshToken);
|
|
572
572
|
return this.generateTokenPair(payload);
|
|
573
573
|
}
|
|
574
574
|
};
|
|
@@ -1045,6 +1045,8 @@ init_express();
|
|
|
1045
1045
|
|
|
1046
1046
|
// src/index.ts
|
|
1047
1047
|
init_config();
|
|
1048
|
+
|
|
1049
|
+
// src/response/index.ts
|
|
1048
1050
|
var ResponseHelper = class {
|
|
1049
1051
|
static success(res, data, message, statusCode = 200) {
|
|
1050
1052
|
const response2 = {
|
|
@@ -1111,45 +1113,51 @@ var ResponseHelper = class {
|
|
|
1111
1113
|
return res.status(204).send();
|
|
1112
1114
|
}
|
|
1113
1115
|
};
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
};
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
};
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
};
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
};
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
};
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
};
|
|
1116
|
+
try {
|
|
1117
|
+
const proto = __require("express").response;
|
|
1118
|
+
if (proto) {
|
|
1119
|
+
proto.success = function(data, message, statusCode = 200) {
|
|
1120
|
+
return ResponseHelper.success(this, data, message, statusCode);
|
|
1121
|
+
};
|
|
1122
|
+
proto.created = function(data, message) {
|
|
1123
|
+
return ResponseHelper.created(this, data, message);
|
|
1124
|
+
};
|
|
1125
|
+
proto.updated = function(data, message) {
|
|
1126
|
+
return ResponseHelper.updated(this, data, message);
|
|
1127
|
+
};
|
|
1128
|
+
proto.deleted = function(message) {
|
|
1129
|
+
return ResponseHelper.deleted(this, message);
|
|
1130
|
+
};
|
|
1131
|
+
proto.error = function(error, statusCode = 400, code, details) {
|
|
1132
|
+
return ResponseHelper.error(this, error, statusCode, code, details);
|
|
1133
|
+
};
|
|
1134
|
+
proto.badRequest = function(error, code) {
|
|
1135
|
+
return ResponseHelper.badRequest(this, error, code);
|
|
1136
|
+
};
|
|
1137
|
+
proto.unauthorized = function(error, code) {
|
|
1138
|
+
return ResponseHelper.unauthorized(this, error, code);
|
|
1139
|
+
};
|
|
1140
|
+
proto.forbidden = function(error, code) {
|
|
1141
|
+
return ResponseHelper.forbidden(this, error, code);
|
|
1142
|
+
};
|
|
1143
|
+
proto.notFound = function(error, code) {
|
|
1144
|
+
return ResponseHelper.notFound(this, error, code);
|
|
1145
|
+
};
|
|
1146
|
+
proto.conflict = function(error, code) {
|
|
1147
|
+
return ResponseHelper.conflict(this, error, code);
|
|
1148
|
+
};
|
|
1149
|
+
proto.validationError = function(error, details) {
|
|
1150
|
+
return ResponseHelper.validationError(this, error, details);
|
|
1151
|
+
};
|
|
1152
|
+
proto.internalError = function(error) {
|
|
1153
|
+
return ResponseHelper.internalError(this, error);
|
|
1154
|
+
};
|
|
1155
|
+
proto.paginated = function(data, page, limit, total) {
|
|
1156
|
+
return ResponseHelper.paginated(this, data, page, limit, total);
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
} catch {
|
|
1160
|
+
}
|
|
1153
1161
|
var response = ResponseHelper;
|
|
1154
1162
|
|
|
1155
1163
|
// src/upload/index.ts
|