And with that, we got all these event controller functions linked to the routes.
Now what we can also do is get rid of these prefixes here, slash events, because that
prefix will actually be added one level above in the app.js file.
In this routes file, I only have events routes, and this prefix doesn't need to be repeated
here.
So I'll actually select all of that and just delete it, and add a slash here, and also
here.
Okay, now we can go to app.js and make sure that the event routes are added here.
And here, I'm probably quickest if I just do that manually and import my events routes
from routes events.js, thanks for auto-completing this.
And then here, I can app.use slash events and point at the events routes.
And that's this slash events prefix I mentioned a second ago.
Okay, so that was a lot of talking about this, but let's see whether this now works.
For that, I'll now run npm run dev to start that development server, and I got an error.
Cannot find module database.js imported in the event.js file.
Let's see.
Yeah, the import path is wrong.
We need to go up one level.
So that was generated incorrectly.
And now, if I run that, looks better.
Let's see whether it works by sending a request where we try to create an event.
Or actually first, we can send a get request to get all events.
We don't have any yet, but the request should work nonetheless.
It just shouldn't return anything.
So if I send a request, a get request to localhost 3000 slash events, I get back an empty array,
which makes sense to me.
Now let's send a post request to localhost 3000 events.
And I get back an object with an event ID.
I don't get back an error, even though I did not attach any data because I haven't added
any validation yet.
That's something we have yet to do.
Currently, I don't validate anything.
I create an event either way.
And that at least seems to work because that event object was then also returned.
It's this thing here.
Now I won't test the other routes just yet.
We'll do that later.
But initially, it looks like everything's working and we can therefore now fine tune
and tweak those controllers and make sure that we do really create the events the way
we want them to create.
And for example, we should also add validation.