Dog
Dog
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
I normally get stuck on problems for weeks 😆
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
oh my bad I thought you hadn't
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
or did you all ready solve this?
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
no this is what you can do for your question, do the <Show when={session}
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
I was doing somethig like this to get the session user data but this was sing the old solid-start
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
export const authOpts: SolidAuthConfig = {
adapter: PrismaAdapter(prisma),
providers: [
Google({
clientId: serverEnv.GOOGLE_CLIENT_ID,
clientSecret: serverEnv.GOOGLE_CLIENT_SECRET,
})
],
callbacks: {
async session({ session, user }) {
if (session.user) {
session.user.id = user.id;
}
const signingSecret = serverEnv.SUPABASE_JWT_SECRET
if (signingSecret) {
const payload = {
aud: "authenticated",
exp: Math.floor(new Date(session.expires).getTime() / 1000),
// sub: user.id,
email: user.email,
role: "authenticated",
}
session.supabaseAccessToken = jwt.sign(payload, signingSecret)
}
return session
},
},
debug: false,
};
export const authOpts: SolidAuthConfig = {
adapter: PrismaAdapter(prisma),
providers: [
Google({
clientId: serverEnv.GOOGLE_CLIENT_ID,
clientSecret: serverEnv.GOOGLE_CLIENT_SECRET,
})
],
callbacks: {
async session({ session, user }) {
if (session.user) {
session.user.id = user.id;
}
const signingSecret = serverEnv.SUPABASE_JWT_SECRET
if (signingSecret) {
const payload = {
aud: "authenticated",
exp: Math.floor(new Date(session.expires).getTime() / 1000),
// sub: user.id,
email: user.email,
role: "authenticated",
}
session.supabaseAccessToken = jwt.sign(payload, signingSecret)
}
return session
},
},
debug: false,
};
export const useSession = () => {
return createServerData$(
async (_, { request }) => {
return await getSession(request, authOpts)
},
{ key: () => ["auth_user"] }
)
}

const AuthShowcase: VoidComponent = () => {
const session = useSession();
return (
<div>
<Show
when={session()}
fallback={
<button
onClick={() => signIn("google", { redirect: false })}
>
Sign in
</button>
}
>
<span>Welcome {session()?.user?.name}</span>
<button
onClick={() => signOut({ redirect: true, redirectTo: "/" })}
>
Sign out
</button>
</Show>
</div>
);
};
export const useSession = () => {
return createServerData$(
async (_, { request }) => {
return await getSession(request, authOpts)
},
{ key: () => ["auth_user"] }
)
}

