A Programming Environment for TypeScript & Node.js built on top of VS Code

Overview

Programming Environment
for TypeScript & Node.js

A battery-included TypeScript framework built on top of Visual Studio Code

Website


Kretes channel on Discord Kretes Package on NPM Kretes related screencasts on YouTube

Kretes is a programming environment for building modern web applications using TypeScript & Node.js with « batteries included » approach. It is an integrated solution that optimizes for programmers productivity by reducing choices and incorporating community conventions.

Table of Contents

Rationale

Kretes is being built with battery included approach in mind, i.e. it comes with a (eventually large) library of useful modules which are developed in a coherent way. This stands in direct opposition to Koa approach. Kretes tries to formalize conventions and eliminate valueless choices by providing solid defaults for building web applications that increase the programmers productivity.

Kretes fights against the accidental complexity. Let's focus on business needs of our applications instead of constantly configuring, patching and putting together various software elements.

Features In A Nutshell

Kretes bridges client-side (frontend) and server-side (backend) development by using a single programming language - JavaScript - across the board.

The project draws inspiration from Rails while trying to be less magical, if any at all. In Kretes, you write your applications using TypeScript.

As a secondary goal, Kretes tries to minimize the dependencies. It uses external packages only if absolutely necessary (e.g. security, OS abstractions etc).

Roadmap

Kretes keeps track of the upcoming fixes and features on GitHub Projects: Kretes Roadmap

Bug reports

We use Github Issues for managing bug reports and feature requests. If you run into problems, please search the issues or submit a new one here: https://github.com/kreteshq/kretes/issues

Detailed bug reports are always great; it's event better if you are able to include test cases.

