Code Monkey home page Code Monkey logo

lunox's Introduction

LUNOX MONOREPO

This is Lunox Monorepo created using pnpm workspace. There are two main workspace

  • packages: all lunox related packages developed in this folder. Including Lunox Framework Core.
  • presets: this workspace is to create lunox application sekeleton preset. For example preset svelte and react. This workspace is mainly used for testing lunox packages.

What is LUNOX

Lunox is Laravel-Flavoured NodeJs Framework. What is Laravel? Laravel is a web application framework with expressive, elegant syntax see the official website. Lunox goals is to bring the Laravel Flavour to nodejs environment.

Creating Lunox App

pnpm create lunox-app

Documentation

Lunox Documentation can be accessed here

Development

Basic Pnpm Workspace Command

  • install modules in all workspace, run this command in root repo
pnpm install
  • add modules to specific workspace, for example we want to add svelte to lunox-svelte (see package name in package.json)
pnpm --filter lunox-svelte add svelte@latest
  • run script on specific workspace, for example we want to run eslint on lunox-svelte
pnpm --filter lunox-svelte lint
  • run script on all workspace, just add -r (recursive)
pnpm -r lint

Contribution

Lunox has three main repo

  1. Lunox - Lunox Monorepo, contains lunox packages and presets.
  2. Lunox Framework - main source code of Lunox Framework (DEPRECATED: merged to this repo).
  3. Lunox Website - Documentation of Lunox Framework.

This framework still in development, PR are welcome, but please open issue or discussion before adding new feature.

lunox's People

Contributors

axmad386 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

Watchers

 avatar  avatar  avatar  avatar

lunox's Issues

[lunox-core] Need Gate and Policy feature for Advance Authorization

In laravel, we can use gate and policy to handle authorization. See
https://laravel.com/docs/10.x/authorization#introduction
But maybe we can start from simple version

  • Gate.define
  • Gate.authorize
  • Gate.before
  • Gate.after
  • Abstract class of Policy, or just interface to make Policy object
  • can middleware, its like Gate.authorize but via middleware

Also we need AuthServiceProvider can register policies like this

import Post from "../app/Models/Post";
import {ServiceProvider} from "@lunoxjs/core";
class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     */
    protected policies: [Class<any>,typeof Policy][]= [
        [Post, PostPolicy], // are we can do this in typescript?
    ];
 
    /**
     * Register any application authentication / authorization services.
     */
    public function boot(): void
    {
        // ...
    }
}

[lunox-eloquent] Need Documentation of How to use `@lunoxjs/eloquent`

Hello. Thank you for this wonderful package. It appears that in package next, you install the typeorm DatabaseServiceProvider. Installing eloquent and subsequently replacing the provider in app/config fails with dependency errors:

