@flowerforce/flowerbase 1.0.1-beta.11 → 1.0.1-beta.13

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 CHANGED
@@ -2,17 +2,286 @@
2
2
 
3
3
  > **A serverless-native MongoDB package designed for modern cloud applications. Lightweight. Fast. Pay-as-you-go.**
4
4
 
5
- ---
6
5
 
7
- ## ✨ Features
8
6
 
9
- - 🚀 **Serverless-ready** built from the ground up to work in serverless environments like AWS Lambda.
10
- - 🔄 **MongoDB-compatible API** — drop-in replacement for most common MongoDB queries and models.
11
- - 🔐 **Secure by default** — Strict access rules.
7
+ ## 🗂️ MongoDB Atlas Migration Guide
12
8
 
13
- ---
9
+ This guide walks you through the process of setting up a Node.js backend application and integrating the `@flowerforce/flowerbase` library to connect with MongoDB Atlas.
14
10
 
15
- ## 📦 Installation
11
+ ## 📁 1. Project Setup
12
+
13
+ ### ✅ Step 1.1 – Initialize a Node.js Application
14
+
15
+ Create a new project directory and initialize it with npm:
16
+
17
+ ```bash
18
+ mkdir my-app
19
+ cd my-app
20
+ npm init -y
21
+ ```
22
+
23
+ ### ✅ Step 1.2 – Install Dependencies
24
+ Install the `@flowerforce/flowerbase` library, which provides the tools required for managing your data with MongoDB Atlas:
25
+
26
+ ```bash
27
+ npm install @flowerforce/flowerbase
28
+ ```
29
+
30
+ ## 🏗️ 2. Create the Project Structure
31
+ Inside your project root, create the main source directory:
32
+
33
+ ```bash
34
+ mkdir src
35
+ ```
36
+ Within the src folder, add a new file named index.ts:
37
+
38
+ ```bash
39
+ touch src/index.ts
40
+ ```
41
+
42
+ ## 🌿 3. Environment Variables
43
+ Ensure the following environment variables are set in your .env file or deployment environment:
44
+
45
+ ```env
46
+ PROJECT_ID=your-project-id
47
+ PORT=3000
48
+ DB_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/dbname
49
+ APP_SECRET=your-jwt-secret
50
+ HOST=0.0.0.0
51
+ ```
52
+
53
+ #### 🔹 projectId
54
+ - `Purpose`: Serves as a unique identifier for your project within the Flowerbase ecosystem.
55
+
56
+ - `Requirement`: This value is user-defined; you must create a unique string to identify your project.
57
+
58
+ > Example:
59
+ ```env
60
+ PROJECT_ID=my-cool-app-5678
61
+ ```
62
+
63
+ #### 🔹 jwtSecret
64
+ - `Purpose`: Used as the secret key for signing and verifying JSON Web Tokens (JWTs) in your application, ensuring secure authentication.
65
+
66
+ - `Requirement`: This is a user-defined secret; you must generate a secure, random string.
67
+
68
+ > Example:
69
+ ```env
70
+ APP_SECRET=supersecurejwtsecret987
71
+ ```
72
+
73
+ 🛡️ Note: Never commit .env files to source control. Use a .gitignore file to exclude it.
74
+
75
+
76
+ ## 🧩 4. Initialize Flowerbase
77
+ In your index.ts file, import the initialize function from the `@flowerforce/flowerbase` package and invoke it:
78
+
79
+ ```ts
80
+ // src/index.ts
81
+
82
+ import { initialize } from '@flowerforc/flowerbase';
83
+
84
+ initialize({
85
+ projectId: process.env.PROJECT_ID,
86
+ port: Number(process.env.PORT),
87
+ mongodbUrl: process.env.DB_CONNECTION_STRING,
88
+ jwtSecret: process.env.APP_SECRET,
89
+ host: process.env.HOST
90
+ });
91
+ ```
92
+
93
+ This initializes the Flowerbase integration, connecting your application to MongoDB Atlas.
94
+
95
+ ## 🛠️ 5. Server Configuration – Authentication, Rules, and Functions
96
+ After setting up the base Flowerbase integration, you can now configure advanced features to control how your backend behaves.
97
+
98
+ ### 📁 Suggested Folder Structure
99
+
100
+ ```code
101
+ 📁 my-app/
102
+ |
103
+ ├── 📁 src/
104
+ | |
105
+ │ ├── 📄 index.ts
106
+ | |
107
+ │ ├── 📁 auth/
108
+ | | |
109
+ │ │ └── 📄 custom_user_data.json
110
+ | | |
111
+ │ │ └── 📄 providers.json
112
+ | |
113
+ │ ├── 📁 data_sources/
114
+ | | |
115
+ │ │ └── 📁 mongodb-atlas/
116
+ | | |
117
+ │ │ └── 📁 your_db_name/
118
+ | | |
119
+ │ │ └── 📁 collection1/
120
+ | | | |
121
+ │ │ | └── 📄 rules.json
122
+ │ │ |
123
+ │ │ └── 📁 collection2/
124
+ | | |
125
+ │ │ └── 📄 rules.json
126
+ │ │
127
+ │ ├── 📁 functions/
128
+ │ │ |
129
+ │ │ └── 📄 exampleFunction.ts
130
+ │ │ |
131
+ │ │ └── 📄 config.json
132
+ │ │
133
+ │ ├── 📁 triggers/
134
+ │ │ |
135
+ │ │ └── 📄 trigger1.json
136
+ │ │ |
137
+ │ │ └── 📄 trigger2.json
138
+ │ │
139
+ │ ├── 📁 http_endpoints/
140
+ │ │ |
141
+ │ │ └── 📄 config.json
142
+ │ │
143
+ └── 📄 .env
144
+ ```
145
+
146
+ If your previous project followed the MongoDB Realm scaffold, you're in luck:
147
+ Flowerbase was designed to mirror Realm’s structure, making migration simple and straightforward.
148
+
149
+ ## 🚀 6. Build & Deploy the Server
150
+
151
+ Once your migration is complete, it’s time to build and deploy the backend so it can be accessed by your frontend or external clients.
152
+
153
+ ### 🔧 Build the App
154
+
155
+ If you're using TypeScript:
156
+
157
+ ```bash
158
+ npx tsc
159
+ ```
160
+
161
+ Or if you're using a bundler like esbuild:
162
+
163
+ ```bash
164
+ npx esbuild src/index.ts --bundle --outfile=dist/index.js
165
+ ```
166
+
167
+ You can deploy the application using any Node.js-compatible platform.
168
+ Once deployed, you'll receive a public URL (e.g. https://your-app-name.up.example.app).
169
+
170
+ >This URL should be used as the base URL in your frontend application, as explained in the next section.
171
+
172
+ ## 🌐 7. Frontend Setup – Realm SDK in React (Example)
173
+
174
+ You can use the official `realm-web` SDK to integrate MongoDB Realm into a React application.
175
+ This serves as a sample setup — similar logic can be applied using other official Realm SDKs **(e.g. React Native, Node, or Flutter)**.
176
+
177
+ ### 📦 Install Realm SDK
16
178
 
