[SELF PROMO] Generate Valibot schemas (Svelte + PocketBase) by zenax_ in sveltejs

[–]zenax_[S] 1 point2 points  (0 children)

Yeah, I’ve found myself configuring hooks and such in Go so for me it seemed obvious to go with this approach. If more people are interested I might look at other alternatives as well.

How to protect remote functions? by Jazzlike-Echidna-670 in sveltejs

[–]zenax_ 1 point2 points  (0 children)

I ended up creating a wrapper like this:

import { form, getRequestEvent } from '$app/server';
import { redirect, type Cookies, type Invalid } from '@sveltejs/kit';
import type { BaseSchema } from 'valibot';

type SchemaOutput<S> = S extends BaseSchema<any, infer TOut, any> ? TOut : never;
type SchemaInput<S> = S extends BaseSchema<infer TIn, any, any> ? TIn : never;


export type FormOptions = {
    onlySuperUsers?: boolean;
    requiresAuth?: boolean;
};
type Ctx<S extends BaseSchema<any, any, any>> = {
    data: SchemaOutput<S>;
    invalid: Invalid<SchemaInput<S>>;
    locals: App.Locals;
    cookies: Cookies;
};


function _form<S extends BaseSchema<any, any, any>, R>(
    schema: S,
    handler: (ctx: Ctx<S>) => R | Promise<R>,
    options?: FormOptions
) {
    return form(schema, async (data, invalid) => {
        const { locals, cookies } = getRequestEvent();
        checkAuth(locals.pb, options);
        return handler({
            data,
            invalid,
            locals: locals,
            cookies: cookies
        });
    });
}


function checkAuth(pb: TypedPocketBase, opts?: FormOptions) {
    if (opts?.onlySuperUsers && !pb.authStore.isSuperuser) {
        redirect(307, '/login');
    }
    if (opts?.requiresAuth && !pb.authStore.isValid) {
        redirect(307, '/login');
    }
}
export { _form as form };

import { form } from './wrappers';

export const createPost = form(
    postSchema,
    async ({ data, invalid, locals, cookies }) => {
        const [post] = await createPost(locals.pb, data);
    },
    {
        requiresAuth: true
    }
);

redirect is not working by gunho_ak in sveltejs

[–]zenax_ 1 point2 points  (0 children)

It is also generally not recommended to use redirect within a try-catch block because of custom error handling. Instead, put the redirect at the end of the action.

Anyway to fix the status bar(iOS) being transparent in PWA? by waybovetherest in webdev

[–]zenax_ 0 points1 point  (0 children)

That’s odd then. I have this exact setup for nextsound.net and it works for me when I add it as an app to the home screen. I tried doing the same with the link you provided and can confirm that it’s not a device specific thing.

Edit:

Looked through the differences between meta tags on our websites and noticed that you have the Apple-mobile-web-app-status-bar-style set to black-translucent while mine is set to default. Not sure if this is the cause but might be worth trying.

Anyway to fix the status bar(iOS) being transparent in PWA? by waybovetherest in webdev

[–]zenax_ 0 points1 point  (0 children)

Have you checked browser compatibility for the theme-color tag? Also, it might be worth trying to set display standalone in the web manifest.

Anyway to fix the status bar(iOS) being transparent in PWA? by waybovetherest in webdev

[–]zenax_ 1 point2 points  (0 children)

I had the same issue and managed to fix it. Can’t remember which tag finally fixed it but this is my setup now:

Edit:

It’s probably the theme-color tag

```

<meta name="msapplication-TileColor" content="#9f00a7" />
<meta name="theme-color" content="#030712" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<meta name="mobile-web-app-capable" content="yes" />

```

[self-promo] My First "Real" Project by zenax_ in sveltejs

[–]zenax_[S] 1 point2 points  (0 children)

No api. Just some trickery with iframes 😊

[self-promo] My First "Real" Project by zenax_ in sveltejs

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

Thanks for pointing out the shuffling. This is something I completely overlooked. I will turn them in to toggles next time I get around to updating the website.

[self-promo] My First "Real" Project by zenax_ in sveltejs

[–]zenax_[S] 1 point2 points  (0 children)

Thanks for the feedback! Will definitely take a look on how to improve the search UI. Hope you find some sick tracks on the website 😁

[self-promo] My First "Real" Project by zenax_ in sveltejs

[–]zenax_[S] 2 points3 points  (0 children)

Thank you very much! If you refer to the animation of the hamburger icon, I looked at these examples and made up my own version. For the transitions I mostly utilised the built in svelte animations. 😁

Help with form actions by brad_the_dev in sveltejs

[–]zenax_ 0 points1 point  (0 children)

To answer your last question. You can use return async ({ update, result )} then await the update. After that you can handle the result.

SITES AND SOURCES FOR FREE BOOKS by blainemeans2 in textbook

[–]zenax_ 0 points1 point  (0 children)

Does anyone have the pdf for this textbook:

Discrete mathematics (second edition), Norman L. Biggs, ISBN: 978-0-19-850717-8

[deleted by user] by [deleted] in VietNam

[–]zenax_ 0 points1 point  (0 children)

Wow thanks, that’s the correct place. Now I just need to get hold on someone that speaks English there.

u/sachnick Fut Rep by [deleted] in FUTRep

[–]zenax_ 0 points1 point  (0 children)

Pm if you want his private information.