microeinhundert / radonis

Build monolithic applications with a modern, React-based frontend stack based on the Node.js MVC framework AdonisJS.
https://radonis.vercel.app/
MIT License
67 stars 2 forks source link

Type '"AuthController.login"' is not assignable to type '"drive.local.serve"'. #1

Closed finestgecko closed 2 years ago

finestgecko commented 2 years ago

First of all, thank you for your efforts with this amazing project :tada: I think it's a considerable addition to the AdonisJS ecosystem and I'm really enjoying working with it.

I'm still learning how things work with Radonis. I copied the "old-school way" example from the Forms section in the docs, but I get a TypeScript error in Visual Studio Code on the action prop:

image

import { useFlashMessages, Form } from '@microeinhundert/radonis'

export default function Login({}: ILoginProps) {
  const { tx } = useTwind()

    return (
        <Form
              method="post"
              action="AuthController.login" // 👈 this prop
              reloadDocument
        >
            ...
        </Form>
    )
}

The route is registered:

Route.post('/auth/login', 'AuthController.login')

P.S. A quick suggestion—I think it would be useful if the docs could have a somewhat more gentle introduction to the Hydration concept. I know it's not a Radonis-specific concept but having never used hydration before, I'm not really sure where to apply it.

microeinhundert commented 2 years ago

Thank you. The type generation is currently not working as intended and will be fixed in the latest version coming out soon. Until then, a restart of the server should fix the problem and the Route should be available. If not, excluding the /tmp directory from TypeScript should disable the generated types. I will get back to you once it's fixed.

finestgecko commented 2 years ago

@microeinhundert Thank you, I'll give it a try.

Without digressing too much from the issue, do you plan to open Discussions for the repo or a Discord channel perhaps? I can't seem to figure out the client-side interactivity.

microeinhundert commented 2 years ago

I published a new version 1.9.2 with fixed type generation. There are a few things to keep in mind (your issue was one of them) which are now documented in the docs. The dev server must be restarted manually after adding new routes to the application. This is a technical limitation which I hope to remove long term.

The Discussions here on GitHub are also now enabled for the repository, feel free to ask questions there.

finestgecko commented 2 years ago

I published a new version 1.9.2 with fixed type generation. There are a few things to keep in mind (your issue was one of them) which are now documented in the docs. The dev server must be restarted manually after adding new routes to the application. This is a technical limitation which I hope to remove long term.

The Discussions here on GitHub are also now enabled for the repository, feel free to ask questions there.

Thank you. I updated the dependencies:

joel@office:~/qms$ npx npm-check-updates -i
Need to install the following packages:
  npm-check-updates
Ok to proceed? (y) y
Upgrading /home/joel/qms/package.json
[====================] 40/40 100%

 @adonisjs/i18n                    ^1.5.0  →    ^1.5.6     
 @microeinhundert/radonis          ^1.9.1  →    ^1.9.2     
 @microeinhundert/radonis-server   ^1.9.1  →    ^1.9.2     
 @microeinhundert/radonis-twind    ^1.9.1  →    ^1.9.2     
 @microeinhundert/radonis-unocss   ^1.9.1  →    ^1.9.2     
 @types/react                     ^18.0.0  →  ^18.0.20     
 @types/react-dom                 ^18.0.0  →   ^18.0.6     
 typescript                          ~4.6  →      ~4.8     

Then I tried to run the application and got this:

[dev:*server]   Error 
[dev:*server] 
[dev:*server]  Cannot find module '../src/AssetsManager'
[dev:*server] Require stack:
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@microeinhundert+radonis-server@1.9.2_ul64gqjd5kvqldtwaiwi4ak7qq/node_modules/@microeinhundert/radonis-server/build/providers/RadonisProvider.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@poppinss+utils@4.0.4/node_modules/@poppinss/utils/build/src/esmRequire.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@poppinss+utils@4.0.4/node_modules/@poppinss/utils/build/index.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@adonisjs+require-ts@2.0.12/node_modules/@adonisjs/require-ts/build/src/Compiler/index.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@adonisjs+require-ts@2.0.12/node_modules/@adonisjs/require-ts/build/index.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@adonisjs+assembler@5.8.1_@adonisjs+core@5.8.6/node_modules/@adonisjs/assembler/build/src/requireHook/index.js
[dev:*server] - /home/joel/qms/node_modules/.pnpm/@adonisjs+assembler@5.8.1_@adonisjs+core@5.8.6/node_modules/@adonisjs/assembler/build/register.js
[dev:*server] - internal/preload
[dev:*server] 
[dev:*server] 
[dev:*server]    1  Object.callback
[dev:*server]      /home/joel/qms/node_modules/.pnpm/@microeinhundert+radonis-server@1.9.2_ul64gqjd5kvqldtwaiwi4ak7qq/node_modules/@microeinhundert/radonis-server/build/providers/RadonisProvider.js:51
[dev:*server] 
[dev:*server]    2  Bindings.resolve
[dev:*server]      /home/joel/qms/node_modules/.pnpm/@adonisjs+fold@8.2.0/node_modules/@adonisjs/fold/build/src/Ioc/Bindings.js:47
[dev:*server] 
[dev:*server]    3  Ioc.resolveBinding
[dev:*server]      /home/joel/qms/node_modules/.pnpm/@adonisjs+fold@8.2.0/node_modules/@adonisjs/fold/build/src/Ioc/index.js:266
[dev:*server] 
[dev:*server]    4  anonymous
[dev:*server]      /home/joel/qms/node_modules/.pnpm/@adonisjs+fold@8.2.0/node_modules/@adonisjs/fold/build/src/Ioc/index.js:414
[dev:*server] 
[dev:*server]    5  Ioc.withBindings
[dev:*server]      /home/joel/qms/node_modules/.pnpm/@adonisjs+fold@8.2.0/node_modules/@adonisjs/fold/build/src/Ioc/index.js:414
[dev:*server] 
[dev:*server] [ warn ]  Underlying HTTP server died with "0 code"
[dev:*server] [ info ]  watching file system for changes

It seems that the AssetsManager path is wrong: https://github.com/microeinhundert/radonis/blob/dd97441085c923be1c907390e98d6368fc4476d6/packages/radonis-server/providers/RadonisProvider.ts#L70

If I go into node_modules and edit the RadonisProvider:

Seems to have fixed it.

image

microeinhundert commented 2 years ago

It seems like pnpm does not detect the changes I made to folder casing when updating dependencies. Deleting node_modules and reinstalling should also fix it, although I would find it odd if pnpm had such bug. It worked for me when testing with npm.

finestgecko commented 2 years ago

It seems like pnpm does not detect the changes I made to folder casing when updating dependencies. Deleting node_modules and reinstalling should also fix it, although I would find it odd if pnpm had such bug. It worked for me when testing with npm.

Hmm, it's a strange one.

I already tried deleting node_modules before, but I reinstalled with pnpm. Just tried it again, this time reinstalling with npm instead, but I get the same problem. I also tried clearing the cache, to no avail.

I'll keep trying to see if I can figure it out.

microeinhundert commented 2 years ago

I know what the problem is. I'm on a mac and macOS behaves differently with folder casing. Patch is coming very soon.

microeinhundert commented 2 years ago

It should be fixed now in version 1.9.3.

finestgecko commented 2 years ago

It should be fixed now in version 1.9.3.

It's working perfectly! Thanks so much for your help. :pray: