Full Stack Development with Svelte & SvelteKit – Part II
This repository contains the project code for Part II of the workshop. On this readme, you can find all information
necessary to work the hands-on exercise of Part II.
Resources
Getting Started
First things first, you need to clone this repository to your local machine. After that, you first can install
dependencies and then initialize the environment variables. After that it should be possible to run the dev server,
If you prefer to work in a sandboxed browser environment, you can open the repository in StackBlitz, instead.
Everything should work the same.
# clone the repo
git clone https://github.com/nilsroehrig/full-stack-svelte-part-2.git
# in repository folder, checkout exercise starting point
git checkout exercise
# install deps
npm ci
# initialize env
node init.js
# run dev server
npm run dev
The dev server is available at localhost:5173.
Hands-On Exercise
Creating Events
- Add a new page at
/events/create
that contains a form to create a new event.
- The page should contain a form to enter all necessary information for an event. See the
Event
entity in the server/src/entities
folder for reference.
- The page should define a form action that processes the form data and creates a new event in the database. Use zod-form-data to validate the form data.
- The new page should be accessible via the navigation bar.
Event Details
- Add a new page at
/events/[id]
that accepts an event as a prop and displays the details of said event. This should include the name of the owner and the number of participants as well.
- The page should display wether the current user is the owner of the event.
- The page should define a server load function that fetches the event with id [id], as well as its related data from the database.
- Clicking on an event in the events list should navigate to the event details page.
Participating in & Leaving Events
- On the event details page, add a button to participate in the event.
- If the user is already participating in the event, the button should instead allow the user to leave the event.
- The page should define form actions to handle the participation and leaving of events.
Edit Events
- Add a new page at
/events/[id]/edit
that accepts an event as a prop and contains a form to edit said event.
- The page should define a server load function that fetches the event with id [id] from the database.
- The page should define a form action that processes the form data and updates the event in the database.
- It should not be possible to edit events of which the user is not the owner.
- The page should be accessible via the event details page.
Deleting Events
- On the event details page, add the option to delete the event.
- The page should define a form action that deletes the event from the database.
- It should not be possible to delete events of which the user is not the owner.
Displaying Participtions
- On the startpage, add a new section that displays all events the user is participating in.
Display All Events
- Add a new page at
/events
that displays all events in the database.
- The page should define a server load function that fetches all events from the database ordered by date. The
order
option of any repository find method can be used to achieve this.
- The new page should be accessible via the navigation bar.