kreteshq / kretes

A Programming Environment for TypeScript & Deno
https://kretes.dev/
Other
676 stars 35 forks source link

How to set up the db? #66

Closed emilos closed 4 years ago

emilos commented 4 years ago

Does the lib require anything related to postgres to be set up, like a config file? (similar to rails)

┌─( Client )───────────────────────────────────────┐┌─( Server )───────────────────────────────────────┐
│[4mrollup v1.32.1                                 ││los/my-app/node_modules/pg/lib/connect            │
│bundles config/client/index.ts → publi            ││ion.js:413                                        │
│c...                                              ││  - Socket.<anonymous>                            │
│^C                                                ││    /Users/emilos/Desktop/Projects/emi            │
│ ..:: PROGRAM TERMINATED ::..                     ││los/my-app/node_modules/pg/lib/connect            │
│                                                  ││ion.js:129                                        │
│                                                  ││  - Socket.emit                                   │
│                                                  ││    events.js:223                                 │
│                                                  ││  - addChunk                                      │
│                                                  ││    _stream_readable.js:309                       │
│                                                  ││  - readableAddChunk                              │
│                                                  ││    _stream_readable.js:290                       │
│                                                  ││  - Socket.Readable.push                          │
│                                                  ││    _stream_readable.js:224                       │
│                                                  ││  - TCP.onStreamRead                              │
│                                                  ││    internal/stream_base_commons.js:18            │
│                                                  ││1                                                 │
│                                                  ││                                                  │
│                                                  ││ ..:: PROGRAM TERMINATED (code: 1) ::.            │
│                                                  ││.                                                 │
│                                                  ││                                                  │
│                                                  ││                                                  │
└──────────────────────────────────────────────────┘└──────────────────────────────────────────────────
zaiste commented 4 years ago

@emilos could you try huncwot server or hc server ? The start command is deprecated as I'm working on a tight integration with VS Code. Do you happen to use this editor ?

with hc server you should get a following screen if there is no PostgreSQL instance running

Screen Shot 2020-03-10 at 18 48 52

I've decided to exclusively focus on PostgreSQL to force people to learn about certain beautiful features of that database that are usually hidden by an ORM. ;)

I'll update the documentation in a moment. I should've done it long ago.

emilos commented 4 years ago

Thanks, that's more helpful, I get the following error message here:

emilos@Emils-MacBook-Pro my-app % huncwot server
/Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:794
    throw new Error("Cannot parse config file: '" + fullFilename + "': " + e3);
    ^

Error: Cannot parse config file: '/Users/emilos/Desktop/Projects/emilos/my-app/config/default.yml': TypeError: VisionmediaYaml.eval is not a function
    at Config.util.parseFile (/Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:794:11)
    at /Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:601:26
    at Array.forEach (<anonymous>)
    at Config.util.loadFileConfigs (/Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:600:16)
    at new Config (/Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:116:27)
    at Object.<anonymous> (/Users/emilos/.nvm/versions/node/v12.14.1/lib/node_modules/huncwot/node_modules/config/lib/config.js:1441:31)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)

The yaml file seems to be valid though (I've double checked in a yaml validator).

db:
  database: "my_app"
  username: "emilos"

deploy:
  server:
    src: .
    dest: "YOUR DESTINATION"
    delete: true
    exclude:
      - dist
      - node_modules
      - .git
      - static/upload
      - config/default.yaml
  client:
    src: dist/
    dest: "YOUR DESTINATION"
    delete: true

Any ideas?

zaiste commented 4 years ago

@emilos Would it be possible if you (temporarily) install js-yaml globally? Just to see if it solves the issue

npm i -g js-yaml
emilos commented 4 years ago

@zaiste bingo, thanks!

zaiste commented 4 years ago

For future references, the YAML issue is related to this.

emilos commented 4 years ago

Maybe it makes sense to simplify this and just have a json or js file that does the same? I do understand the desire to use the lovely yaml syntax, but maybe it does not sense to have it out of the box? Less deps, less things to worry about etc.

I do use it in the engine too, considering to move it to a separate package though... not sure what's the best approach :)

zaiste commented 4 years ago

I relate to this sentiment, but I would it keep it as-is for now and decide about it later. In the future we could just have a visual panel in VS Code and simply use json underneath.