sh1man
sh1man
SSolidJS
Created by sh1man on 6/23/2024 in #support
Is there a convenient way to check the permissions of a user
No description
1 replies
SSolidJS
Created by sh1man on 6/4/2024 in #support
Excel table component
Can anyone tell me if there is a ready-made Excel table component?
3 replies
SSolidJS
Created by sh1man on 4/1/2024 in #support
websocket get peers on the server
can you show an example of how to get websocket peers on the server solistart
17 replies
SSolidJS
Created by sh1man on 3/26/2024 in #support
How to css preloading
When the file weighs a lot, I don’t immediately see the application of styles on the site. I connect app.css to app.tsx
2 replies
SSolidJS
Created by sh1man on 3/20/2024 in #support
how do you usually convert a form field from string to number on rpc servershould i use valibot to
helps pls
3 replies
SSolidJS
Created by sh1man on 3/14/2024 in #support
Cookie bug
https://github.com/sh1man999/solidstart-auth.git The problem is the following: After I called logInAction, I set cookies and redirected to the main page, but the redirect did not occur
12 replies
SSolidJS
Created by sh1man on 3/13/2024 in #support
what's the difference between? createResource andcreateAsync
and who can write about createAsync in more detail essentially createAsync is a wrapper over createResource, but I don’t remember what it’s for? and why do you need to indicate on the routes export const route = { load: () => historyLoadPdfFile() } satisfies RouteDefinition;
6 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 don’t have a database on the solidstart server, I only work with third-party APIs. Where to store user information. I want not to write in some functions constantly the same code for processing unauthorized. You need to write a wrapper function?
export const getUser = cache(async () => {
"use server";
try {
const session = await getSession();
const userId = session.data.userId;
if (userId === undefined) throw new Error("User not found");
const user = await db.user.findUnique({ where: { id: userId } });
if (!user) throw new Error("User not found");
return { id: user.id, username: user.username };
} catch {
await logoutSession();
throw redirect("/login");
}
}, "user");
export const getUser = cache(async () => {
"use server";
try {
const session = await getSession();
const userId = session.data.userId;
if (userId === undefined) throw new Error("User not found");
const user = await db.user.findUnique({ where: { id: userId } });
if (!user) throw new Error("User not found");
return { id: user.id, username: user.username };
} catch {
await logoutSession();
throw redirect("/login");
}
}, "user");
19 replies
SSolidJS
Created by sh1man on 3/6/2024 in #support
Can someone tell me how to redirect the user on each API, if 401, that is, do not write the logic ag
Can someone tell me how to redirect the user on each API, if 401, that is, do not write the logic again for each action
1 replies
SSolidJS
Created by sh1man on 3/2/2024 in #support
someone used the plugin postcss-functions ?
how to set the visibility of functions in css files. ide shows that there is an unknown function, what should I do with these
1 replies
SSolidJS
Created by sh1man on 2/22/2024 in #support
Can anyone tell me how best to do it? Store API
import axios from "axios";
import {ErrorApi} from "~/utils/tryCallApi";
import {IBaseResponse, UserProfileEntity} from "~/types";
import {getCookieValue} from "~/utils";
import {type Navigator} from "@solidjs/router";
import {paths} from "~/utils/paths";

export type HttpClientActions = {
user: HttpClientActionsProfile
}

type HttpClientActionsProfile = {
profile: () => Promise<IBaseResponse<UserProfileEntity>>;
}

export default function createHttpClient(navigate: Navigator) {

const api = axios.create({
baseURL: import.meta.env.VITE_API_URL,
withCredentials: true,
headers: {
Accept: 'application/json',
}
})

api.interceptors.request.use((config) => {
const csrfToken = getCookieValue('csrftoken');
if (csrfToken !== null) {
config.headers['X-CSRFToken'] = csrfToken;
}
return config;
})

api.interceptors.response.use(
async (response) => response,
async (error) => {
if(error?.response?.status === 401){
/// This normal practice ????????????????????
setTimeout(() => {
navigate(paths.logIn);
}, 0);
}
const apiError: ErrorApi = {
message: error?.response?.data?.detail,
data: error?.response?.data,
status: error?.response?.status,
result: false
}
return Promise.reject(apiError);
}
)

const httpClient: HttpClientActions = {
user: {
profile: async () => api.post('/user/profile/'),
}
}

return httpClient;
}
import axios from "axios";
import {ErrorApi} from "~/utils/tryCallApi";
import {IBaseResponse, UserProfileEntity} from "~/types";
import {getCookieValue} from "~/utils";
import {type Navigator} from "@solidjs/router";
import {paths} from "~/utils/paths";

export type HttpClientActions = {
user: HttpClientActionsProfile
}

type HttpClientActionsProfile = {
profile: () => Promise<IBaseResponse<UserProfileEntity>>;
}