17
179
  ```bash
18
- npm install flowerbase
180
+ npm install realm-web
181
+ ```
182
+
183
+ ### ⚙️ Configure Realm in React
184
+
185
+ Create a file to initialize and export the Realm App instance:
186
+
187
+ ```ts
188
+ // src/realm/realmApp.ts
189
+
190
+ import * as Realm from "realm-web";
191
+
192
+ // Replace with your actual Realm App ID and your deployed backend URL
193
+ const app = new Realm.App({
194
+ id: "your-realm-app-id", // e.g., my-app-abcde
195
+ baseUrl: "https://your-deployed-backend-url.com" // e.g., https://your-app-name.up.example.app
196
+ });
197
+
198
+ export default app;
199
+
200
+ ```
201
+
202
+ >🔗 The baseUrl should point to the backend URL you deployed earlier using Flowerbase.
203
+ This tells the frontend SDK where to send authentication and data requests.
204
+
205
+
206
+
207
+ ## 🔐 8. Authentication – Local Email/Password (User-Pass)
208
+
209
+ The authentication system in `@flowerforce/flowerbase` reimplements the classic **email/password** login method (called local-userpass), similar to the one used by MongoDB Realm.
210
+
211
+ ### 🧱 Compatibility with Realm
212
+
213
+ In MongoDB Atlas (Realm), users were stored in a separate internal authentication database, not directly accessible via the standard MongoDB collections.
214
+
215
+ However, with Flowerbase:
216
+
217
+ - Users are stored directly in a MongoDB collection (by default named auth_users), but this can be customized in the server project via a JSON configuration file, as shown later in this guide.
218
+
219
+ - The document structure remains identical to the previous Realm implementation
220
+
221
+ - No changes are required to migrate the user data — existing user documents will continue to work as-is.
222
+ However, all users will be required to reset their passwords since it is not possible to extract passwords from the old MongoDB authentication system.
223
+
224
+ ### ✅ Supported Auth Method
225
+
226
+ The only authentication mode currently re-implemented in `@flowerforce/flowerbase` is:
227
+
228
+ - Local Email/Password (local-userpass)
229
+
230
+ > Other methods (OAuth, API key, anonymous, etc.) are not supported yet.
231
+
232
+ #### Example user:
233
+ ```json
234
+ {
235
+ "_id": {
236
+ "$oid": "example-user-id"
237
+ },
238
+ "email": "myuser@flowerbase.example",
239
+ "password": "your-encrypted-password",
240
+ "status": "confirmed",
241
+ "identities": [
242
+ {
243
+ "id": "example-id",
244
+ "provider_type": "local-userpass",
245
+ "provider_id": "example-provider-id",
246
+ "provider_data": {
247
+ "email": "myuser@flowerbase.example",
248
+ }
249
+ }
250
+ ]
251
+ }
252
+ ```
253
+
254
+ You can specify the MongoDB collection used to store authentication users by configuring the `auth_collection` field inside the `auth/providers.json` file.
255
+
256
+ #### 📁 auth/providers.json
257
+ Example
258
+ ```json
259
+ {
260
+ "api-key": {
261
+ "name": "api-key",
262
+ "type": "api-key",
263
+ "disabled": true
264
+ },
265
+ "local-userpass": {
266
+ "name": "local-userpass",
267
+ "type": "local-userpass",
268
+ "disabled": false,
269
+ "auth_collection": "my-users-collection" //custom collection name
270
+ "config": {
271
+ "autoConfirm": true,
272
+ "resetPasswordSubject": "reset",
273
+ "resetPasswordUrl": "https://my.app.url/password-reset",
274
+ "runConfirmationFunction": false
275
+ }
276
+ }
277
+ }
278
+
279
+ ```
280
+ #### 🧠 Summary
281
+ | Feature | Status |
282
+ |--------------------------|-----------------------------------------|
283
+ | Realm-compatible schema | ✅ Supported (unchanged) |
284
+ | Authentication strategy | ✅ Local Email/Password only |
285
+ | OAuth / API Keys / etc. | 🚫 Not supported (for now) |
286
+ | User data accessibility | ✅ Stored in your main DB |
287
+
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAqFjC,CAAA"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAsFjC,CAAA"}
@@ -31,7 +31,7 @@ const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0
31
31
  if (!serviceFn) {
32
32
  throw new Error(`Service "${req.body.service}" does not exist`);
33
33
  }
