GithubHelp home page GithubHelp logo

cheatcode / joystick Goto Github PK

View Code? Open in Web Editor NEW
194.0 5.0 10.0 13.74 MB

A full-stack JavaScript framework for building stable, easy-to-maintain apps and websites.

Home Page: https://cheatcode.co/joystick

License: Other

JavaScript 99.71% HTML 0.18% CSS 0.10%
batteries-included components express full-stack javascript javascript-framework nodejs ui

joystick's People

Contributors

rglover avatar tomashubelbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

joystick's Issues

Add an alias for set() called action()

This is more of a DX detail than actual functionality. Realizing now that there will be HTTP requests that trigger some functionality on the server but do not have an intent of "getting" or "setting" something. Technically those are HTTP POST requests, but the word set() can be confusing. Aliasing set() as action() would improve context with zero cost at the framework level.

This would also require considering the addition of an actions property on the API schema, something like:

export default {
  getters: {},
  setters: {},
  actions: {},
}

Automatically treat non .js files in folders as copy-only

When building with esbuild right now, any file that is not a .js file gets picked up by esbuild and throws an error because it's not a recognized file type. Need to add a check to the files being built to say "just skip to copy if this isn't a .js file."

MongoDB error when running create app command

Any solutions to this error? Node version is 14.5.0.

โžœ  joystick create smth
file:///usr/local/lib/node_modules/@joystick.js/cli/dist/functions/start/databases/mongodb/checkConnection.js:1
import { MongoClient } from "mongodb";
         ^^^^^^^^^^^
SyntaxError: The requested module 'mongodb' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'mongodb';
const { MongoClient } = pkg;
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:137:5)
    at async Loader.import (internal/modules/esm/loader.js:162:24)

Maybe it's related https://jira.mongodb.org/browse/NODE-2655

OAuth accounts

Add support to accounts object for common OAuth providers:

import ui, { accounts } from '@joystick.js/ui';

accounts.github();
accounts.google();
accounts.facebook();
accounts.twitter();

Would also be good to have a hook for defining your own OAuth accounts provider.

Add ability to eject from Joystick

Will take some work, but could have a way to do a static site eject that's just plain HTML, CSS, and JavaScript files organized into folders similar to routes.

Add ability to pass configuration directly to node.app()?

Came across this on another project in relation to middleware. Certain middleware config will need access to JavaScript in order to work (e.g., defining custom rules for a cors config). Would be good if a new config option can be passed to node.app() which mimics the behavior of the config block in the settings.env.json file.

Need to think a bit on this to avoid confusion. Do we want to allow all configuration to be passed this way or just specific configuration? Can we get away with introducing a .js version of settings files to avoid this altogether (and build them like any other file)? Need to be mindful of backwards compatibility with .json files.

Expand getPathVariations to include /<part>

Noticing that some paths are not being picked up as codependencies on file changes. Need to modify getPathVariations in getCodependenciesForFile:

const getPathVariations = (path = "") => {
  const pathParts = path.split("/");
  const variations = [];

  pathParts.forEach((pathPart, pathPartIndex) => {
    let base = `${pathPart}`;

    variations.push(`/${pathPart}`);

    pathParts.slice(pathPartIndex + 1, pathParts.length).forEach((part) => {
      base = base += `/${part}`;
      variations.push(base);
      if (part.includes(".")) {
        variations.push(base.split(".")[0]);
      }
    });
  });

  variations.push(`./${pathParts[0]}`);
  variations.push(`./${pathParts[0]}/index`);
  variations.push(`./${pathParts[0]}/index.js`);
  variations.push(`/index`);
  variations.push(`/index.js`);

  return variations;
};

getPathVariations("ui/components/button/index.js");

Add websocket client and server

Consider adding a config option to enable websockets or customize the connection. Want to have something like ws.connect() or ws.send() built into @joystick.js/ui. Need to think carefully about how the endpoints will be shaped so you can expand it to be multi-purpose.

Add a standardized error reporter for the CLI

There will be a lot of errors/warnings that need to be printed to the console. It would be helpful to have a generic function that could be called from any of the packages to handle reporting so everything is consistent.

Handle media queries in getCSSFromTree.js

Getting this when using a media query in a component's CSS:

TypeError: Cannot read properties of undefined (reading 'map')
    at file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:12:39
    at Array.map (<anonymous>)
    at buildPrefixedAST (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:9:37)
    at handlePrefixCSS (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:23:23)
    at getCSSFromTree (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:30:25)
    at file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:35:7
    at Array.forEach (<anonymous>)
    at getCSSFromTree (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/getCSSFromTree.js:34:19)
    at ssr_default (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/ssr/index.js:21:27)
    at ServerResponse.res.render (file:///Users/rglover/projects/cheatcode/site/node_modules/@joystick.js/node/dist/app/middleware/render.js:62:18)

Add webhook handlers

Speculative. Have a way to define webhook handlers/middleware for common services.

Add ability to disable built-in middleware

Came across a use case for this on another project. Need to be able to disable the built-in middleware in favor of configuring a custom version in the middleware option passed to node.app(). This will allow handling domain-specific setups without having to kludge together something using the config in settings.

Add an authorized option to getters and setters

In order to aid in the process of authorizing access to the API, add an authorized property that allows for validating a request is authorized before passing the input to the get() or set() function:

export default {
  posts: {
    input: { ... },
    authorized: (input, context) => {
      // Return true/false here based on some test.
    },
    get: () => { ... },
  }
}

Simple enough so that you could write a multi-purpose function, import it, and assign it to authorized.

Fix folder rename breaking builds and exiting

Getting this when I rename a folder. Likely due with the move to Chokidar.

node:fs:585
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open 'ui/pages/index/index.js'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getCodeFrame_default (file:///Users/rglover/.nvm/versions/node/v16.13.0/lib/node_modules/@joystick.js/cli/dist/lib/getCodeFrame.js:4:19)
    at file:///Users/rglover/.nvm/versions/node/v16.13.0/lib/node_modules/@joystick.js/cli/dist/functions/start/buildFile.js:44:25
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'ui/pages/index/index.js'
}

Clarify how to call a getter or setter from the server

On the client this is done via @joystick.js/ui's get() and set() methods but technically you can import these methods via @joystick.js/node, too. The problem is that right now they perform an unnecessary HTTP request from the server back to itself.

While you could do something like this...

import node from '@joystick.js/node';
import api from './api';

node.app({
  routes: {
    '/do-something': (req, res) => {
      api.getters.posts.get();
      res.send('Done');
    },
  },
});

Calling api.getters.posts.get() directly skips over the input validation. Since all we're doing to register a getter is creating an express route, it'd be worth extracting the work being done in those routes into a separate function. Then, instead of making an HTTP request in the Node version of get() and set(), just make them a wrapper around that function. So, same API as the client but under the hood it skips the HTTP trip.

Add warnings for file structure

Need to think carefully about how to do this but need to force existence of certain things. May even make it so that folder structure/everything are locked.

Add database adapter for Supabase

Not sure if it'd be wise to alias their own auth functions (e.g., make authentication.signup() point to supabase.auth.signup()) or just have the supabase client exported raw. Likely the latter (same for #23).

Will also need to figure out auth hooks for .isLoggedIn() and related APIs.

Goal is to avoid being too tightly coupled so the only real upgrades necessary in Joystick are drivers or client libraries (want to avoid unnecessary abstractions on other people's code).

Add a live option to getters to automate real-time data

Not sure what the implementation looks like but we could have a live property passed to the options of object of get() that allows you to establish a real-time query via websockets...

get('posts', {
  live: true,
  input: { ... },
  output: { ... },
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.