@frp
- Member Since
- Feb 14, 2024
- Lessons Completed
- 53
- Comments Contributed
- 30
- Hours Watched
- 7.05
Recent Activity
Here's what @frp has been up to this past year
-
Commented on post How To Add A Global Property To Your HttpContext in AdonisJS 5
In 6, it looks like HTTPContext is a type, not an interface, so we can't just extend it that way, right?
-
Commented on post Understanding the HttpContext
The adonis 6 docs talk about extending httpcontext through macros and getters. Does that mean we can't just add a property like you do here? Also, contracts are out now, can I just add that interface definition in my app types file? I want to put together an object of properties I need throughout a request and add it to httpcontext. I was thinking of doing it in the route stack middleware. As usual, their documentation only explains about half of what you need to know so I am confused. You explain all this shit way better than they do.
-
Replied to Yeah, validation will come with module 7, which focuses on form...
Ok, so the return earlier is just passing on to the next validator, and unless you have that field.report() method, you are good. Thanks, that makes sense.
-
Commented on post Form Basics and CSRF Protection
Are you going to do anything with form validation? I'm trying to write a custom rule for Vine and the docs don't seem to say what the function should return. In Laravel a validation function returned true or false but I cannot figure it out from the example they use in the Vine docs.
-
Completed lesson Unmapped and Computed Model Properties
-
Replied to Hey frp! When a route calls a controller's method as its handler...
Ok thanks. That might do what I want just as well.
-
Completed lesson Querying Our Movies with the Query Builder
-
Completed lesson Stubbing Fake Data with Model Factories
-
Completed lesson Defining Required Data with Seeders
-
Completed lesson The Basics of CRUD
-
Completed lesson Defining Our Models
-
Completed lesson Introducing Lucid Models
-
Commented on post Cleaning Up Routes with Controllers
Hi Tom!
I'm trying to inject the context into a controller, and it is not working:
import type { HttpContext } from '@adonisjs/core/http' import { inject } from '@adonisjs/core' @inject() export default class JoinController { ctx: HttpContext constructor(ctx: HttpContext) { this.ctx = ctx } }
I got this error message:
Cannot inject "[Function: Object]" in "[class JoinController]
Sorry about the massive font lol. It looks like in the docs but does not work. Any ideas?
-
Replied to Ah - gotcha, so you're using one server to serve multiple sites...
The URL builder in Adonis works fine, so I generate the route strings in my publish service and put the strings in the Edge template. Works great. Thanks!
-
Completed lesson The Flow of Migrations
-
Commented on post Introducing and Defining Database Migrations
which Queen City is yours? Cincinnati?
-
Completed lesson Introducing and Defining Database Migrations
-
Commented on post Understanding our Database Schema
I want more! With a rebel yell, I cry "More! More! More!"
:)
Good stuff!
-
Completed lesson Understanding our Database Schema
-
Completed lesson Configuring Lucid and our Database Connection
-
Completed lesson Easy SVG Icons with Edge Iconify
-
Replied to I just pushed up a working example of subdomain usage you can...
Thanks, I will check it out. I thought I had found the answer (I found "URL Builder" in the docs) but it still won't look up the routes inside Edge. And one clarification: I'm not doing subdomains, I'm doing different domains. It works fine on the routing end - everything routes correctly - but it's just inside Edge that it won't work. I will look at what you did and can probably kitbash it to my usage. I really appreciate all your time. You're a mensch.
Just FYI, this is how I generate the routes in my routes.ts file:
for (let site in Sites) { router .group(() => { router.get('/welcome/:tab?', [WelcomeController, 'welcome']).as('welcome') router.get('/join', [JoinController, 'join']).as('join') router.get('/upgrade', [JoinController, 'upgrade']).as('upgrade') router.resource('users', UsersController).as('users') }) .domain(Sites[site].domain) .as(site) }
-
Replied to I haven't yet worked with subdomains in AdonisJS 6, but I believe...
So this still is not working. I tried it just like that, console.log confirmed it, and it still says it "cannot look up" the route.
How can I recreate the route outside of an Edge template? I don't see a helper for that. Laravel had a route helper you could use anywhere in the app to craft a url string. If I had that I could just craft the string in the service and feed it into Edge. Failing that, I will just have to manually create the URL strings. I can, but for all the reasons you know, would rather not.
Thanks for all your help.
-
Completed lesson Creating Our Base Button
-
Completed lesson Main Slot, Named Slots, and Slot Scopes
-
Completed lesson Serializing Props as Element Attributes
-
Completed lesson Component Props and Default State
-
Completed lesson Component State & Passing State from EdgeJS to ApineJS
-
Completed lesson A Look At Component Reactivity
-
Completed lesson Dynamic Demo Routes for Components
-
Replied to I haven't yet worked with subdomains in AdonisJS 6, but I believe...
Wow thanks. I did not get that from the documentation anywhere. Hey, question: Do you know of any full-featured V6 example site on Github? It would be soooo helpful to see a full example of all this stuff, service providers, the container, everything.
-
Completed lesson Singleton Services and the Idea of Caching
-
Replied to Hi, I am getting the Cannot lookup rote Edge error when I try...
I should probably add that the 'moms' at the start of that route name is for a domain:
router .group(() => { router.get('/join', [JoinController, 'join']).as('join') }) .domain('moms.test') .as('moms')
-
Commented on post EdgeJS Templating Basics
Hi, I am getting the Cannot lookup rote Edge error when I try to use an edge template with the route() helper in it.
Error: Cannot lookup route "moms.join" at anonymous (D:\www\seeds\resources\views\moms\pages\home.edge:95:0) <a class='button' href="{{ route('moms.join') }}">
That route shows up in list:routes:
GET /join (moms.join) .................................................. #controllers/join_controller.joinWhat am I doing wrong? Please let me know what additional information is needed.
Thank you.
-
Completed lesson HTTP Method Spoofing HTML Forms
-
Completed lesson Form Basics and CSRF Protection
-
Completed lesson Share vs Global Data Flow
-
Completed lesson State vs Share Data Flow
-
Completed lesson Extracting A Layout Component
-
Completed lesson Use Slots To Make A Button Component
-
Completed lesson Component Tags, State, and Props
-
Completed lesson Making A Reusable Movie Card Component
-
Completed lesson Vite and Our Assets
-
Completed lesson Loading A Movie Using Route Parameters
-
Completed lesson View Structure and Component-Based Layouts
-
Completed lesson Getting Started, Installing AlpineJS and TailwindCSS
-
Completed lesson Exploring EdgeJS' Component System
-
Replied to It looks like AdonisJS is using the request.url to parse these...
Thanks! I followed the link to the source code and it looks like all I have to do to get what I want is request.hostname(), and that method just pulls the info out of the headers anyway.
-
Replied to Yeah, I've got quite a bit planned including additional focus...
Hi Tom, can you tell me why when I inspect the request object the parsed url host, protocol, etc are always null? I'm not sure the difference between host and hostname (if they were not null I could figure it out haha), but I want to be able to key off of that value in my code. I could grab the host header and parse that, but I'd rather just use the parsedUrl property for everything.
"parsedUrl": { "protocol": null, "slashes": null, "auth": null, "host": null, "port": null, "hostname": null, "hash": null, "search": null, "query": null, "pathname": '/welcome', "path": '/welcome', "href": '/welcome'
-
Replied to Oh hell, I think I know the problem and it has nothing to do...
Yup, that was it. I commented out the domain() and it works. Haha sorry about the wild chicken chase!
-
Replied to Ah - yeah I see! It works fine if you have it at the top-level...
Oh hell, I think I know the problem and it has nothing to do with the import being hoisted. These routes are prefixed by a domain and I am not browsing to the domain. Duh!
-
Replied to Ah - yeah I see! It works fine if you have it at the top-level...
Thanks again. It's weird that the routes show up when you run the ace command, but not in the app. I will try the function solution from your video and see if we get the same issue.
edit: I see what you did in your last comment. You made it dynamic instead of hard-coded like in the tutorial. Ok, I will try the comment approach.
console.log('Hello World!')
Copied! -
Replied to Yeah, if you're looking for something that'll dynamically pick...
So I am getting "Exception Cannot GET:" in the browser on all of my routes. It points to node_modules/send/index.js
debug('stat "%s"', path)
fs.stat(path, function onstat (err, stat) {
if (err && err.code === 'ENOENT' && !extname(path) && path[path.length - 1] !== sep) {
// not found, check extensions
return next(err)
}
if (err)
return self.onStatError(err)
if (stat.isDirectory())
return self.redirect(path)
self.emit('file', path, stat)
self.send(path, stat)
Sorry, I don't know how to make it format code in these comment editors. Earlier it just did it automatically.
-
Replied to Oh rats!! I think something like this might work:// start/routes...
I see what you did there. I will give that a try and report back! lol Thanks
…. It worked! I have routes!
-
Replied to Yeah, I used the functions on an earlier test and it worked ...
I guess it didn't work. Server did not throw an error but list:routes does not show any routes. Back to the drawing board!
-
Replied to Yeah, the primary thing that matters is where the route definition...
Yeah, I used the functions on an earlier test and it worked great. Probably easier but I'm trying to learn the whole module imports thing so I wanted to try it this way. I made a subdir routes off of start and this is what I did. It appears to be working (didn't throw an error). Thanks!
import router from '@adonisjs/core/services/router' import { fsReadAll } from '@adonisjs/core/helpers' const files = await fsReadAll(new URL('./routes', import.meta.url), { pathType: 'url' }) console.log(files) const imps: string[] = files.map((el) => { return el.substring(el.lastIndexOf('/') + 1, el.lastIndexOf('.')) }) console.log(imps) router.group(async () => { for (let domain of imps) { await import(`./routes/${domain}.js`) } })
Copied! -
Replied to Yeah, I used to provide both written and video formats for every...
Yeah, absolutely, I can imagine. I'm sure you are trying to crank out a million now to get people up to speed with Adonis 6. Must be crazy with all the changes they made. My below comment was because I'm trying to figure out for myself how to make these Adonis 5 tutorials work in Adonis 6, since you have so much stuff for A5 that I need to use.
-
Commented on post Multi-File Route Grouping Strategies
If we were to modify this to Adonis 6, we would need to change that require to an import, right? I was thinking we would want to put "await import('./routegroup.ts')" where you have the require? I guess if the enclosing function is not already async we would have to use the .then construction. Hm. As you can see, I'm still trying to master these concepts
-
Commented on post Multi-File Route Grouping Strategies
I noticed on some lessons, you have the text with screenshots like this one, and other lessons you don't. I love this format because I would much rather read than watch a video and it is great to be able to come back to it and scroll to the section I need. This is well-done. Hey, I put in a plug for Adonis to hire you for their tutorials when they start them :)
-
Commented on post How To Add InertiaJS to a New AdonisJS Project
I love how you say Laravel is "kinda similar" to Adonis. That made me laugh. I came to Adonis from Laravel, and it feels like a port of Laravel to Node.JS. :)
-
Commented on post Updating Our URL & Populating Filter Field Values
this looks really cool. I had never heard of htmx. With htmx you can get an SPA feel with Edge templates.
-
Completed lesson Updating Our URL & Populating Filter Field Values
-
Completed lesson Posting & Swapping Filtered Content with HTMX
-
Completed lesson Defining Our AdonisJS Filter Form Handler
-
Completed lesson Creating Our Filter Query with AdonisJS
-
Completed lesson Installing HTMX & Project Overview
-
Replied to Agreed, and thank you for the suggestion! It'd be good to cover...
Thanks Tom. I imagine you also will be updating a lot of your v5 lessons to v6. I really like your style. I find you way easier to understand than most tutorialists
-
Completed lesson Understanding the HttpContext
-
Completed lesson HTML Attribute and Class Utilities
-
Completed lesson EdgeJS Templating Basics
-
Completed lesson Linking Between Routes
-
Completed lesson Rendering a View for a Route
-
Commented on post Rendering a View for a Route
It would be cool to get some tutorials on using other output options, like pushing to a SPA or using a different templating engine.
-
Completed lesson Bouncer Actions & Authorizations
-
Completed lesson Introducing, Installing, & Configuring Bouncer
-
Completed lesson Let's Learn Adonis 5: Validating Requests
-
Completed lesson Service Providers & The IoC Container
-
Completed lesson Static, Non-Static, & Singleton Services
-
Completed lesson Easy Imports with NodeJS Subpath Imports
-
Completed lesson Quick Start Apps with Custom Starter Kits
-
Completed lesson Improved Caching with Redis
-
Completed lesson Environment Variables and their Validation
-
Account created Welcome to Adocasts, @frp!