my-typescript-library-rahul52us 1.2.0 → 1.2.1
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.
|
@@ -24,19 +24,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
-
;
|
|
28
27
|
const TokensSchema = new mongoose_1.default.Schema({
|
|
29
28
|
userId: {
|
|
30
29
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
31
|
-
required: true
|
|
30
|
+
required: true,
|
|
32
31
|
},
|
|
33
32
|
type: {
|
|
34
|
-
type: String
|
|
33
|
+
type: String,
|
|
34
|
+
required: true,
|
|
35
35
|
},
|
|
36
36
|
created_at: {
|
|
37
37
|
type: Date,
|
|
38
|
-
default: Date.now
|
|
39
|
-
}
|
|
38
|
+
default: Date.now,
|
|
39
|
+
},
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
// Safe way to dynamically fetch or initialize the model
|
|
42
|
+
let TokenModel = null;
|
|
43
|
+
console.log(mongoose_1.default.models);
|
|
44
|
+
if (mongoose_1.default.models.Token) {
|
|
45
|
+
console.log("Token model already exists.");
|
|
46
|
+
TokenModel = mongoose_1.default.models.Token;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log("Creating Token model fallback.");
|
|
50
|
+
TokenModel = mongoose_1.default.model('Token', TokensSchema);
|
|
51
|
+
}
|
|
52
|
+
exports.default = TokenModel;
|
|
42
53
|
//# sourceMappingURL=tokens.schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.schema.js","sourceRoot":"","sources":["../../../src/repository/schemas/tokens.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;
|
|
1
|
+
{"version":3,"file":"tokens.schema.js","sourceRoot":"","sources":["../../../src/repository/schemas/tokens.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsD;AAQtD,MAAM,YAAY,GAAW,IAAI,kBAAQ,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE;QACN,IAAI,EAAE,iBAAM,CAAC,KAAK,CAAC,QAAQ;QAC3B,QAAQ,EAAE,IAAI;KACf;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;KACf;IACD,UAAU,EAAE;QACV,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI,CAAC,GAAG;KAClB;CACF,CAAC,CAAC;AAEH,wDAAwD;AACxD,IAAI,UAAU,GAAS,IAAI,CAAC;AAE5B,OAAO,CAAC,GAAG,CAAC,kBAAQ,CAAC,MAAM,CAAC,CAAA;AAE5B,IAAI,kBAAQ,CAAC,MAAM,CAAC,KAAK,EAAE;IACzB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC3C,UAAU,GAAG,kBAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;CACpC;KAAM;IACL,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,UAAU,GAAG,kBAAQ,CAAC,KAAK,CAAW,OAAO,EAAE,YAAY,CAAC,CAAC;CAC9D;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
userId: Schema.Types.ObjectId;
|
|
4
|
-
type: string;
|
|
5
|
-
created_at: Date;
|
|
6
|
-
}
|
|
7
|
-
declare const _default: mongoose.PassportLocalModel<ISession>;
|
|
8
|
-
export default _default;
|
|
1
|
+
declare let TokenModel: any;
|
|
2
|
+
export default TokenModel;
|
package/package.json
CHANGED
|
@@ -1,24 +1,39 @@
|
|
|
1
1
|
import mongoose, { Schema, Document } from "mongoose";
|
|
2
2
|
|
|
3
3
|
interface ISession extends Document {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
userId: Schema.Types.ObjectId;
|
|
5
|
+
type: string;
|
|
6
|
+
created_at: Date;
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
const TokensSchema: Schema = new mongoose.Schema({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
userId: {
|
|
11
|
+
type: Schema.Types.ObjectId,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
type: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
created_at: {
|
|
19
|
+
type: Date,
|
|
20
|
+
default: Date.now,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Safe way to dynamically fetch or initialize the model
|
|
25
|
+
let TokenModel : any = null;
|
|
26
|
+
|
|
27
|
+
console.log(mongoose.models)
|
|
28
|
+
|
|
29
|
+
if (mongoose.models.Token) {
|
|
30
|
+
console.log("Token model already exists.");
|
|
31
|
+
TokenModel = mongoose.models.Token;
|
|
32
|
+
} else {
|
|
33
|
+
console.log("Creating Token model fallback.");
|
|
34
|
+
TokenModel = mongoose.model<ISession>('Token', TokensSchema);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default TokenModel;
|
|
38
|
+
|
|
39
|
+
|