@optimatech88/titomeet-shared-lib 1.0.0
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/.prettierrc +5 -0
- package/dist/auth/auth.guard.d.ts +17 -0
- package/dist/auth/auth.guard.d.ts.map +1 -0
- package/dist/auth/auth.guard.js +89 -0
- package/dist/auth/auth.guard.js.map +1 -0
- package/dist/auth/auth.module.d.ts +9 -0
- package/dist/auth/auth.module.d.ts.map +1 -0
- package/dist/auth/auth.module.js +32 -0
- package/dist/auth/auth.module.js.map +1 -0
- package/dist/cache/cache.module.d.ts +5 -0
- package/dist/cache/cache.module.d.ts.map +1 -0
- package/dist/cache/cache.module.js +41 -0
- package/dist/cache/cache.module.js.map +1 -0
- package/dist/cache/cache.service.d.ts +9 -0
- package/dist/cache/cache.service.d.ts.map +1 -0
- package/dist/cache/cache.service.js +38 -0
- package/dist/cache/cache.service.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/prisma/prisma.module.d.ts +3 -0
- package/dist/prisma/prisma.module.d.ts.map +1 -0
- package/dist/prisma/prisma.module.js +22 -0
- package/dist/prisma/prisma.module.js.map +1 -0
- package/dist/prisma/prisma.service.d.ts +7 -0
- package/dist/prisma/prisma.service.d.ts.map +1 -0
- package/dist/prisma/prisma.service.js +24 -0
- package/dist/prisma/prisma.service.js.map +1 -0
- package/dist/prisma/prisma.service.spec.d.ts +2 -0
- package/dist/prisma/prisma.service.spec.d.ts.map +1 -0
- package/dist/prisma/prisma.service.spec.js +17 -0
- package/dist/prisma/prisma.service.spec.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/api/endpoints.d.ts +7 -0
- package/dist/utils/api/endpoints.d.ts.map +1 -0
- package/dist/utils/api/endpoints.js +10 -0
- package/dist/utils/api/endpoints.js.map +1 -0
- package/dist/utils/constants.d.ts +3 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +15 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/events.d.ts +7 -0
- package/dist/utils/events.d.ts.map +1 -0
- package/dist/utils/events.js +10 -0
- package/dist/utils/events.js.map +1 -0
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +40 -0
- package/prisma/schema.prisma +118 -0
- package/src/auth/auth.guard.ts +96 -0
- package/src/auth/auth.module.ts +24 -0
- package/src/cache/cache.module.ts +25 -0
- package/src/cache/cache.service.ts +19 -0
- package/src/index.ts +21 -0
- package/src/prisma/prisma.module.ts +9 -0
- package/src/prisma/prisma.service.ts +13 -0
- package/src/types/index.ts +12 -0
- package/src/utils/api/endpoints.ts +7 -0
- package/src/utils/constants.ts +13 -0
- package/src/utils/events.ts +7 -0
- package/src/utils/index.ts +12 -0
- package/tsconfig.json +24 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { JwtService } from '@nestjs/jwt';
|
|
3
|
+
export declare class AuthGuard implements CanActivate {
|
|
4
|
+
private jwtService;
|
|
5
|
+
private prisma;
|
|
6
|
+
constructor(jwtService: JwtService);
|
|
7
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
8
|
+
private extractTokenFromHeader;
|
|
9
|
+
}
|
|
10
|
+
export declare class OptionalAuthGuard implements CanActivate {
|
|
11
|
+
private jwtService;
|
|
12
|
+
private prisma;
|
|
13
|
+
constructor(jwtService: JwtService);
|
|
14
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
15
|
+
private extractTokenFromHeader;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=auth.guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.d.ts","sourceRoot":"","sources":["../../src/auth/auth.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAGjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,qBACa,SAAU,YAAW,WAAW;IAIzC,OAAO,CAAC,UAAU;IAHpB,OAAO,CAAC,MAAM,CAAe;gBAGnB,UAAU,EAAE,UAAU;IAK1B,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B9D,OAAO,CAAC,sBAAsB;CAI/B;AAED,qBACa,iBAAkB,YAAW,WAAW;IAIjD,OAAO,CAAC,UAAU;IAHnB,OAAO,CAAC,MAAM,CAAe;gBAGpB,UAAU,EAAE,UAAU;IAK1B,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IA4B9D,OAAO,CAAC,sBAAsB;CAI/B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OptionalAuthGuard = exports.AuthGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
15
|
+
const client_1 = require("@prisma/client");
|
|
16
|
+
let AuthGuard = class AuthGuard {
|
|
17
|
+
constructor(jwtService) {
|
|
18
|
+
this.jwtService = jwtService;
|
|
19
|
+
this.prisma = new client_1.PrismaClient();
|
|
20
|
+
}
|
|
21
|
+
async canActivate(context) {
|
|
22
|
+
const request = context.switchToHttp().getRequest();
|
|
23
|
+
const token = this.extractTokenFromHeader(request);
|
|
24
|
+
if (!token) {
|
|
25
|
+
throw new common_1.UnauthorizedException();
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const payload = (await this.jwtService.verifyAsync(token));
|
|
29
|
+
const user = await this.prisma.user.findUnique({
|
|
30
|
+
where: { id: payload.userId }
|
|
31
|
+
});
|
|
32
|
+
if (!user) {
|
|
33
|
+
throw new common_1.UnauthorizedException();
|
|
34
|
+
}
|
|
35
|
+
request['user'] = user;
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
throw new common_1.UnauthorizedException();
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
extractTokenFromHeader(request) {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const [type, token] = (_b = (_a = request.headers.authorization) === null || _a === void 0 ? void 0 : _a.split(' ')) !== null && _b !== void 0 ? _b : [];
|
|
45
|
+
return type === 'Bearer' ? token : undefined;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.AuthGuard = AuthGuard;
|
|
49
|
+
exports.AuthGuard = AuthGuard = __decorate([
|
|
50
|
+
(0, common_1.Injectable)(),
|
|
51
|
+
__metadata("design:paramtypes", [jwt_1.JwtService])
|
|
52
|
+
], AuthGuard);
|
|
53
|
+
let OptionalAuthGuard = class OptionalAuthGuard {
|
|
54
|
+
constructor(jwtService) {
|
|
55
|
+
this.jwtService = jwtService;
|
|
56
|
+
this.prisma = new client_1.PrismaClient();
|
|
57
|
+
}
|
|
58
|
+
async canActivate(context) {
|
|
59
|
+
const request = context.switchToHttp().getRequest();
|
|
60
|
+
const token = this.extractTokenFromHeader(request);
|
|
61
|
+
if (!token) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const payload = (await this.jwtService.verifyAsync(token));
|
|
66
|
+
const user = await this.prisma.user.findUnique({
|
|
67
|
+
where: { id: payload.userId }
|
|
68
|
+
});
|
|
69
|
+
if (!user) {
|
|
70
|
+
throw new common_1.UnauthorizedException();
|
|
71
|
+
}
|
|
72
|
+
request['user'] = user;
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
extractTokenFromHeader(request) {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
const [type, token] = (_b = (_a = request.headers.authorization) === null || _a === void 0 ? void 0 : _a.split(' ')) !== null && _b !== void 0 ? _b : [];
|
|
81
|
+
return type === 'Bearer' ? token : undefined;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
exports.OptionalAuthGuard = OptionalAuthGuard;
|
|
85
|
+
exports.OptionalAuthGuard = OptionalAuthGuard = __decorate([
|
|
86
|
+
(0, common_1.Injectable)(),
|
|
87
|
+
__metadata("design:paramtypes", [jwt_1.JwtService])
|
|
88
|
+
], OptionalAuthGuard);
|
|
89
|
+
//# sourceMappingURL=auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../../src/auth/auth.guard.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
export interface AuthModuleOptions {
|
|
3
|
+
jwtSecret: string;
|
|
4
|
+
jwtExpiresIn?: string | number;
|
|
5
|
+
}
|
|
6
|
+
export declare class AuthModule {
|
|
7
|
+
static forRoot(options: AuthModuleOptions): DynamicModule;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=auth.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.d.ts","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAG/D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,qBAEa,UAAU;IACrB,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa;CAY1D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var AuthModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
13
|
+
let AuthModule = AuthModule_1 = class AuthModule {
|
|
14
|
+
static forRoot(options) {
|
|
15
|
+
return {
|
|
16
|
+
module: AuthModule_1,
|
|
17
|
+
imports: [
|
|
18
|
+
jwt_1.JwtModule.register({
|
|
19
|
+
secret: options.jwtSecret,
|
|
20
|
+
signOptions: { expiresIn: options.jwtExpiresIn || '7d' },
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
exports: [jwt_1.JwtModule],
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.AuthModule = AuthModule;
|
|
28
|
+
exports.AuthModule = AuthModule = AuthModule_1 = __decorate([
|
|
29
|
+
(0, common_1.Global)(),
|
|
30
|
+
(0, common_1.Module)({})
|
|
31
|
+
], AuthModule);
|
|
32
|
+
//# sourceMappingURL=auth.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,qCAAwC;AASjC,IAAM,UAAU,kBAAhB,MAAM,UAAU;IACrB,MAAM,CAAC,OAAO,CAAC,OAA0B;QACvC,OAAO;YACL,MAAM,EAAE,YAAU;YAClB,OAAO,EAAE;gBACP,eAAS,CAAC,QAAQ,CAAC;oBACjB,MAAM,EAAE,OAAO,CAAC,SAAS;oBACzB,WAAW,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,EAAE;iBACzD,CAAC;aACH;YACD,OAAO,EAAE,CAAC,eAAS,CAAC;SACrB,CAAC;IACJ,CAAC;CACF,CAAA;AAbY,gCAAU;qBAAV,UAAU;IAFtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAatB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.module.d.ts","sourceRoot":"","sources":["../../src/cache/cache.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAK/D,qBAEa,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa;CAgBhD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
var CacheModule_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CacheModule = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const cacheable_1 = require("cacheable");
|
|
16
|
+
const cache_service_1 = require("./cache.service");
|
|
17
|
+
const redis_1 = __importDefault(require("@keyv/redis"));
|
|
18
|
+
let CacheModule = CacheModule_1 = class CacheModule {
|
|
19
|
+
static forRoot(redisUrl) {
|
|
20
|
+
return {
|
|
21
|
+
module: CacheModule_1,
|
|
22
|
+
providers: [
|
|
23
|
+
{
|
|
24
|
+
provide: 'CACHE_INSTANCE',
|
|
25
|
+
useFactory: () => {
|
|
26
|
+
const secondary = new redis_1.default(redisUrl);
|
|
27
|
+
return new cacheable_1.Cacheable({ secondary, ttl: '1h' });
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
cache_service_1.CacheService,
|
|
31
|
+
],
|
|
32
|
+
exports: ['CACHE_INSTANCE', cache_service_1.CacheService],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.CacheModule = CacheModule;
|
|
37
|
+
exports.CacheModule = CacheModule = CacheModule_1 = __decorate([
|
|
38
|
+
(0, common_1.Global)(),
|
|
39
|
+
(0, common_1.Module)({})
|
|
40
|
+
], CacheModule);
|
|
41
|
+
//# sourceMappingURL=cache.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.module.js","sourceRoot":"","sources":["../../src/cache/cache.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,yCAAsC;AACtC,mDAA+C;AAC/C,wDAAoC;AAI7B,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,QAAgB;QAC7B,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,gBAAgB;oBACzB,UAAU,EAAE,GAAG,EAAE;wBACf,MAAM,SAAS,GAAG,IAAI,eAAS,CAAC,QAAQ,CAAC,CAAC;wBAC1C,OAAO,IAAI,qBAAS,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;oBACjD,CAAC;iBACF;gBACD,4BAAY;aACb;YACD,OAAO,EAAE,CAAC,gBAAgB,EAAE,4BAAY,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF,CAAA;AAjBY,kCAAW;sBAAX,WAAW;IAFvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CAiBvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cacheable } from 'cacheable';
|
|
2
|
+
export declare class CacheService<T> {
|
|
3
|
+
private readonly cache;
|
|
4
|
+
constructor(cache: Cacheable);
|
|
5
|
+
get<T>(key: string): Promise<T>;
|
|
6
|
+
set(key: string, value: T, ttl?: number | string): Promise<void>;
|
|
7
|
+
delete(key: string): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cache.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.service.d.ts","sourceRoot":"","sources":["../../src/cache/cache.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,qBACa,YAAY,CAAC,CAAC;IACa,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,SAAS;IAEjE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhE,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGzC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CacheService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const cacheable_1 = require("cacheable");
|
|
18
|
+
let CacheService = class CacheService {
|
|
19
|
+
constructor(cache) {
|
|
20
|
+
this.cache = cache;
|
|
21
|
+
}
|
|
22
|
+
async get(key) {
|
|
23
|
+
return await this.cache.get(key);
|
|
24
|
+
}
|
|
25
|
+
async set(key, value, ttl) {
|
|
26
|
+
await this.cache.set(key, value, ttl);
|
|
27
|
+
}
|
|
28
|
+
async delete(key) {
|
|
29
|
+
await this.cache.delete(key);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.CacheService = CacheService;
|
|
33
|
+
exports.CacheService = CacheService = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__param(0, (0, common_1.Inject)('CACHE_INSTANCE')),
|
|
36
|
+
__metadata("design:paramtypes", [cacheable_1.Cacheable])
|
|
37
|
+
], CacheService);
|
|
38
|
+
//# sourceMappingURL=cache.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.service.js","sourceRoot":"","sources":["../../src/cache/cache.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yCAAsC;AAG/B,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAAuD,KAAgB;QAAhB,UAAK,GAAL,KAAK,CAAW;IAAG,CAAC;IAE3E,KAAK,CAAC,GAAG,CAAI,GAAW;QACtB,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,GAAqB;QACpD,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF,CAAA;AAdY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,gBAAgB,CAAC,CAAA;qCAAyB,qBAAS;GAD5D,YAAY,CAcxB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './auth/auth.guard';
|
|
2
|
+
export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice } from '@prisma/client';
|
|
3
|
+
export * from './auth/auth.guard';
|
|
4
|
+
export * from './auth/auth.module';
|
|
5
|
+
export * from './cache/cache.module';
|
|
6
|
+
export * from './cache/cache.service';
|
|
7
|
+
export * from './prisma/prisma.module';
|
|
8
|
+
export * from './prisma/prisma.service';
|
|
9
|
+
export * from './types';
|
|
10
|
+
export * from './utils';
|
|
11
|
+
export * from './utils/api/endpoints';
|
|
12
|
+
export * from './utils/events';
|
|
13
|
+
export { JwtService } from "@nestjs/jwt";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGrI,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AAGnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AAExC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.JwtService = exports.EventStatus = exports.EventVisibility = exports.EventAccess = exports.UserRole = exports.PrismaClient = void 0;
|
|
18
|
+
__exportStar(require("./auth/auth.guard"), exports);
|
|
19
|
+
var client_1 = require("@prisma/client");
|
|
20
|
+
Object.defineProperty(exports, "PrismaClient", { enumerable: true, get: function () { return client_1.PrismaClient; } });
|
|
21
|
+
Object.defineProperty(exports, "UserRole", { enumerable: true, get: function () { return client_1.UserRole; } });
|
|
22
|
+
Object.defineProperty(exports, "EventAccess", { enumerable: true, get: function () { return client_1.EventAccess; } });
|
|
23
|
+
Object.defineProperty(exports, "EventVisibility", { enumerable: true, get: function () { return client_1.EventVisibility; } });
|
|
24
|
+
Object.defineProperty(exports, "EventStatus", { enumerable: true, get: function () { return client_1.EventStatus; } });
|
|
25
|
+
__exportStar(require("./auth/auth.guard"), exports);
|
|
26
|
+
__exportStar(require("./auth/auth.module"), exports);
|
|
27
|
+
__exportStar(require("./cache/cache.module"), exports);
|
|
28
|
+
__exportStar(require("./cache/cache.service"), exports);
|
|
29
|
+
__exportStar(require("./prisma/prisma.module"), exports);
|
|
30
|
+
__exportStar(require("./prisma/prisma.service"), exports);
|
|
31
|
+
__exportStar(require("./types"), exports);
|
|
32
|
+
__exportStar(require("./utils"), exports);
|
|
33
|
+
__exportStar(require("./utils/api/endpoints"), exports);
|
|
34
|
+
__exportStar(require("./utils/events"), exports);
|
|
35
|
+
var jwt_1 = require("@nestjs/jwt");
|
|
36
|
+
Object.defineProperty(exports, "JwtService", { enumerable: true, get: function () { return jwt_1.JwtService; } });
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yCAAqI;AAA5H,sGAAA,YAAY,OAAA;AAAiB,kGAAA,QAAQ,OAAA;AAAS,qGAAA,WAAW,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,qGAAA,WAAW,OAAA;AAGhG,oDAAkC;AAClC,qDAAmC;AAGnC,uDAAqC;AACrC,wDAAsC;AAGtC,yDAAuC;AACvC,0DAAwC;AAExC,0CAAwB;AACxB,0CAAwB;AACxB,wDAAsC;AACtC,iDAA+B;AAE/B,mCAAyC;AAAhC,iGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.module.d.ts","sourceRoot":"","sources":["../../src/prisma/prisma.module.ts"],"names":[],"mappings":"AAGA,qBAKa,YAAY;CAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PrismaModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const prisma_service_1 = require("./prisma.service");
|
|
12
|
+
let PrismaModule = class PrismaModule {
|
|
13
|
+
};
|
|
14
|
+
exports.PrismaModule = PrismaModule;
|
|
15
|
+
exports.PrismaModule = PrismaModule = __decorate([
|
|
16
|
+
(0, common_1.Global)(),
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [prisma_service_1.PrismaService],
|
|
19
|
+
exports: [prisma_service_1.PrismaService],
|
|
20
|
+
})
|
|
21
|
+
], PrismaModule);
|
|
22
|
+
//# sourceMappingURL=prisma.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.module.js","sourceRoot":"","sources":["../../src/prisma/prisma.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,qDAAiD;AAO1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IALxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { PrismaClient } from '@prisma/client';
|
|
3
|
+
export declare class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
4
|
+
onModuleInit(): Promise<void>;
|
|
5
|
+
onModuleDestroy(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=prisma.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.service.d.ts","sourceRoot":"","sources":["../../src/prisma/prisma.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,eAAe,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBACa,aAAc,SAAQ,YAAa,YAAW,YAAY,EAAE,eAAe;IAChF,YAAY;IAIZ,eAAe;CAGtB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.PrismaService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const client_1 = require("@prisma/client");
|
|
12
|
+
let PrismaService = class PrismaService extends client_1.PrismaClient {
|
|
13
|
+
async onModuleInit() {
|
|
14
|
+
await this.$connect();
|
|
15
|
+
}
|
|
16
|
+
async onModuleDestroy() {
|
|
17
|
+
await this.$disconnect();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.PrismaService = PrismaService;
|
|
21
|
+
exports.PrismaService = PrismaService = __decorate([
|
|
22
|
+
(0, common_1.Injectable)()
|
|
23
|
+
], PrismaService);
|
|
24
|
+
//# sourceMappingURL=prisma.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.service.js","sourceRoot":"","sources":["../../src/prisma/prisma.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,2CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,qBAAY;IAC7C,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AARY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAQzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.service.spec.d.ts","sourceRoot":"","sources":["../../src/prisma/prisma.service.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const testing_1 = require("@nestjs/testing");
|
|
4
|
+
const prisma_service_1 = require("./prisma.service");
|
|
5
|
+
describe('PrismaService', () => {
|
|
6
|
+
let service;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
const module = await testing_1.Test.createTestingModule({
|
|
9
|
+
providers: [prisma_service_1.PrismaService],
|
|
10
|
+
}).compile();
|
|
11
|
+
service = module.get(prisma_service_1.PrismaService);
|
|
12
|
+
});
|
|
13
|
+
it('should be defined', () => {
|
|
14
|
+
expect(service).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=prisma.service.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prisma.service.spec.js","sourceRoot":"","sources":["../../src/prisma/prisma.service.spec.ts"],"names":[],"mappings":";;AAAA,6CAAsD;AACtD,qDAAiD;AAEjD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,OAAsB,CAAC;IAE3B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,MAAM,MAAM,GAAkB,MAAM,cAAI,CAAC,mBAAmB,CAAC;YAC3D,SAAS,EAAE,CAAC,8BAAa,CAAC;SAC3B,CAAC,CAAC,OAAO,EAAE,CAAC;QAEb,OAAO,GAAG,MAAM,CAAC,GAAG,CAAgB,8BAAa,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/utils/api/endpoints.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAoB,CAAA;AAC/C,eAAO,MAAM,kBAAkB,EAAE,MAAyB,CAAA;AAE1D,eAAO,MAAM,aAAa;;;CAGzB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_ENDPOINTS = exports.PROPERTIES_API_URL = exports.CHAT_API_URL = void 0;
|
|
4
|
+
exports.CHAT_API_URL = "api/chats";
|
|
5
|
+
exports.PROPERTIES_API_URL = "api/properties";
|
|
6
|
+
exports.API_ENDPOINTS = {
|
|
7
|
+
CHAT: 'api/chats',
|
|
8
|
+
PROPERTIES_API_URL: 'api/properties',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../../../src/utils/api/endpoints.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAW,WAAW,CAAA;AAClC,QAAA,kBAAkB,GAAW,gBAAgB,CAAA;AAE7C,QAAA,aAAa,GAAG;IAC3B,IAAI,EAAE,WAAW;IACjB,kBAAkB,EAAE,gBAAgB;CACrC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0EACwC,CAAC;AAE1E,eAAO,MAAM,uBAAuB,UASnC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TEMPORARY_EMAIL_DOMAINS = exports.DEFAULT_AVATAR_IMAGE = void 0;
|
|
4
|
+
exports.DEFAULT_AVATAR_IMAGE = 'https://immob-bucket-2.s3.us-east-2.amazonaws.com/pictures/images.png';
|
|
5
|
+
exports.TEMPORARY_EMAIL_DOMAINS = [
|
|
6
|
+
'10minutemail.com',
|
|
7
|
+
'guerrillamail.com',
|
|
8
|
+
'mailinator.com',
|
|
9
|
+
'dispostable.com',
|
|
10
|
+
'yopmail.com',
|
|
11
|
+
'trashmail.com',
|
|
12
|
+
'tempmail.com',
|
|
13
|
+
'temp-mail.org',
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAC/B,uEAAuE,CAAC;AAE7D,QAAA,uBAAuB,GAAG;IACrC,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,aAAa;IACb,eAAe;IACf,cAAc;IACd,eAAe;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;CAKzB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SOCKET_EVENTS = void 0;
|
|
4
|
+
exports.SOCKET_EVENTS = {
|
|
5
|
+
INBOX_OPENED: 'events.sockets.inboxOpened',
|
|
6
|
+
INBOX_CHANGED: 'events.sockets.inboxChanged',
|
|
7
|
+
NEW_MESSAGE: 'events.sockets.newMessage',
|
|
8
|
+
GET_UNREAD_MESSAGES_COUNT: 'events.sockets.getUnreadMessagesCount',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/utils/events.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IACzB,YAAY,EAAE,4BAA4B;IAC1C,aAAa,EAAE,6BAA6B;IAC5C,WAAW,EAAE,2BAA2B;IACxC,yBAAyB,EAAE,uCAAuC;CACrE,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PaginationQuery } from "@/types";
|
|
2
|
+
export declare const getPaginationData: (query: PaginationQuery) => {
|
|
3
|
+
page: number;
|
|
4
|
+
skip: number;
|
|
5
|
+
limit: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const getUserChannel: (userId: string) => string;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,iBAAiB,UAAW,eAAe;;;;CAOvD,CAAC;AAEF,eAAO,MAAM,cAAc,WAAY,MAAM,WAA8B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserChannel = exports.getPaginationData = void 0;
|
|
4
|
+
const getPaginationData = (query) => {
|
|
5
|
+
const page = query.page;
|
|
6
|
+
const PAGE = parseInt(page, 10) || 1;
|
|
7
|
+
const LIMIT = Number(query.limit) || 10;
|
|
8
|
+
const SKIP = (PAGE - 1) * LIMIT;
|
|
9
|
+
return { page: PAGE, skip: SKIP, limit: LIMIT };
|
|
10
|
+
};
|
|
11
|
+
exports.getPaginationData = getPaginationData;
|
|
12
|
+
const getUserChannel = (userId) => `channels-user-${userId}`;
|
|
13
|
+
exports.getUserChannel = getUserChannel;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB,GAAG,CAAC,KAAsB,EAAE,EAAE;IAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,IAAc,CAAC;IAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAEhC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAClD,CAAC,CAAC;AAPW,QAAA,iBAAiB,qBAO5B;AAEK,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,iBAAiB,MAAM,EAAE,CAAC;AAA/D,QAAA,cAAc,kBAAiD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@optimatech88/titomeet-shared-lib",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "nest build",
|
|
9
|
+
"format": "prettier --write \"src/**/*.ts\""
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"description": "",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@faker-js/faker": "^8.4.1",
|
|
23
|
+
"@keyv/redis": "^4.2.0",
|
|
24
|
+
"@nestjs/common": "^10.4.1",
|
|
25
|
+
"@nestjs/config": "^3.2.3",
|
|
26
|
+
"@nestjs/core": "^10.4.1",
|
|
27
|
+
"@nestjs/jwt": "^10.2.0",
|
|
28
|
+
"@prisma/client": "^6.3.1",
|
|
29
|
+
"cacheable": "^1.8.8",
|
|
30
|
+
"express": "^4.19.2",
|
|
31
|
+
"nestjs-seeder": "^0.3.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/express": "^4.17.21",
|
|
35
|
+
"@types/node": "^22.2.0",
|
|
36
|
+
"prettier": "^3.3.3",
|
|
37
|
+
"prisma": "^6.3.1",
|
|
38
|
+
"typescript": "^5.5.4"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
5
|
+
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
6
|
+
|
|
7
|
+
generator client {
|
|
8
|
+
provider = "prisma-client-js"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
datasource db {
|
|
12
|
+
provider = "postgresql"
|
|
13
|
+
url = env("DATABASE_URL")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
enum UserRole {
|
|
18
|
+
SUPER_ADMIN
|
|
19
|
+
ADMIN
|
|
20
|
+
USER
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
model User {
|
|
24
|
+
id String @id @default(cuid())
|
|
25
|
+
username String @unique
|
|
26
|
+
email String @unique
|
|
27
|
+
firstName String
|
|
28
|
+
lastName String
|
|
29
|
+
password String?
|
|
30
|
+
role UserRole @default(USER)
|
|
31
|
+
|
|
32
|
+
createdAt DateTime @default(now())
|
|
33
|
+
updatedAt DateTime @updatedAt
|
|
34
|
+
|
|
35
|
+
accounts Account[]
|
|
36
|
+
messages Message[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
model Account {
|
|
40
|
+
id String @id @default(cuid())
|
|
41
|
+
refreshToken String @unique
|
|
42
|
+
expiresAt DateTime
|
|
43
|
+
user User @relation(fields: [userId], references: [id])
|
|
44
|
+
userId String
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
enum EventAccess {
|
|
48
|
+
FREE
|
|
49
|
+
PAID
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
enum EventVisibility {
|
|
53
|
+
PUBLIC
|
|
54
|
+
PRIVATE
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum EventStatus {
|
|
58
|
+
DRAFT
|
|
59
|
+
PUBLISHED
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
model Event {
|
|
63
|
+
id String @id @default(cuid())
|
|
64
|
+
name String
|
|
65
|
+
description String
|
|
66
|
+
startDate DateTime
|
|
67
|
+
endDate DateTime
|
|
68
|
+
startTime String // Format: "HH:mm"
|
|
69
|
+
endTime String // Format: "HH:mm"
|
|
70
|
+
address String
|
|
71
|
+
capacity Int
|
|
72
|
+
coverPicture String
|
|
73
|
+
tags String[] // Array of tags
|
|
74
|
+
accessType EventAccess @default(FREE)
|
|
75
|
+
visibility EventVisibility @default(PUBLIC)
|
|
76
|
+
prices EventPrice[] // Remove the previous price field
|
|
77
|
+
chat Chat? // Optional one-to-one relation
|
|
78
|
+
status EventStatus @default(DRAFT)
|
|
79
|
+
|
|
80
|
+
createdAt DateTime @default(now())
|
|
81
|
+
updatedAt DateTime @updatedAt
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
model EventPrice {
|
|
85
|
+
id String @id @default(uuid())
|
|
86
|
+
name String // e.g., "Early Bird", "VIP", "Regular"
|
|
87
|
+
amount Float
|
|
88
|
+
description String?
|
|
89
|
+
capacity Int? // Optional capacity per price tier
|
|
90
|
+
event Event @relation(fields: [eventId], references: [id])
|
|
91
|
+
eventId String
|
|
92
|
+
|
|
93
|
+
createdAt DateTime @default(now())
|
|
94
|
+
updatedAt DateTime @updatedAt
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
model Chat {
|
|
98
|
+
id String @id @default(cuid())
|
|
99
|
+
name String
|
|
100
|
+
event Event @relation(fields: [eventId], references: [id])
|
|
101
|
+
eventId String @unique // One-to-one relation with Event
|
|
102
|
+
messages Message[]
|
|
103
|
+
|
|
104
|
+
createdAt DateTime @default(now())
|
|
105
|
+
updatedAt DateTime @updatedAt
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
model Message {
|
|
109
|
+
id String @id @default(cuid())
|
|
110
|
+
content String
|
|
111
|
+
chat Chat @relation(fields: [chatId], references: [id])
|
|
112
|
+
chatId String
|
|
113
|
+
sender User @relation(fields: [senderId], references: [id])
|
|
114
|
+
senderId String
|
|
115
|
+
|
|
116
|
+
createdAt DateTime @default(now())
|
|
117
|
+
updatedAt DateTime @updatedAt
|
|
118
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CanActivate,
|
|
3
|
+
ExecutionContext,
|
|
4
|
+
Injectable,
|
|
5
|
+
UnauthorizedException,
|
|
6
|
+
} from '@nestjs/common';
|
|
7
|
+
import { JwtService } from '@nestjs/jwt';
|
|
8
|
+
import { PrismaClient } from '@prisma/client';
|
|
9
|
+
import { Request } from 'express';
|
|
10
|
+
import { IncomingHttpHeaders } from 'http';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class AuthGuard implements CanActivate {
|
|
14
|
+
private prisma: PrismaClient;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
private jwtService: JwtService,
|
|
18
|
+
) {
|
|
19
|
+
this.prisma = new PrismaClient();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
23
|
+
const request = context.switchToHttp().getRequest();
|
|
24
|
+
const token = this.extractTokenFromHeader(request);
|
|
25
|
+
if (!token) {
|
|
26
|
+
throw new UnauthorizedException();
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const payload = (await this.jwtService.verifyAsync(token)) as {
|
|
30
|
+
userId: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const user = await this.prisma.user.findUnique({
|
|
34
|
+
where: { id: payload.userId }
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!user) {
|
|
38
|
+
throw new UnauthorizedException();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
request['user'] = user;
|
|
42
|
+
} catch {
|
|
43
|
+
throw new UnauthorizedException();
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
|
|
49
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
50
|
+
return type === 'Bearer' ? token : undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Injectable()
|
|
55
|
+
export class OptionalAuthGuard implements CanActivate {
|
|
56
|
+
private prisma: PrismaClient;
|
|
57
|
+
|
|
58
|
+
constructor(
|
|
59
|
+
private jwtService: JwtService,
|
|
60
|
+
) {
|
|
61
|
+
this.prisma = new PrismaClient();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async canActivate(context: ExecutionContext): Promise<boolean> {
|
|
65
|
+
const request = context.switchToHttp().getRequest();
|
|
66
|
+
const token = this.extractTokenFromHeader(request);
|
|
67
|
+
if (!token) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const payload = (await this.jwtService.verifyAsync(token)) as {
|
|
72
|
+
userId: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const user = await this.prisma.user.findUnique({
|
|
76
|
+
where: { id: payload.userId }
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
if (!user) {
|
|
80
|
+
throw new UnauthorizedException();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
request['user'] = user;
|
|
84
|
+
|
|
85
|
+
// Continue without setting user
|
|
86
|
+
} catch {
|
|
87
|
+
// Continue without setting user
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private extractTokenFromHeader(request: Request & { headers: IncomingHttpHeaders }): string | undefined {
|
|
93
|
+
const [type, token] = request.headers.authorization?.split(' ') ?? [];
|
|
94
|
+
return type === 'Bearer' ? token : undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Module, DynamicModule, Global } from '@nestjs/common';
|
|
2
|
+
import { JwtModule } from '@nestjs/jwt';
|
|
3
|
+
|
|
4
|
+
export interface AuthModuleOptions {
|
|
5
|
+
jwtSecret: string;
|
|
6
|
+
jwtExpiresIn?: string | number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@Global()
|
|
10
|
+
@Module({})
|
|
11
|
+
export class AuthModule {
|
|
12
|
+
static forRoot(options: AuthModuleOptions): DynamicModule {
|
|
13
|
+
return {
|
|
14
|
+
module: AuthModule,
|
|
15
|
+
imports: [
|
|
16
|
+
JwtModule.register({
|
|
17
|
+
secret: options.jwtSecret,
|
|
18
|
+
signOptions: { expiresIn: options.jwtExpiresIn || '7d' },
|
|
19
|
+
}),
|
|
20
|
+
],
|
|
21
|
+
exports: [JwtModule],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Module, DynamicModule, Global } from '@nestjs/common';
|
|
2
|
+
import { Cacheable } from 'cacheable';
|
|
3
|
+
import { CacheService } from './cache.service';
|
|
4
|
+
import KeyvRedis from '@keyv/redis';
|
|
5
|
+
|
|
6
|
+
@Global()
|
|
7
|
+
@Module({})
|
|
8
|
+
export class CacheModule {
|
|
9
|
+
static forRoot(redisUrl: string): DynamicModule {
|
|
10
|
+
return {
|
|
11
|
+
module: CacheModule,
|
|
12
|
+
providers: [
|
|
13
|
+
{
|
|
14
|
+
provide: 'CACHE_INSTANCE',
|
|
15
|
+
useFactory: () => {
|
|
16
|
+
const secondary = new KeyvRedis(redisUrl);
|
|
17
|
+
return new Cacheable({ secondary, ttl: '1h' });
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
CacheService,
|
|
21
|
+
],
|
|
22
|
+
exports: ['CACHE_INSTANCE', CacheService],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
|
+
import { Cacheable } from 'cacheable';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class CacheService<T> {
|
|
6
|
+
constructor(@Inject('CACHE_INSTANCE') private readonly cache: Cacheable) {}
|
|
7
|
+
|
|
8
|
+
async get<T>(key: string): Promise<T> {
|
|
9
|
+
return await this.cache.get(key);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async set(key: string, value: T, ttl?: number | string): Promise<void> {
|
|
13
|
+
await this.cache.set(key, value, ttl);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async delete(key: string): Promise<void> {
|
|
17
|
+
await this.cache.delete(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './auth/auth.guard';
|
|
2
|
+
export { PrismaClient, User, Account, UserRole, Event, EventAccess, EventVisibility, EventStatus, EventPrice } from '@prisma/client';
|
|
3
|
+
|
|
4
|
+
//auth
|
|
5
|
+
export * from './auth/auth.guard';
|
|
6
|
+
export * from './auth/auth.module';
|
|
7
|
+
|
|
8
|
+
//cache
|
|
9
|
+
export * from './cache/cache.module';
|
|
10
|
+
export * from './cache/cache.service';
|
|
11
|
+
|
|
12
|
+
//prisma
|
|
13
|
+
export * from './prisma/prisma.module';
|
|
14
|
+
export * from './prisma/prisma.service';
|
|
15
|
+
|
|
16
|
+
export * from './types';
|
|
17
|
+
export * from './utils';
|
|
18
|
+
export * from './utils/api/endpoints';
|
|
19
|
+
export * from './utils/events';
|
|
20
|
+
|
|
21
|
+
export { JwtService } from "@nestjs/jwt";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { PrismaClient } from '@prisma/client';
|
|
3
|
+
|
|
4
|
+
@Injectable()
|
|
5
|
+
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
|
6
|
+
async onModuleInit() {
|
|
7
|
+
await this.$connect();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async onModuleDestroy() {
|
|
11
|
+
await this.$disconnect();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const DEFAULT_AVATAR_IMAGE =
|
|
2
|
+
'https://immob-bucket-2.s3.us-east-2.amazonaws.com/pictures/images.png';
|
|
3
|
+
|
|
4
|
+
export const TEMPORARY_EMAIL_DOMAINS = [
|
|
5
|
+
'10minutemail.com',
|
|
6
|
+
'guerrillamail.com',
|
|
7
|
+
'mailinator.com',
|
|
8
|
+
'dispostable.com',
|
|
9
|
+
'yopmail.com',
|
|
10
|
+
'trashmail.com',
|
|
11
|
+
'tempmail.com',
|
|
12
|
+
'temp-mail.org',
|
|
13
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PaginationQuery } from "@/types";
|
|
2
|
+
|
|
3
|
+
export const getPaginationData = (query: PaginationQuery) => {
|
|
4
|
+
const page = query.page as string;
|
|
5
|
+
const PAGE = parseInt(page, 10) || 1;
|
|
6
|
+
const LIMIT = Number(query.limit) || 10;
|
|
7
|
+
const SKIP = (PAGE - 1) * LIMIT;
|
|
8
|
+
|
|
9
|
+
return { page: PAGE, skip: SKIP, limit: LIMIT };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const getUserChannel = (userId: string) => `channels-user-${userId}`;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"removeComments": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
7
|
+
"experimentalDecorators": true,
|
|
8
|
+
"target": "ES2017",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"baseUrl": ".",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@/*": ["./src/*"]
|
|
15
|
+
},
|
|
16
|
+
"strict": true,
|
|
17
|
+
"strictNullChecks": false,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"declarationMap": true,
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*.ts"],
|
|
23
|
+
"exclude": ["node_modules", "dist"]
|
|
24
|
+
}
|