TypeError: Cannot read properties of undefined (reading 'make')
    at Proxy.resolveFacadeInstance (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@lunoxjs/eloquent/node_modules/@lunoxjs/core/dist/ViewFactory-bbd4d106.mjs:1:8753)
    at Proxy.<anonymous> (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@lunoxjs/eloquent/node_modules/@lunoxjs/core/dist/ViewFactory-bbd4d106.mjs:1:8310)
    at b.boot (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@lunoxjs/eloquent/dist/index.mjs:1:8928)
    at se.boot (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]/node_modules/@lunoxjs/core/dist/index.js:1:2878)
    at async d.bootstrap (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]/node_modules/@lunoxjs/core/dist/chunk-5JSYJ6R5.js:1:263)
    at async se.bootstrapWith (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]/node_modules/@lunoxjs/core/dist/index.js:1:2538)
    at async Kernel2.start (file:///lunox-app/src/node/lunox/lunox-002/node_modules/.pnpm/@[email protected]/node_modules/@lunoxjs/core/dist/index.js:1:4066)
    at async file:///lunox-app/src/node/lunox/lunox-002/dist/index.js:15:1

I know some prefer TypeORM or even Drizzle, but is eloquent still a viable option for those that may prefer it?

Eject knex and objection to @lunox/eloquent

Lunox v1 has builtin ORM called eloquent, it's built on top of knex an objection. I use them because of my personal project and objection is highly customisable (we can create fillable, guarded, custom attribute like in laravel eloquent). But knex and objection is not user friendly, there are many popular database manager like typeorm and prisma that modern than objection.

I think it's better to exclude knex and objection to separate module @lunox/eloquent. But, maybe it will be hard because migration artisan command is also using knex for now. So it's likely migration will be removed from lunox and will be injected from @lunox/eloquent. It requires service provider to support load console command (TBD)

[lunox-core] run artisan command without build step

For now artisan command should run only after build step, or run in watch mode (pnpm dev). So tstep by step to run artisan command for now is:

  • runpnpm build or pnpm dev, wait until source code is compiled
  • run pnpm artisan [command]

It will be nice if we can run artisan command without compiling the source code, for example using ts-node. But I was tried using it and is complicated for esm type project.
I see this magic tool for alternative
https://github.com/esbuild-kit/tsx
I think we can use it in development.

[lunox-core] Facade cannot access getter or properties

When classed get wrapped on Facade using useFacade helper, all class properties and getter is not accessible. This is because Facade __getStatic magic method only triggered when we access class method. I think this code will fix this issue. Tested on another project using vitest.

  static __getStatic(name: string, abstract: string | symbol) {
   // before, we didn't check target property here 
   // because this.app is still undefined here due to static method
   // so by using app(), we can rebind app here
    let target: any;
    if (!this.app && app()) {
      this.setApplicationFacade(app());
      target = this.resolveFacadeInstance(abstract);
     // Tara... we can access target getter or property here
      if (target[name]) {
        return target[name];
      }
    }
    return (...args: any) => {
     // if target not resolved before, resolve here
      if (!target) {
        target = this.resolveFacadeInstance(abstract);
      }
      // this for checking Route facade is being called
      if (target.facadeCalled) {
        target.facadeCalled();
      }

      // check method is callable in instance
      if (target[name]) {
        return target[name].call(target, ...args);
      }

      // check method is callable in class
      if (target.constructor) {
        if (target.constructor[name]) {
          return target.constructor[name].call(target.constructor, ...args);
        }
      }

      throw new BadMethodCallException(`Method ${target.constructor.name}.${name} does not exist.`);
    };
  }

[create-lunox-app] Need multiple Preset that can handle multiple library

For now, there is three available presets.

  • api
  • react
  • svelte

All of them is using @lunoxjs/typeorm as database manager, @lunoxjs/validation as validator. How if someone want to use @lunoxjs/eloquent or @lunoxjs/prisma, how if they want to use @lunoxjs/zod as validator. I think create-lunox-app should handle such situation.

Bug Router Parameter in windows

kalo memakai router seperti loacalhost:8000/:slug di linux, css styling tidak dapat berjalan, dan di windows menampilkan halaman 404

sedangkan memakai router seperti localhost:8000/test/slug di linux dapat menampiklan halaman secara sempurna, sedangkan di windows menampilkan 404 bukan 303 ye.

[lunox-core] Eject Validation to separate module

currently lunoxjs has builtin form validation that can be accessed using req.validate() method. But under the hood it using https://github.com/kodepandai/node-input-validator. But sometimes user prefer using third party for validation eg: zod. So IMO, it's better to move this feature to separate module called @lunoxjs/validation.

But may be we got some problem here, since this validation is attached to Request class. So we should use macro to extend this functional. maybe something like this in

// in ValidationServiceProvider
register(){
  Request.macro('validate', callback here)
}

Also we need to extend the Request interface using Module Augmentation

[lunox-core] json should not be parsed as form data

Current implementation of body parser is when request method is not get, everything is parsed via formidable. This will introduces incorrect behavior. For example request with method put but sent application/json it will threat single array as not array.

agent.put("/url").send({ids: ["randomid"]}) 
// body will parsed as 
{ ids: "randomid"} --> it should be {ids: ["randomid"]}

Update Vitejs to v4

Vite has released v3, should we migrate to it? But may be it will be breaking change.

[Storage] Cannot set custom option on s3 driver

For now, if we upload image with Storage.disk().put('image.jpg', imageContent), the image stored with missing content-type.
We can add content-type option when upload with aws sdk, but the flydrive wrapper is lack of this feature. The worst thing is, we need this option to make our content accessable publicly.

Currently lunox is using https://github.com/Slynova-Org/flydrive for Storage manager. I think that repo is no longer maintained. We need to refork that repo to add support adding custom option as 3rd params of put method. Or may be better, we can read custom option from filesystem config file like laravel did.

Change to Monorepo

Since we are already using pnpm as package manager. I think is good to make this repo as monorepo using pnpm workspace
So we can merge this https://github.com/kodepandai/lunok-framework to this repo

Pros:

  • development will be easier
  • testing will be fast since we can install directly other local package to this repo

Const:

  • we should create tool to initialize lunox app, we cannot use degit anymore.

[lunox-view] Support SPA

For now, lunoxjs only support full mpa(multi page application). So it will full server side routing every we visit url in lunoxjs. I have experiment that using inertiajs, it can handle the spa part. All we need is just tweek in entry-client and how View render. It will be awesome, imagine client side routing with full SSR support like nextjs or svelte-kit but still has the power of laravel like route.

[preset] Multiple Preset Progress

Preset Validator Database Manager Done
api @lunoxjs/validation @lunoxjs/eloquent
api @lunoxjs/validation @lunoxjs/typeorm
api @lunoxjs/validation @lunoxjs/prisma
api @lunoxjs/validation @lunoxjs/drizzle
api @lunoxjs/zod @lunoxjs/eloquent
api @lunoxjs/zod @lunoxjs/typeorm
api @lunoxjs/zod @lunoxjs/prisma
api @lunoxjs/zod @lunoxjs/drizzle
react @lunoxjs/validation @lunoxjs/eloquent
react @lunoxjs/validation @lunoxjs/typeorm
react @lunoxjs/validation @lunoxjs/prisma
react @lunoxjs/validation @lunoxjs/drizzle
react @lunoxjs/zod @lunoxjs/eloquent
react @lunoxjs/zod @lunoxjs/typeorm
react @lunoxjs/zod @lunoxjs/prisma
react @lunoxjs/zod @lunoxjs/drizzle
svelte @lunoxjs/validation @lunoxjs/eloquent
svelte @lunoxjs/validation @lunoxjs/typeorm
svelte @lunoxjs/validation @lunoxjs/prisma
svelte @lunoxjs/validation @lunoxjs/drizzle
svelte @lunoxjs/zod @lunoxjs/eloquent
svelte @lunoxjs/zod @lunoxjs/typeorm
svelte @lunoxjs/zod @lunoxjs/prisma
svelte @lunoxjs/zod @lunoxjs/drizzle

Eject module related View to @lunox/view

View in lunox is highly depends on vite as frontend tooling. Sometimes we want to build just API without UI, so vite is unnecessary here. We should decouple lunox from vite by create separate module called @lunox/view.

Fyi still in progress on next branch. React and svelte plugin also will be separated on @lunox/view-plugin-react and @lunox/view-plugin-svelte

Any suggestions? Please fill in comment

[Bug] Nested View

When we create view in nested folder, server side svelte component rendered successfully but client component failed to hydrate. I think it's because how vite build client side component.
For workaround may be we can build client side component with rollup + rollup multi input plugin

[lunox-core] Testing Source Code using Vitest

We are using jest and ts-node before to test lunoxjs packages. But it very buggy, since jest esm still experimental. Vitest will solve this problem. This is vitest config, deps.inline is important here so we can directly test the typescript file.

// vitest.config.ts
import { defineConfig } from "vitest/config";
export default defineConfig({
  test: {
    include: ["**/*.test.ts"],
    deps: {
      inline: ["@lunoxjs/core", "@lunoxjs/filesystem"], // add more here
    },
    reporters: "verbose",
  },
});

[Bugs] Lunox Depencency missing when using node v17.4.0

When we start lunox in dev mode pnpm dev lunox is crashing with node v17.4.0, but it's fine in node v16.

compiling ts file...

node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@kodepandai/flydrive' imported from /home/dmuggle/GIT/cobalunox/node_modules/lunox/dist/index.js
Did you mean to import @[email protected]/node_modules/@kodepandai/flydrive/build/index.js?
    at new NodeError (node:internal/errors:371:5)
    at packageResolve (node:internal/modules/esm/resolve:892:9)
    at moduleResolve (node:internal/modules/esm/resolve:938:18)
    at defaultResolve (node:internal/modules/esm/resolve:1041:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v17.4.0

rollup v2.65.0

I still investigate this issue. For now, please using node v16.x.x

[Bugs] Cannot run on Windows

Currently lunox can't run on windows. I don't have windows to test it, but my friend try to run and fail 😞

[Feature Request] Prisma Support

I believe this frameworks main goals to be Laravel of NodeJS right?

currently i don't see any Eloquent Query Builder like ability on this framework.

This is why i propose Prisma support as replacement for the query builder.
although im not sure what is your current plant for building the query builder.
i believe this is gonna be beneficial to the project.

Pros :

  • Easy Data Modelling
  • Easy Pagination, Sorting, Filtering
  • Support for wide array of database SQLite , MySQL, PostgreSQL, MongoDB (Preview), CockroachDB (Preview)
  • Fast Query Engine written in Rust
  • Type Safety

Cons :

  • Lack of polymorphism support
  • Different way to model data and relations compared to Laravel
  • Dependent on third party ORM library
  • Telemetry (can opt-out)

i might be wrong, but please do correct me.

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.