const AuthShowcase: VoidComponent = () => {
const session = useSession();
return (
<div>
<Show
when={session()}
fallback={
<button
onClick={() => signIn("google", { redirect: false })}
>
Sign in
</button>
}
>
<span>Welcome {session()?.user?.name}</span>
<button
onClick={() => signOut({ redirect: true, redirectTo: "/" })}
>
Sign out
</button>
</Show>
</div>
);
};
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
ok I think I have another project that used prisma let me check
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
because I'm trying to implement row level security with supabase and can't get it to work
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
oh ok do you use supabase with lucia?
19 replies
SSolidJS
Created by sh1man on 3/7/2024 in #support
what write so as not to constantly write a redirect in every function in case of unauthorize
Are you using supabase and @solid-mediakit/auth?
19 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
import { createServerData$ } from 'solid-start/server';
import { useRouteData } from '@solidjs/router';
import {
createResource,
Show,
type Component,
createSignal,
createEffect
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { compile, run, } from '@mdx-js/mdx';
import * as runtime from 'solid-jsx';
import { MDXProvider } from 'solid-jsx';
import { YouTube, type YouTubeProps } from 'solid-social';

export const routeData = () => {
return createServerData$(async () => {
const markdown = `
## Title
---
<YouTube youTubeId="C0DPdy98e4c" />
`;
const compiledMarkdown = String(
await compile(markdown, {
outputFormat: 'function-body',
jsxImportSource: 'solid-js',
providerImportSource: '#',
})
);
return compiledMarkdown
});
};

export default function serverSideRender() {
const rd = useRouteData<typeof routeData>();

const [compiledMarkdown, setCompiledMarkdown] = createSignal();

createEffect(() => {
setCompiledMarkdown(rd())
})

const getContent = async () => {
const { default: Content } = (await run(compiledMarkdown(), runtime)) as unknown as { default: Component };
return Content;
};

const [data] = createResource(compiledMarkdown, getContent);


return (
<MDXProvider
components={{
YouTube: (props:YouTubeProps) => <div><YouTube {...props} /></div>
}}
>
<h1>Server Side Render</h1>
<div>
<Show when={!data.loading && data()}>
<Dynamic component={data()} />
</Show>
</div>
</MDXProvider>
);
}
import { createServerData$ } from 'solid-start/server';
import { useRouteData } from '@solidjs/router';
import {
createResource,
Show,
type Component,
createSignal,
createEffect
} from 'solid-js';
import { Dynamic } from 'solid-js/web';
import { compile, run, } from '@mdx-js/mdx';
import * as runtime from 'solid-jsx';
import { MDXProvider } from 'solid-jsx';
import { YouTube, type YouTubeProps } from 'solid-social';

export const routeData = () => {
return createServerData$(async () => {
const markdown = `
## Title
---
<YouTube youTubeId="C0DPdy98e4c" />
`;
const compiledMarkdown = String(
await compile(markdown, {
outputFormat: 'function-body',
jsxImportSource: 'solid-js',
providerImportSource: '#',
})
);
return compiledMarkdown
});
};

export default function serverSideRender() {
const rd = useRouteData<typeof routeData>();

const [compiledMarkdown, setCompiledMarkdown] = createSignal();

createEffect(() => {
setCompiledMarkdown(rd())
})

const getContent = async () => {
const { default: Content } = (await run(compiledMarkdown(), runtime)) as unknown as { default: Component };
return Content;
};

const [data] = createResource(compiledMarkdown, getContent);


return (
<MDXProvider
components={{
YouTube: (props:YouTubeProps) => <div><YouTube {...props} /></div>
}}
>
<h1>Server Side Render</h1>
<div>
<Show when={!data.loading && data()}>
<Dynamic component={data()} />
</Show>
</div>
</MDXProvider>
);
}
Thank you so much, it's working with server side compiling now
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
So now it works client side it should be able to work compiling server side then running client side as you mentioned before
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
ah yeah I was doing
import * as runtime from 'solid-js/jsx-runtime';
import * as runtime from 'solid-js/jsx-runtime';
instead of
import * as runtime from 'solid-jsx';
import * as runtime from 'solid-jsx';
probably missed it when I was copying imports from old non working ones
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
oh 1 sec lemme try something
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
Huh strange because I commented out the provider from solid-jsx
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
No description
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
I found this compileMarkdown function on github that might work. https://github.com/lukaprsina/fizika/blob/fe6dfd9344c4e6fe93821a6167144ff9a2478464/web/src/components/Markdown.tsx#L194C14-L194C14 I can't test it at the moment as my laptop is freezing every few seconds
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
oh ok, well thank you for trying to help me anyways
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
https://stackblitz.com/edit/solid-ssr-vite-qyuqxf?file=src%2Froutes%2Findex.tsx Ok I made a compileMarkdown util and used
jsx: true,
jsx: true,
and
jsxImportSource: 'solid-js/jsx-runtime',
jsxImportSource: 'solid-js/jsx-runtime',
, also removed async in there and then returned it inside a Dynamic component but it's still not working :/
69 replies
SSolidJS
Created by Dog on 10/11/2023 in #support
Anyone using solid-social with solid-markdown?
https://stackblitz.com/edit/solid-ssr-vite-qyuqxf?file=src%2Froutes%2Findex.tsx I'd like the markdown content to be rendered server side as I'm storing it in supabase database
69 replies