tsledge-core 0.1.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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/dist/app.d.ts +14 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/bin/repl.js +1181 -0
  6. package/dist/bin/repl.js.map +7 -0
  7. package/dist/core/http.d.ts +15 -0
  8. package/dist/core/http.d.ts.map +1 -0
  9. package/dist/core/index.d.ts +4 -0
  10. package/dist/core/index.d.ts.map +1 -0
  11. package/dist/core/query-builder.d.ts +96 -0
  12. package/dist/core/query-builder.d.ts.map +1 -0
  13. package/dist/core/types.d.ts +58 -0
  14. package/dist/core/types.d.ts.map +1 -0
  15. package/dist/db/index.d.ts +2 -0
  16. package/dist/db/index.d.ts.map +1 -0
  17. package/dist/db/mongodb.d.ts +6 -0
  18. package/dist/db/mongodb.d.ts.map +1 -0
  19. package/dist/exitCodes.d.ts +4 -0
  20. package/dist/exitCodes.d.ts.map +1 -0
  21. package/dist/fluent-interface/fluent-pattern-handler.d.ts +60 -0
  22. package/dist/fluent-interface/fluent-pattern-handler.d.ts.map +1 -0
  23. package/dist/fluent-interface/index.d.ts +3 -0
  24. package/dist/fluent-interface/index.d.ts.map +1 -0
  25. package/dist/fluent-interface/types.d.ts +26 -0
  26. package/dist/fluent-interface/types.d.ts.map +1 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/middleware/authentication/index.d.ts +4 -0
  30. package/dist/middleware/authentication/index.d.ts.map +1 -0
  31. package/dist/middleware/authentication/session.d.ts +63 -0
  32. package/dist/middleware/authentication/session.d.ts.map +1 -0
  33. package/dist/middleware/authentication/types.d.ts +34 -0
  34. package/dist/middleware/authentication/types.d.ts.map +1 -0
  35. package/dist/middleware/authentication/validation.d.ts +64 -0
  36. package/dist/middleware/authentication/validation.d.ts.map +1 -0
  37. package/dist/middleware/file-storage.d.ts +4 -0
  38. package/dist/middleware/file-storage.d.ts.map +1 -0
  39. package/dist/middleware/index.d.ts +5 -0
  40. package/dist/middleware/index.d.ts.map +1 -0
  41. package/dist/middleware/logger.d.ts +4 -0
  42. package/dist/middleware/logger.d.ts.map +1 -0
  43. package/dist/middleware/types.d.ts +2 -0
  44. package/dist/middleware/types.d.ts.map +1 -0
  45. package/dist/models/auth-token-blocklist.d.ts +13 -0
  46. package/dist/models/auth-token-blocklist.d.ts.map +1 -0
  47. package/dist/models/auth-user.d.ts +15 -0
  48. package/dist/models/auth-user.d.ts.map +1 -0
  49. package/dist/models/index.d.ts +3 -0
  50. package/dist/models/index.d.ts.map +1 -0
  51. package/dist/src/index.js +1159 -0
  52. package/dist/src/index.js.map +7 -0
  53. package/dist/tests/main.js +1111 -0
  54. package/dist/tests/main.js.map +7 -0
  55. package/dist/types.d.ts +26 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/utils/date.d.ts +2 -0
  58. package/dist/utils/date.d.ts.map +1 -0
  59. package/dist/utils/encoding.d.ts +13 -0
  60. package/dist/utils/encoding.d.ts.map +1 -0
  61. package/dist/utils/env.d.ts +9 -0
  62. package/dist/utils/env.d.ts.map +1 -0
  63. package/dist/utils/index.d.ts +6 -0
  64. package/dist/utils/index.d.ts.map +1 -0
  65. package/dist/utils/mongo-relation.d.ts +21 -0
  66. package/dist/utils/mongo-relation.d.ts.map +1 -0
  67. package/dist/utils/validation.d.ts +59 -0
  68. package/dist/utils/validation.d.ts.map +1 -0
  69. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Niklas Wockenfuß
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # TSledgeCore
2
+
3
+ A TypeScript playground and toolkit for web development.
4
+
5
+ ![thumbnail](docs/res/thumbnail.png)
6
+
7
+ ## Installation
8
+
9
+ This project requires the following dependencies:
10
+
11
+ ```bash
12
+ npm install mongoose@9.2.1
13
+ ```
14
+
15
+ ## Tutorials
16
+
17
+ ### Create Mongoose Collection
18
+
19
+ ```typescript
20
+ import mongoose from "mongoose";
21
+
22
+ export interface User {
23
+ ofUserGroup: mongoose.Types.ObjectId;
24
+ username: string;
25
+ email: string;
26
+ secretHash: string;
27
+ }
28
+
29
+ export type UserDocument = User & mongoose.Document;
30
+
31
+ const UserSchema = new mongoose.Schema<UserDocument>(
32
+ {
33
+ ofUserGroup: {
34
+ type: mongoose.Schema.Types.ObjectId,
35
+ ref: 'UserGroup',
36
+ alias: 'userGroup',
37
+ required: true,
38
+ },
39
+ username: { type: String, unique: true, required: true, filter: true }, // 'filter' is a fluent-pattern-handler feature
40
+ email: { type: String, unique: true, required: true, select: false },
41
+ secretHash: { type: String, select: false },
42
+ },
43
+ { collection: 'users', timestamps: true }
44
+ );
45
+
46
+ UserSchema.set('toJSON', {
47
+ transform: (_doc, ret: any) => {
48
+ delete ret.secretHash;
49
+ return ret;
50
+ }
51
+ });
52
+
53
+ export const UserModel = mongoose.model<UserDocument>('User', UserSchema);
54
+ ```
55
+
56
+ ### Using FluentInterface
57
+
58
+ ```typescript
59
+ router.get(
60
+ '/',
61
+ async (
62
+ req: FluentExpressRequest,
63
+ res: FluentExpressResponse
64
+ ) => {
65
+ try {
66
+ let queryBuilder = new QueryBuilder({
67
+ model: UserModel
68
+ });
69
+ let codec = await FluentPatternHandler.getInstance().exec({
70
+ req,
71
+ res,
72
+ queryBuilder
73
+ });
74
+
75
+ codec.sendToClient(res);
76
+ } catch (e) {
77
+ console.log(e);
78
+ res.status(500).json();
79
+ }
80
+ }
81
+ );
82
+ ```
83
+
84
+ ### API Examples
85
+
86
+ #### Search across all filter fields
87
+
88
+ ```http
89
+ GET /?filter=john_doe&limit=10&offset=5
90
+ ```
91
+
92
+ Search in all fields marked with `filter: true` option.
93
+
94
+ #### Search in a specific field
95
+
96
+ ```http
97
+ GET /?username=john_doe&limit=10&offset=5
98
+ ```
99
+
100
+ Search only in the `username` field.
package/dist/app.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import * as core from 'express-serve-static-core';
2
+ /**
3
+ * Creates and configures an Express application.
4
+ * @example
5
+ * ```typescript
6
+ * const app = tsledge.createApp();
7
+ * app.listen(PORT, () => {
8
+ * console.log(`Server running on port ${PORT}`);
9
+ * });
10
+ * ```
11
+ * @returns {core.Express} The configured Express application.
12
+ */
13
+ export declare function createApp(): core.Express;
14
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,2BAA2B,CAAC;AAGlD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,IAAI,IAAI,CAAC,OAAO,CASxC"}