@medyll/idae-api 0.124.0 → 0.126.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/README.md +15 -14
- package/dist/server/IdaeApi.d.ts +1 -1
- package/dist/server/IdaeApi.js +0 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -72,7 +72,6 @@ idaeApi.setOptions({
|
|
|
72
72
|
enableAuth: true, // or false
|
|
73
73
|
jwtSecret: 'your-secret-key',
|
|
74
74
|
tokenExpiration: '1h',
|
|
75
|
-
onInUse: 'reboot', // behavior if the port is already in use
|
|
76
75
|
routes: customRoutes // optional
|
|
77
76
|
});
|
|
78
77
|
|
|
@@ -140,19 +139,7 @@ const client = new IdaeApiClient();
|
|
|
140
139
|
- `db(dbName)` : Select a database (returns an object with `collection` and `getCollections`)
|
|
141
140
|
- `collection(collectionName, dbName?)` : Select a collection (optionally in a given database)
|
|
142
141
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
All the following methods are available via the `IdaeApiClientCollection` object:
|
|
146
|
-
|
|
147
|
-
- `findAll(params?)` : List all documents (with filters, sorting, pagination)
|
|
148
|
-
- `findById(id)` : Get a document by its ID
|
|
149
|
-
- `findOne(params)` : Get a document by a filter (inherited from idae-db)
|
|
150
|
-
- `create(body)` : Create a document
|
|
151
|
-
- `update(id, body)` : Update a document
|
|
152
|
-
- `deleteById(id)` : Delete a document by its ID
|
|
153
|
-
- `deleteManyByQuery(params)` : Delete multiple documents by filter
|
|
154
|
-
|
|
155
|
-
#### Event/Hook Management (inherited from idae-db)
|
|
142
|
+
### Event/Hook Management (inherited from idae-db)
|
|
156
143
|
|
|
157
144
|
You can register hooks on all operations:
|
|
158
145
|
|
|
@@ -167,6 +154,20 @@ usersCollection.registerEvents({
|
|
|
167
154
|
},
|
|
168
155
|
// ... same for update, create, etc.
|
|
169
156
|
});
|
|
157
|
+
|
|
158
|
+
#### CRUD Operations on a Collection
|
|
159
|
+
|
|
160
|
+
All the following methods are available via the `IdaeApiClientCollection` object:
|
|
161
|
+
|
|
162
|
+
- `findAll(params?)` : List all documents (with filters, sorting, pagination)
|
|
163
|
+
- `findById(id)` : Get a document by its ID
|
|
164
|
+
- `findOne(params)` : Get a document by a filter (inherited from idae-db)
|
|
165
|
+
- `create(body)` : Create a document
|
|
166
|
+
- `update(id, body)` : Update a document
|
|
167
|
+
- `deleteById(id)` : Delete a document by its ID
|
|
168
|
+
- `deleteManyByQuery(params)` : Delete multiple documents by filter
|
|
169
|
+
|
|
170
|
+
#
|
|
170
171
|
```
|
|
171
172
|
|
|
172
173
|
### Usage Examples
|
package/dist/server/IdaeApi.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { RouteManager } from "./engine/routeManager.js";
|
|
|
5
5
|
interface IdaeApiOptions {
|
|
6
6
|
port?: number;
|
|
7
7
|
routes?: RouteDefinition[];
|
|
8
|
-
onInUse?: "
|
|
8
|
+
onInUse?: "fail" | "replace";
|
|
9
9
|
enableAuth?: boolean;
|
|
10
10
|
jwtSecret?: string;
|
|
11
11
|
tokenExpiration?: string;
|
package/dist/server/IdaeApi.js
CHANGED
|
@@ -124,13 +124,6 @@ class IdaeApi {
|
|
|
124
124
|
if (error.code === "EADDRINUSE") {
|
|
125
125
|
console.error(`Port ${__classPrivateFieldGet(this, _IdaeApi_idaeApiOptions, "f").port} is already in use.`);
|
|
126
126
|
switch (__classPrivateFieldGet(this, _IdaeApi_idaeApiOptions, "f").onInUse) {
|
|
127
|
-
case "reboot":
|
|
128
|
-
console.log("Rebooting server...");
|
|
129
|
-
setTimeout(() => {
|
|
130
|
-
this.stop();
|
|
131
|
-
this.start();
|
|
132
|
-
}, 1000);
|
|
133
|
-
break;
|
|
134
127
|
case "replace":
|
|
135
128
|
console.log("Replacing existing server...");
|
|
136
129
|
this.stop();
|
|
@@ -201,7 +194,6 @@ apiServer.setOptions({
|
|
|
201
194
|
enableAuth: true,
|
|
202
195
|
jwtSecret: 'your_jwt_secret',
|
|
203
196
|
tokenExpiration: '15m',
|
|
204
|
-
onInUse: 'reboot'
|
|
205
197
|
});
|
|
206
198
|
|
|
207
199
|
// Start the server
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medyll/idae-api",
|
|
3
3
|
"scope": "@medyll",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.126.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"description": "A flexible and extensible API framework for Node.js, designed to work with multiple database types and configurations. It features a modular architecture, dynamic database connection management, and a flexible routing system. The framework supports TypeScript for improved robustness and maintainability.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"sequelize": "^6.37.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@medyll/idae-db": "^0.
|
|
49
|
+
"@medyll/idae-db": "^0.94.0",
|
|
50
50
|
"@medyll/idae-prettier-config": "next",
|
|
51
51
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
52
52
|
"@sveltejs/kit": "^2.21.2",
|