Comments
  • Just installed and trying to start the server getting error.

    Just installed and trying to start the server getting error.

    Error connect ECONNREFUSED 127.0.0.1:5432 Explanation It looks like you haven't started your database server.

    Stack trace

    • TCPConnectWrap.afterConnect [as oncomplete] net.js:1137
    opened by kalaikt 16
  • Struggling with creating a custom URL

    Struggling with creating a custom URL

    I'm playing with Huncwot and so far so good. I would like to ask you how can I retrieve a user's data by passing a keyword after parameters. For instance, in Twitter, if you pass a username after Twitter (Twitter.com/user) you will go to their profile page (eg; Twitter.com/Zaiste) and if you add the "followers" keyword after username it will take you to followers page and bring that user's followers data (eg; Twitter.com/Zaiste/followers) I can go to users page by creating a folder (User) and giving it Controllers (browse.ts, fetch.ts ...) but how about (Followers) section ? How can I make a URL link with user/followers and bring the same user's followers ?. Thank you. Best regards.

    opened by inc16sec 13
  • Unable to Start the Server

    Unable to Start the Server

    Platform: windows 10 Node: v14.1.0

    After creating the project with Kretes I have launched the task server and it has shown me the following error

    Error

    Debugger listening on ws://127.0.0.1:9229/917ec5e3-95c9-407b-8d85-13490b7554f2
    For help, see: https://nodejs.org/en/docs/inspector
    internal/modules/cjs/loader.js:1023
      throw err;
      ^
    
    Error: Cannot find module 'C:\Users\c\Desktop\justwatch\UserscDesktopjustwatch\node_modules\huncwot\cli.js'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
        at Function.Module._load (internal/modules/cjs/loader.js:890:27)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
        at internal/main/run_main_module.js:17:47 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    }
    The terminal process terminated with exit code: 1
    

    I have verified in the path node_modules\huncwot\cli.js and it contains this code.

    #!/usr/bin/env node
    
    // Copyright 2016 Zaiste & contributors. All rights reserved.
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    // http://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    
    const validateNode = require('validate-node-version')('>=7.6.x');
    
    if (!validateNode.satisfies) {
      console.error(validateNode.message);
      process.exit(1);
    }
    
    const argv = require('yargs')
      .version()
      .usage('Usage: huncwot <command> [options]')
      .command(['new [dir]', 'initialize', 'n'], 'Create new project', require('./cli/init'))
      .example('huncwot new my-project', 'Create and initialize `my-project` directory')
      .command(['server [dir]', 'serve', 's'], 'Serve the directory', require('./cli/server'))
      .example('huncwot server --port 4000', 'Serve the directory at the port 4000')
      .command(['database [command]', 'db'], 'Database operations', require('./cli/database'))
      .demandCommand(1, 'You need at least one command before moving on')
      .help('h')
      .alias('h', 'help')
      .epilogue('for more information, find the documentation at https://huncwot.net')
      .argv;
    
    

    Also try using the huncwot library but it shows me the following error. I do not understand why it shows me that error since my project was generated, so it does not have any specific configuration with db.

    $ huncwot server
      Error connect ECONNREFUSED 127.0.0.1:5432
      Explanation
      It looks like you haven't started your database server.
    
      Stack trace
      - TCPConnectWrap.afterConnect [as oncomplete]
        net.js:1142
    

    If there is any solution and you can help me, I will appreciate it!

    opened by ChrisMichaelPerezSantiago 12
  • Background processing does not work as described in docs

    Background processing does not work as described in docs

    Kretes: 0.71 OS: Ubuntu 20.04 LTS

    According to: https://kretes.dev/docs/guide/in-depth/background-processing/

    I created example task in tasks/SendEmail.ts and run kretes background in nix-shell

    1. By default it listens on postgresql default port instead 5454
    ks background
    
    Run background processing
    
    Options:
      -h, --help     Show help                                             [boolean]
      -V, --version  Show version number                                   [boolean]
    
    Error: connect ECONNREFUSED 127.0.0.1:5432
        at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
      errno: 'ECONNREFUSED',
      code: 'ECONNREFUSED',
      syscall: 'connect',
      address: '127.0.0.1',
      port: 5432
    }
    

    export PGPORT=5454 solves this problem but

    1. Kretes is looking for tasks in dist/tasks directory instead of tasks
    ks background
    
    Run background processing
    
    Options:
      -h, --help     Show help                                             [boolean]
      -V, --version  Show version number                                   [boolean]
    
    Error: Could not find tasks to execute - '/home/daksamit/dev/kretes_demo/dist/tasks' does not exist
        at Object.getTasks [as default] (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/node_modules/graphile-worker/dist/getTasks.js:57:15)
        at async assertTaskList (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/node_modules/graphile-worker/dist/runner.js:24:30)
        at async Object.exports.run (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/node_modules/graphile-worker/dist/runner.js:51:47)
        at async Object.exports.handler (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/dist/cli/background/start.js:37:21)
    

    I copied task to dist/tasks and now ks bg output is:

    [core] INFO: Worker connected and looking for jobs... (task names: '')
    (node:20119) UnhandledPromiseRejectionWarning: Error: Failed 10 times in a row to acquire job; latest error: No runnable tasks!
        at doNext (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/node_modules/graphile-worker/dist/worker.js:86:36)
        at Timeout.<anonymous> (/home/daksamit/.config/nvm/12.13.0/lib/node_modules/kretes/node_modules/graphile-worker/dist/worker.js:93:56)
        at listOnTimeout (internal/timers.js:531:17)
        at processTimers (internal/timers.js:475:7)
    (node:20119) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:20119) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    Missing comma SendEmail instead of SendEmail, in example and broken 'edit this page on github' link in docs image

    opened by daksamit 8
  • Error: exit code 1

    Error: exit code 1

    I don't know if this error is a result of the many deprecated files that Kretes currently imports, but I cannot find any way around fixing this bug. Please review and advise. Thank you for your assistance.

    image

    opened by ealvar3z 7
  • Error after create controller

    Error after create controller

    TypeError: Cannot destructure property 'method' of 'translate(...)' as it is undefined. at new Huncwot (/usr/lib/node_modules/huncwot/index.js:111:17) at start (/usr/lib/node_modules/huncwot/cli/server.js:53:15) at /usr/lib/node_modules/huncwot/cli/server.js:119:17 at processTicksAndRejections (internal/process/task_queues.js:97:5) at async Promise.all (index 0)

    opened by zeny 7
  • How to set up the db?

    How to set up the db?

    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) ::.            │
    │                                                  ││.                                                 │
    │                                                  ││                                                  │
    │                                                  ││                                                  │
    └──────────────────────────────────────────────────┘└──────────────────────────────────────────────────
    
    opened by emilos 7
  • Having an issue trying to retrieve data from Huncwot server.

    Having an issue trying to retrieve data from Huncwot server.

    Hello there. So I've been playing around with this amazing library and everything seemed to be going so well but the it wasn't :D

    So i connected huncwot with my Neo4j db and tried to fetch some data and it works well with browser but when i try to fetch call the GET request from Flutter/emulator it gives me an error.

    On the Flutter DEBUG CONSOLE it prints an HTML response (which i don't know from where did it come from) and in the Huncwot consol it prints (undefined Internal Server Error)

    Here's my Neo4j query function

    static browseUserData() { return session.run('MATCH (u:USER) RETURN u.display_name AS name, u.bio AS bio') .then((res) => { return JSON.stringify(res.records, null, 3); }) .catch((error) => { console.error(error); }); }

    And here's my Handler function from User folder i have a browse.ts file inside controller folder

    const browse: Handler = async (): Promise<any> => { const user = await DatabaseEvents.browseUserData(); return OK(user); } export = browse;

    and here's my how i try to GET the data from Flutter

    `var uri = 'http://1localhost:5544/user';

    browseData() async {
       http.Response response = await http.get(uri);
       print(response.body);
    

    }` All of this works fine and as expected in a normal browser (Chrom in my case) but on Flutter it prints something else

    This is what I get.

    `flutter: