@flowerforce/flowerbase 1.1.2-beta.6 → 1.1.2-beta.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAoJjC,CAAA"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/features/functions/controller.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,kBAuGjC,CAAA"}
@@ -24,38 +24,8 @@ const utils_1 = require("./utils");
24
24
  const functionsController = (app_1, _a) => __awaiter(void 0, [app_1, _a], void 0, function* (app, { functionsList, rules }) {
25
25
  app.addHook('preHandler', app.jwtAuthentication);
26
26
  app.post('/call', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
27
- const { user, query } = req;
27
+ const { user } = req;
28
28
  const { name: method, arguments: args } = req.body;
29
- if (query) {
30
- const { baas_request, stitch_request } = query;
31
- const config = JSON.parse(Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'));
32
- console.log("🚀 ~ functionsController ~ baas_request:", baas_request, query, Buffer.from(baas_request || stitch_request || '', 'base64'), Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'), config);
33
- const [{ database, collection }] = config.arguments;
34
- const app = state_1.StateManager.select('app');
35
- const services = state_1.StateManager.select('services');
36
- const changeStream = yield services['mongodb-atlas'](app, {
37
- user,
38
- rules
39
- })
40
- .db(database)
41
- .collection(collection)
42
- .watch([], { fullDocument: 'whenAvailable' });
43
- console.log("🚀 ~ functionsController ~ changeStream:", changeStream);
44
- res.header('Content-Type', 'text/event-stream');
45
- res.header('Cache-Control', 'no-cache');
46
- res.header("content-encoding", "gzip");
47
- res.header('Connection', 'keep-alive');
48
- res.header("access-control-allow-credentials", true);
49
- res.header("access-control-allow-origin", "*");
50
- res.header("access-control-allow-headers", "X-Stitch-Location, X-Baas-Location, Location");
51
- res.raw.flushHeaders();
52
- changeStream.on('change', (change) => {
53
- res.raw.write(`data: ${JSON.stringify(change)}\n\n`);
54
- });
55
- req.raw.on('close', () => {
56
- changeStream.close();
57
- });
58
- }
59
29
  if ('service' in req.body) {
60
30
  const serviceFn = services_1.services[req.body.service];
61
31
  if (req.body.service)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.1.2-beta.6",
3
+ "version": "1.1.2-beta.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,54 +19,9 @@ export const functionsController: FunctionController = async (
19
19
  ) => {
20
20
  app.addHook('preHandler', app.jwtAuthentication)
21
21
 
22
- app.post<{ Body: FunctionCallDto, Querystring?: FunctionCallBase64Dto }>('/call', async (req, res) => {
23
- const { user, query } = req
22
+ app.post<{ Body: FunctionCallDto }>('/call', async (req, res) => {
23
+ const { user } = req
24
24
  const { name: method, arguments: args } = req.body
25
- if (query) {
26
- const { baas_request, stitch_request } = query
27
-
28
- const config: Base64Function = JSON.parse(
29
- Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8')
30
- )
31
-
32
- console.log("🚀 ~ functionsController ~ baas_request:",
33
- baas_request,
34
- query,
35
- Buffer.from(baas_request || stitch_request || '', 'base64'),
36
- Buffer.from(baas_request || stitch_request || '', 'base64').toString('utf8'),
37
- config
38
- )
39
- const [{ database, collection }] = config.arguments
40
- const app = StateManager.select('app')
41
- const services = StateManager.select('services')
42
-
43
- const changeStream = await services['mongodb-atlas'](app, {
44
- user,
45
- rules
46
- })
47
- .db(database)
48
- .collection(collection)
49
- .watch([], { fullDocument: 'whenAvailable' })
50
- console.log("🚀 ~ functionsController ~ changeStream:", changeStream)
51
-
52
- res.header('Content-Type', 'text/event-stream')
53
- res.header('Cache-Control', 'no-cache')
54
- res.header("content-encoding", "gzip")
55
- res.header('Connection', 'keep-alive')
56
- res.header("access-control-allow-credentials", true)
57
- res.header("access-control-allow-origin", "*")
58
- res.header("access-control-allow-headers", "X-Stitch-Location, X-Baas-Location, Location")
59
- res.raw.flushHeaders()
60
-
61
- changeStream.on('change', (change) => {
62
- res.raw.write(`data: ${JSON.stringify(change)}\n\n`)
63
- })
64
-
65
- req.raw.on('close', () => {
66
- changeStream.close()
67
- })
68
- }
69
-
70
25
 
71
26
  if ('service' in req.body) {
72
27
  const serviceFn = services[req.body.service]