1

I am at this the third day now, but can't find the way to successfully use the AppDevPack on my local angular app. I am working on a Mac, I have Angular v 8.15.0. I was able to successfully install the library but when ever I wan't to compile it, it breaks. To describe: I've done almost everything to the script. The only difference is that I have made a service in which the @domino lives(it is not directly on a component). The main problem seems to be with grpc and then with stream.

import { Injectable } from '@angular/core';
//import { useServer } from '@domino/domino-db/';
import * as useServer from '../../../node_modules/@domino/domino-db';


@Injectable({
  providedIn: 'root'
})
export class DominoService {

  private serverConfig = {
    hostName: 'http://www.hostname.com/',
    connection: { port:'3002'}
  };

  private databaseConfig = {
    filePath: 'dev-tmp.nsf'
  };

  public database: any;

  constructor() {
    useServer( this.serverConfig ).then( async server => {
      this.database = await server.useDatabase( this.databaseConfig );
    });

    const coll = this.database.bulkReadDocuments({
      query: "Form = 'Document'"
    });
    console.log("Returned docs:" + JSON.stringify(coll));

  }

Here are some of the errors:

Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/@domino/domino-db/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/@domino/domino-db/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/@domino/domino-db/node_modules/grpc/node_modules/minimatch/minimatch.js Module not found: Error: Can't resolve 'path' in '/Users/…/node_modules/@domino/domino-db/node_modules/grpc/node_modules/minimatch'

ERROR in ./node_modules/@domino/domino-db/node_modules/grpc/node_modules/detect-libc/lib/detect-libc.js Module not found: Error: Can't resolve 'child_process' in ‘/…/node_modules/@domino/domino-db/node_modules/grpc/node_modules/detect-libc/lib' Error: Can't resolve 'path' in '/Users/.../node_modules/@domino/domino-db/node_modules/grpc/node_modules/minimatch' ERROR in ./node_modules/@domino/domino-db/node_modules/grpc/node_modules/detect-libc/lib/detect-libc.js Module not found: Error: Can't resolve 'child_process' in '/Users/.../node_modules/@domino/domino-db/node_modules/grpc/node_modules/detect-libc/lib' ERROR in ./node_modules/@domino/domino-db/node_modules/grpc/src/client.js Module not found: Error: Can't resolve 'stream' in '/Users/.../node_modules/@domino/domino-db/node_modules/grpc/src'

hardillb
  • 54,545
  • 11
  • 67
  • 105
dregos
  • 61
  • 7
  • That error doesn't look familiar. What version of Node are you using? domino-db was tested with Node 8.x. – Dave Delay Feb 22 '19 at 14:28
  • I have a question and some comments about your code. Why is the require for domino-db using a relative path? Your call to this.database.bulkReadDocuments needs to be done in the then of the useServer promise. All of our functions are async so they must be awaited or chained as promises. Similarly, you must also await the this.database.bulkReadDocuments before you use coll. I would not do this in a constructor, because it can't be async, so you have to use promise chaining (at least for the useServer call). – ddumont Feb 22 '19 at 15:42
  • Also, are you trying to webpack this code? – ddumont Feb 22 '19 at 15:45
  • Regarding my code. I did not really give it much attention. I was really just frustrated with the installation. I've tried with Node 11, 10, and 8.14. Nothing worked. However, I will try and reinstall npm and node and do everything from scratch. – dregos Feb 22 '19 at 18:32
  • What do you mean by webpack? – dregos Feb 22 '19 at 18:56
  • Dan's webpack question is really about whether the code that's calling domino-db is executing in 1) the browser, or 2) the Node.js runtime. Since you mentioned Angular, I suspect it's running in the browser. The domino-db package is really meant for the Node.js runtime. – Dave Delay Feb 22 '19 at 21:10
  • aaa.. I understand. Makes sense.. Do you maybe have an example how I could use this in an angular app so it runs on node.js runtime? – dregos Feb 22 '19 at 22:16
  • 1
    Ok I get it now. I need something for serverside comunication. Like Express. – dregos Feb 23 '19 at 21:45

1 Answers1

4

Critical dependency: the request of a dependency is an expression

From the error message, I can see that you're trying to webpack this. We do not support running domino-db on a webpage. Even if you got past this error, domino-db would fail to load in that environment because it's insecure.

Domino-db in production, secure environments requires client credentials to log in. Those aren't things you want to appear in the browser page.

ddumont
  • 583
  • 3
  • 14
  • Would you be kind to explain what exactly is webpacking and how am I trying to do that? I am not an expert when it comes to NodeJS and Angular. – dregos Feb 22 '19 at 19:02
  • Think of your application as having three logical tiers: 1) the Angular web UI, 2) a REST API, and 3) the Domino database. The first tier runs in the browser. It presents a view of the application model, but it manipulates the model by calling the middle tier's REST API. The middle tier is a Node.js server (possibly using Express) that implements a model-specific REST API. It uses domino-db to store data in a Domino database. I suppose you started from an Angular tutorial and you have accidentally combined the view and model in a single tier. Can you try moving domino-db to a Node.js server? – Dave Delay Feb 22 '19 at 22:56
  • I understand. Thank you for your help. Basically my logic was off. And to think, I've done this kind of architectures already. Just didn't connect the dots. I tought, this domino-db is client side library for communication with domino. I will try and create an Express node.js server, where @domino-db will run and then communicate with it via http requests. Or is there a better way for local development? – dregos Feb 24 '19 at 17:35
  • That's a pretty good start. We have quite a few internal examples of that kind of thing. I'd love to be able to make some of them open-source. Working on that.(lawyers ;) – ddumont Feb 25 '19 at 16:45