34
- const [{ database, collection, query, update, document }] = args;
34
+ const [{ database, collection, query, update, document, documents }] = args;
35
35
  const currentMethod = serviceFn(app, { rules, user })
36
36
  .db(database)
37
37
  .collection(collection)[method];
@@ -39,7 +39,8 @@ const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0
39
39
  currentMethod,
40
40
  query,
41
41
  update,
42
- document
42
+ document,
43
+ documents
43
44
  });
44
45
  return operatorsByType[method]();
45
46
  }
@@ -20,6 +20,7 @@ type ArgumentsData = Arguments<{
20
20
  query: Parameters<GetOperatorsFunction>;
21
21
  update: Document;
22
22
  document: Document;
23
+ documents: Document[];
23
24
  }>;
24
25
  export type Base64Function = {
25
26
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dtos.d.ts","sourceRoot":"","sources":["../../../src/features/functions/dtos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,KAAK,UAAU,GAAG,OAAO,CAAC,MAAM,UAAU,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAA;AAE1E,MAAM,MAAM,eAAe,GACvB;IACA,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,aAAa,CAAA;CACzB,GACC;IACA,SAAS,EAAE,aAAa,CAAA;IACxB,IAAI,EAAE,UAAU,CAAA;IAChB,OAAO,EAAE,eAAe,CAAA;CACzB,CAAA;AAEH,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,KAAK,aAAa,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAA;IACvC,MAAM,EAAE,QAAQ,CAAA;IAChB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAC,CAAA;AAGF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,EAAE,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,QAAQ,GAAG;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA"}
@@ -22,6 +22,7 @@ export type ExecuteQueryParams = {
22
22
  query: Parameters<GetOperatorsFunction>;
23
23
  update: Document;
24
24
  document: Document;
25
+ documents: Document[];
25
26
  };
26
27
  type FunctionsControllerOptions = {
27
28
  functionsList: Functions;
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/features/functions/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAEhD,MAAM,MAAM,uBAAuB,GAAG;IACpC,GAAG,EAAE,eAAe,CAAA;IACpB,aAAa,EAAE,SAAS,CAAA;IACxB,SAAS,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,MAAM,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAA;IAC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AAU,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACvF,KAAK,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAA;IACvC,MAAM,EAAE,QAAQ,CAAA;IAChB,QAAQ,EAAE,QAAQ,CAAA;IAClB,SAAS,EAAE,QAAQ,EAAE,CAAA;CACtB,CAAA;AAED,KAAK,0BAA0B,GAAG;IAChC,aAAa,EAAE,SAAS,CAAA;IACxB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC/B,GAAG,EAAE,eAAe,EACpB,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE,0BAA0B,KACjD,OAAO,CAAC,IAAI,CAAC,CAAA"}
@@ -10,7 +10,7 @@ export declare const loadFunctions: (rootDir?: string) => Promise<Functions>;
10
10
  * @param query -> the query data
11
11
  * @param update -> the update Document that should be deserialized
12
12
  */
13
- export declare const executeQuery: ({ currentMethod, query, update, document }: ExecuteQueryParams) => Promise<{
13
+ export declare const executeQuery: ({ currentMethod, query, update, document, documents }: ExecuteQueryParams) => Promise<{
14
14
  find: () => Promise<any[]>;
15
15
  findOne: () => Promise<unknown>;
16
16
  deleteOne: () => Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/functions/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAwB9E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,4CAKhC,kBAAkB;;;;;;;;;EAkCpB,CAAA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/functions/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE3D;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAU,gBAAuB,KAAG,OAAO,CAAC,SAAS,CAwB9E,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,uDAMhC,kBAAkB;;;;;;;;;EAkCpB,CAAA"}
@@ -58,7 +58,7 @@ exports.loadFunctions = loadFunctions;
58
58
  * @param query -> the query data
59
59
  * @param update -> the update Document that should be deserialized
60
60
  */
61
- const executeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ currentMethod, query, update, document }) {
61
+ const executeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ currentMethod, query, update, document, documents }) {
62
62
  return {
63
63
  find: () => __awaiter(void 0, void 0, void 0, function* () {
64
64
  return yield currentMethod(bson_1.EJSON.deserialize(query)).toArray();
@@ -68,7 +68,7 @@ const executeQuery = (_a) => __awaiter(void 0, [_a], void 0, function* ({ curren
68
68
  insertOne: () => currentMethod(bson_1.EJSON.deserialize(document)),
69
69
  updateOne: () => currentMethod(bson_1.EJSON.deserialize(query), bson_1.EJSON.deserialize(update)),
70
70
  aggregate: () => currentMethod(bson_1.EJSON.deserialize(query)),
71
- insertMany: () => currentMethod(bson_1.EJSON.deserialize(query)),
71
+ insertMany: () => currentMethod(bson_1.EJSON.deserialize(documents)),
72
72
  updateMany: () => currentMethod(bson_1.EJSON.deserialize(query), bson_1.EJSON.deserialize(update)),
73
73
  };
74
74
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.0.1-beta.11",
3
+ "version": "1.0.1-beta.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,7 @@ export const functionsController: FunctionController = async (
29
29
  if (!serviceFn) {
30
30
  throw new Error(`Service "${req.body.service}" does not exist`)
31
31
  }
32
- const [{ database, collection, query, update, document }] = args
32
+ const [{ database, collection, query, update, document, documents }] = args
33
33
 
34
34
  const currentMethod = serviceFn(app, { rules, user })
35
35
  .db(database)
@@ -39,7 +39,8 @@ export const functionsController: FunctionController = async (
39
39
  currentMethod,
40
40
  query,
41
41
  update,
42
- document
42
+ document,
43
+ documents
43
44
  })
44
45
  return operatorsByType[method as keyof typeof operatorsByType]()
45
46
  }
@@ -26,6 +26,7 @@ type ArgumentsData = Arguments<{
26
26
  query: Parameters<GetOperatorsFunction>
27
27
  update: Document
28
28
  document: Document
29
+ documents: Document[]
29
30
  }>
30
31
 
31
32
 
@@ -25,6 +25,7 @@ export type ExecuteQueryParams = {
25
25
  query: Parameters<GetOperatorsFunction>
26
26
  update: Document
27
27
  document: Document
28
+ documents: Document[]
28
29
  }
29
30
 
30
31
  type FunctionsControllerOptions = {
@@ -44,7 +44,8 @@ export const executeQuery = async ({
44
44
  currentMethod,
45
45
  query,
46
46
  update,
47
- document
47
+ document,
48
+ documents
48
49
  }: ExecuteQueryParams) => {
49
50
  return {
50
51
  find: async () =>
@@ -70,7 +71,7 @@ export const executeQuery = async ({
70
71
  ),
71
72
  insertMany: () =>
72
73
  (currentMethod as ReturnType<GetOperatorsFunction>['insertMany'])(
73
- EJSON.deserialize(query)
74
+ EJSON.deserialize(documents)
74
75
  ),
75
76
  updateMany: () =>
76
77
  (currentMethod as ReturnType<GetOperatorsFunction>['updateMany'])(