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.js
CHANGED
|
@@ -6,7 +6,6 @@ var bullmq = require('bullmq');
|
|
|
6
6
|
var jwt = require('jsonwebtoken');
|
|
7
7
|
var bcrypt = require('bcryptjs');
|
|
8
8
|
var nodemailer = require('nodemailer');
|
|
9
|
-
var express = require('express');
|
|
10
9
|
var clientS3 = require('@aws-sdk/client-s3');
|
|
11
10
|
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
12
11
|
|
|
@@ -447,6 +446,7 @@ var init_express = __esm({
|
|
|
447
446
|
cleanupInterval;
|
|
448
447
|
constructor() {
|
|
449
448
|
this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
|
|
449
|
+
this.cleanupInterval.unref();
|
|
450
450
|
}
|
|
451
451
|
cleanup() {
|
|
452
452
|
const now = Date.now();
|
|
@@ -577,7 +577,7 @@ var JWTService = class {
|
|
|
577
577
|
return jwt__default.default.verify(token, this.refreshSecret);
|
|
578
578
|
}
|
|
579
579
|
refreshTokens(refreshToken) {
|
|
580
|
-
const payload = this.verifyRefreshToken(refreshToken);
|
|
580
|
+
const { iat, exp, nbf, ...payload } = this.verifyRefreshToken(refreshToken);
|
|
581
581
|
return this.generateTokenPair(payload);
|
|
582
582
|
}
|
|
583
583
|
};
|
|
@@ -1054,6 +1054,8 @@ init_express();
|
|
|
1054
1054
|
|
|
1055
1055
|
// src/index.ts
|
|
1056
1056
|
init_config();
|
|
1057
|
+
|
|
1058
|
+
// src/response/index.ts
|
|
1057
1059
|
var ResponseHelper = class {
|
|
1058
1060
|
static success(res, data, message, statusCode = 200) {
|
|
1059
1061
|
const response2 = {
|
|
@@ -1120,45 +1122,51 @@ var ResponseHelper = class {
|
|
|
1120
1122
|
return res.status(204).send();
|
|
1121
1123
|
}
|
|
1122
1124
|
};
|
|
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
|
-
};
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
};
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
};
|
|
1125
|
+
try {
|
|
1126
|
+
const proto = __require("express").response;
|
|
1127
|
+
if (proto) {
|
|
1128
|
+
proto.success = function(data, message, statusCode = 200) {
|
|
1129
|
+
return ResponseHelper.success(this, data, message, statusCode);
|
|
1130
|
+
};
|
|
1131
|
+
proto.created = function(data, message) {
|
|
1132
|
+
return ResponseHelper.created(this, data, message);
|
|
1133
|
+
};
|
|
1134
|
+
proto.updated = function(data, message) {
|
|
1135
|
+
return ResponseHelper.updated(this, data, message);
|
|
1136
|
+
};
|
|
1137
|
+
proto.deleted = function(message) {
|
|
1138
|
+
return ResponseHelper.deleted(this, message);
|
|
1139
|
+
};
|
|
1140
|
+
proto.error = function(error, statusCode = 400, code, details) {
|
|
1141
|
+
return ResponseHelper.error(this, error, statusCode, code, details);
|
|
1142
|
+
};
|
|
1143
|
+
proto.badRequest = function(error, code) {
|
|
1144
|
+
return ResponseHelper.badRequest(this, error, code);
|
|
1145
|
+
};
|
|
1146
|
+
proto.unauthorized = function(error, code) {
|
|
1147
|
+
return ResponseHelper.unauthorized(this, error, code);
|
|
1148
|
+
};
|
|
1149
|
+
proto.forbidden = function(error, code) {
|
|
1150
|
+
return ResponseHelper.forbidden(this, error, code);
|
|
1151
|
+
};
|
|
1152
|
+
proto.notFound = function(error, code) {
|
|
1153
|
+
return ResponseHelper.notFound(this, error, code);
|
|
1154
|
+
};
|
|
1155
|
+
proto.conflict = function(error, code) {
|
|
1156
|
+
return ResponseHelper.conflict(this, error, code);
|
|
1157
|
+
};
|
|
1158
|
+
proto.validationError = function(error, details) {
|
|
1159
|
+
return ResponseHelper.validationError(this, error, details);
|
|
1160
|
+
};
|
|
1161
|
+
proto.internalError = function(error) {
|
|
1162
|
+
return ResponseHelper.internalError(this, error);
|
|
1163
|
+
};
|
|
1164
|
+
proto.paginated = function(data, page, limit, total) {
|
|
1165
|
+
return ResponseHelper.paginated(this, data, page, limit, total);
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
} catch {
|
|
1169
|
+
}
|
|
1162
1170
|
var response = ResponseHelper;
|
|
1163
1171
|
|
|
1164
1172
|
// src/upload/index.ts
|