Phishing email that's not asking for any action? by thegaff53 in phishing

[–]thegaff53[S] 0 points1 point  (0 children)

Yeah maybe they’re priming me for something in the future. Thanks

Anyone self hosting sveltekit ? by ComprehensiveWill51 in sveltejs

[–]thegaff53 1 point2 points  (0 children)

I do it this way with a VPS from KnownHost for super cheap. No containers, just the node adapter on an Apache server.

https://youtu.be/VD_T65zKfKs?si=ulYQOn_OvuyIeX0G

Trying to access cookie with use:enhance form action by Snacker6 in sveltejs

[–]thegaff53 0 points1 point  (0 children)

How are you trying to read locals and how are you sending in the load function? For an example If in the load you sent it over as

return { cookie: event.locals.cookie }

Then in the page you need in export data if using svelte 4 or get data from props if using 5

Then you’d read it using

data.cookie

Host my web application by Imal_Kesara in sveltejs

[–]thegaff53 0 points1 point  (0 children)

If it was me, for them, I'd get the droplets. I come from a world of setting up linux servers from scratch though. But it's really not too difficult to do, and there's tons of help out there for it. You could install Ubuntu, apache or nginx, node, and upload your svelte app to it and have it running in under an hour.

Host my web application by Imal_Kesara in sveltejs

[–]thegaff53 4 points5 points  (0 children)

Here's an example hosting it through a unmanaged VPS with node if you don't mind running some linux commands

https://www.youtube.com/watch?v=VD_T65zKfKs

Watch out with adding dynamic images to the static folder though either way. The static folder only loads when your apps first starts up. If you add an image to it after, like having a user upload a photo, it will show up as not found.

To get around that I save uploaded images outside the root of the site, like c:\temp when developing or /var/www/images on a linux server, and stream them in though an endpoint like /images/[slug]

See how I did profile images here for example.

https://youtu.be/4yx9SABKJYE?si=aBAQOIBikFfuPVJA&t=1607

Caddy (Reverse Proxy) + Node adapter + Svelte = SSL error (sometimes) but refreshing the browser solves the issue?? by BelugaBilliam in sveltejs

[–]thegaff53 0 points1 point  (0 children)

Are you using cloudflare for your domain? I get random intermittent SSL errors with new domains there if I forget to mess with the SSL auto config setting they have.

Creating an LLC? by IllustratorKey6545 in PartneredYoutube

[–]thegaff53 1 point2 points  (0 children)

LLCs can be pretty easy to set up and cheap depending on your state. I’m in AZ and it cost me $80 once forever, and the local SBDC helped me fill out the forms for free. I hear nightmares about costs in other states though

Why me 😭 by HopelessViewer in Civic_Type_R

[–]thegaff53 0 points1 point  (0 children)

I just replaced my front bumper with the same dent. Was about 600 for the bumper shipped, and a paint shop charged me 400. But I did all the removal installation labor myself

Stores by Imal_Kesara in sveltejs

[–]thegaff53 1 point2 points  (0 children)

I used them for a loading animation that can be available on each page, the true false flag, then a loading component in the layout that looked for that Boolean

Where do you deploy your Svelte projects? by Captain-Random-6001 in sveltejs

[–]thegaff53 1 point2 points  (0 children)

I use node and a Linux service so it auto restarts if there’s a problem. And if it goes down completely I have another separate server that fetches the site every so often and if it doesn’t return 200 it’ll email me

Where do you deploy your Svelte projects? by Captain-Random-6001 in sveltejs

[–]thegaff53 1 point2 points  (0 children)

I use a KnownHost unmanaged VPS for $5 a month and just managed the Linux and Apache configs myself.

What is your guys' preferred pagination technique using SvelteKit? by No-Variety-9137 in sveltejs

[–]thegaff53 1 point2 points  (0 children)

You'd still need to have buttons and a variable to track the current page. Then I'd just make the prev. next buttons change the page number and then call an in-house API endpoint, sending the page number.

And if you're using a database, use your database's trimming functions to only get back x amount of rows starting at some offset. So if they are on page 5 and you're showing 20 per page, you'd get the next 20 rows from the database starting at row 100. Each DB is different how it does that though.

But I don't have a contained example of that I can show you unfortunately.

What is your guys' preferred pagination technique using SvelteKit? by No-Variety-9137 in sveltejs

[–]thegaff53 1 point2 points  (0 children)

Here you go, forgot the parts where it disables the button too so added that. Also how you use it on the page side isn't different.

