what is a Course Builder "session"?
When using NextAuth, constructing the route with the configuration returns a handler that drives the API and the router. It also returns an object that provides a method to get the current user's session. This is useful because it includes user data and even provides a middleware with a callback to augment if needed.
Course Builder essentially mimics this functionality. When you call the Course Builder service, it allows you to await a builder on the server side, similar to awaiting an auth and getting the session back in the NextAuth.
This 'Course Builder' internal lives in the core of your system. This is where the 'switch' statement lives and where actions are made. A get session is called that awaits and returns a response. Currently, this response just returns as an empty body.
This conduit between NextAuth and Course Builder is where you potentially add things. Essentially the Course Builder 'session' more or less integrates with a NextAuth 'session'. This, being server-side, has sound knowledge about who and what it's dealing with. It can access user data and other useful details.
This could be coupled with NextAuth, but it's considered advantageous to separate and handle it from Course Builder's end. The ultimate goal is to morph this into a helper that can be called at various places for commerce or progress.
Transcript
[00:00] So with NextAuth, one of the things that you get when you construct the route and use the... This would be NextAuth and NextAuth, and you pass the config and here's all that bit, and you get back the handler, so get and post, and that's what drives the API and the router, and then it returns this object. So in nextAuth, if I come over here and we look at auth, we'll see that what it provides is off and when you call this as a method then it gives you the current users session so we say get server off session so this is what we use around because I combine that with ability So you get the session which has the user and other bits on there and that even gives you this middleware so we have a callback so we can call back onto that and augment it if we want to which is really nice. And for course builder I'm doing something of the same thing here in that when you call next course builder config I don't know why these are lighting up right now I assume it's because of this. Anyway, so it's not affecting the running of it, just some type errors that will get fixed.
[01:35] But anyway, so now when I run this, and this is just this page, I can await course builder, right? So this is similar to where that was, auth here where we're awaiting auth and we get the session back. In this case, on server side, I can wait course builder and that's in my actions. So if I come over here, this is the course builder internal. So this lives in core.
[02:09] And this is basically the router, right? Like this is where the switch statement lives and actions are called. And if we call a get session, that's awaits that and returns that response. And right now all that is doing is returning this, right? Like, so the body of that response is nothing, but like the idea here is what's a course builder session and this is where you can add stuff like because we'd we're server-side so we have some decent knowledge of who and what we're dealing with and we're in the context of NextAuth so we can access the user and all that fun stuff and what does that mean and what does that get returned here is interesting to me so that we end up with a helper at the end of the day that we can call in various places for commerce or progress or what does a Course Builder session look like for a user.
[03:15] This could also be hung on NextAuth, but I think there is some advantage to separating it out and doing it from Course Builder.