export default function createHttpClient(navigate: Navigator) {

const api = axios.create({
baseURL: import.meta.env.VITE_API_URL,
withCredentials: true,
headers: {
Accept: 'application/json',
}
})

api.interceptors.request.use((config) => {
const csrfToken = getCookieValue('csrftoken');
if (csrfToken !== null) {
config.headers['X-CSRFToken'] = csrfToken;
}
return config;
})

api.interceptors.response.use(
async (response) => response,
async (error) => {
if(error?.response?.status === 401){
/// This normal practice ????????????????????
setTimeout(() => {
navigate(paths.logIn);
}, 0);
}
const apiError: ErrorApi = {
message: error?.response?.data?.detail,
data: error?.response?.data,
status: error?.response?.status,
result: false
}
return Promise.reject(apiError);
}
)

const httpClient: HttpClientActions = {
user: {
profile: async () => api.post('/user/profile/'),
}
}

return httpClient;
}
6 replies
SSolidJS
Created by sh1man on 2/17/2024 in #support
I'd like to see an example of working with a microservices API architecture
I think this is the example that is missing from Solidstart
3 replies
SSolidJS
Created by sh1man on 2/13/2024 in #support
api-routes
I want to use solidstart. But my backend API is in a different programming language. I need to communicate with it via the API and receive json. Also auth to it api. What do I need to use as an http client? Axios?
5 replies
SSolidJS
Created by sh1man on 2/13/2024 in #support
[h3] [unhandled] H3Error: Missing "./runtime/http-types" specifier in "vinxi" package
import type {FetchEvent} from "@solidjs/start/server/types";
import {getHeader, setResponseStatus} from "vinxi/runtime/http-types";
export const cors = async (event: FetchEvent) => {
if (event.request.method !== "GET") {
const originHeader = getHeader(event, "Origin") ?? null;
const hostHeader = getHeader(event, "Host") ?? null;
if (!originHeader || !hostHeader || !verifyRequestOrigin(originHeader, [hostHeader])) {
setResponseStatus(
403,
"Forbidden: Origin is not allowed."
)
return ;
}
}
}
import type {FetchEvent} from "@solidjs/start/server/types";
import {getHeader, setResponseStatus} from "vinxi/runtime/http-types";
export const cors = async (event: FetchEvent) => {
if (event.request.method !== "GET") {
const originHeader = getHeader(event, "Origin") ?? null;
const hostHeader = getHeader(event, "Host") ?? null;
if (!originHeader || !hostHeader || !verifyRequestOrigin(originHeader, [hostHeader])) {
setResponseStatus(
403,
"Forbidden: Origin is not allowed."
)
return ;
}
}
}
3 replies
SSolidJS
Created by sh1man on 2/10/2024 in #support
Custom auth solidstart by prisma
Can anyone help me make my authorization on solidstart? I have orm prisma. I created a user table, what else do I need? 1) how to authorize a user, I have an endpoint trpc. 2) when entering the site, I should receive information about the user; if the error code is 401, then the user is redirected to the logIn page
73 replies
SSolidJS
Created by sh1man on 2/8/2024 in #support
example authorization on the outside server
can anyone show an example of using solidstart with a third-party backend servicing app, for example authorization on the server
1 replies
SSolidJS
Created by sh1man on 2/8/2024 in #support
solidstart authorized example
can anyone share the solidstart code which has authorization and redirection of the user if he is not authorized
6 replies
SSolidJS
Created by sh1man on 2/7/2024 in #support
TRPC. The module system cannot find the file
Help pls. The module system cannot find the file ~/server/routers/root imported into E:/Coding/Projects/tv_emr_log/frontend/src/routes/api/trpc/[trpc].ts. this file root.ts:
import { authRouter } from './auth';
import { router} from "~/server/trpc";


export const appRouter = router({
auth: authRouter
});
export type AppRouter = typeof appRouter;
import { authRouter } from './auth';
import { router} from "~/server/trpc";


export const appRouter = router({
auth: authRouter
});
export type AppRouter = typeof appRouter;
this file [trpc].ts
import { type APIEvent } from "@solidjs/start/server";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import {appRouter} from "~/server/routers/root";

const handler = (event: APIEvent) =>
fetchRequestHandler({
endpoint: "/api/trpc",
req: event.request,
router: appRouter,
createContext: () => ({})
});
export const GET = handler;
export const POST = handler;
import { type APIEvent } from "@solidjs/start/server";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import {appRouter} from "~/server/routers/root";

const handler = (event: APIEvent) =>
fetchRequestHandler({
endpoint: "/api/trpc",
req: event.request,
router: appRouter,
createContext: () => ({})
});
export const GET = handler;
export const POST = handler;
tsconfig.json
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"allowJs": true,
"strict": true,
"noEmit": true,
"types": ["vinxi/client"],
"isolatedModules": true,
"paths": {
"~/*": ["./src/*"]
}
}
}
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"allowJs": true,
"strict": true,
"noEmit": true,
"types": ["vinxi/client"],
"isolatedModules": true,
"paths": {
"~/*": ["./src/*"]
}
}
}
3 replies
SSolidJS
Created by sh1man on 1/27/2024 in #support
backend solidstart or another backend.
Does solidstart make sense if a third-party backend (fastapi) is used? I don't want to write backend in node js because I know fastapi(python) better. What do you advise?
6 replies