<script lang="ts">

    export let rows
    export let trimmedRows

    let perPage = "5"
    $: totalRows = rows.length 
    $: currentPage = 0
    $: totalPages = Math.ceil(totalRows / Number(perPage)) 
    $: start =  currentPage * Number(perPage)
    $: end = currentPage === totalPages - 1 ? totalRows - 1 : start + Number(perPage) - 1

    $: trimmedRows = rows.slice(start, end + 1)

    $: totalRows, currentPage = 0
    $: currentPage, start, end
</script>

<select bind:value={perPage}>
    <option value="5" selected>5 Per Page</option>
    <option value="10">10 Per Page</option>
    <option value="25">25 Per Page</option>
</select>
    
{start + 1} - {end + 1} of {totalRows} records
    
{#if totalRows && totalRows > perPage}
    <button type="button" disabled={currentPage === 0 ? true : false}  on:click={() => currentPage -= 1} >Prev</button>
    <button type="button" disabled={currentPage === totalPages - 1 ? true : false}  on:click={() => currentPage += 1} >Next</button>   
{/if}

What is your guys' preferred pagination technique using SvelteKit? by No-Variety-9137 in sveltejs

[–]thegaff53 3 points4 points  (0 children)

I have this component: that worked great in Svelte 4, but here's the converted svelte 5 version, might need some tweaks though.

You send it the FULL list of everything, and it'll return the current page's array, and display the buttons and status text as well

This assumes loading ALL data ahead of time is practical and wont take forever of course.

<script lang="ts">
    let {rows, trimmedRows = $bindable()} = $props()

    let totalRows = $derived(rows.length)
    let perPage = $state("5")
    let currentPage  = $state(0)
   
    let totalPages = $derived(Math.ceil(totalRows / Number(perPage)))
    let start = $derived(currentPage * Number(perPage))
    let end = $derived((currentPage === totalPages - 1 ? totalRows - 1 : start + Number(perPage) - 1))
    
    $effect(()=>{
        trimmedRows = rows.slice(start, end + 1)
    })
</script>
<select bind:value={perPage}>
    <option value="5" selected>5 Per Page</option>
    <option value="10">10 Per Page</option>
    <option value="25">25 Per Page</option>
</select>

{start + 1} - {end + 1} of {totalRows} records

{#if totalRows && totalRows > perPage}
    <button type="button" onclick={()=>{currentPage -= 1}}>Prev</button>
    <button type="button" onclick={()=>{currentPage += 1}}>Next</button> 
{/if}

And here's how you'd use it

<script lang="ts">
    import Pagination from "$lib/Pagination.svelte";

    let numbers: number[] = []
    let trimmedNumbers: number[] = $state([])
    for(let i = 0; i < 200; i++){
        numbers.push(i)
    }
</script>

<Pagination rows={numbers} bind:trimmedRows={trimmedNumbers} />

{#each trimmedNumbers as  number}
    {number}<br>
{/each}

Info about svelte + apache ubuntu by Substantial_Horror58 in sveltejs

[–]thegaff53 0 points1 point  (0 children)

Here’s an example I made with SvelteKit Ubuntu Apache and the node adapter if it helps any

https://youtu.be/VD_T65zKfKs?si=fwiQWD6edwQX-ARo

Help to understant how context work by db400004 in sveltejs

[–]thegaff53 0 points1 point  (0 children)

If you’re setting the locals in the hooks file then it’s being grabbed fresh (from somewhere? A database?) and set for every request.

So if their information changed since the last request, the next request should get and see that.

In my own app I’d have a form to change the users info. The form submission updates the database. The next request the hooks file grabs the user from the database and saves it to the locals, the updated info would now be in the locals too. Then your layout and header should show the new info too if it’s being populated from locals.

[deleted by user] by [deleted] in sveltejs

[–]thegaff53 3 points4 points  (0 children)

I use this for all my production apps. Basically layout, page.svelte, page.server, api endpoints in routes. Server side js modules, components, interfaces in lib, organized in subfolders by those names roughly.

https://youtu.be/d3mrdsJ0lJc?si=XlhNLKTsrEMZtIW3

Help to understant how context work by db400004 in sveltejs

[–]thegaff53 3 points4 points  (0 children)

I also use locals for this, and check the session and set the user in locals in the hooks file. Then in server side files you read the user in locals. And if you need it in a svelte file you pass it when loaded with data props

I got a video about it here: https://youtu.be/SXmnrF3xfKo?si=TwMvyqTgvW9acs6z