Up
Up
Explore posts from servers
CDCloudflare Developers
Created by Up on 12/19/2024 in #pages-help
Accessing remote D1 database during local dev with SvelteKit
I am building a SvelteKit site that is deployed to CF pages, and uses a D1 database. However, working on it is very painful due to not being able to test changes locally without the DB. Creating a mock database is not sufficient here, so it seems like I cannot simply use wrangler pages dev to get around the issue. How can I improve the development experience, as I would rather not have to deploy to production over and over again just to test tiny code changes? Previously I had been using cf-bindings-proxy but that appears to not be compatible with node 22, so I will need to either fix that or find an alternative.
1 replies
PPrisma
Created by Up on 6/27/2024 in #help-and-questions
N+1 problem with multiple filter conditions
I have a table that maps access to "file groups" per user, for a range of time periods. each group having a different expiry date for each user. Now I want to retrieve all files that a user has ever had access to. for that, the naive approach would be something like 1. query the file access table: select file_group and exp_date, where user = $currentUser, order by exp_date descending, distinct per file_group, limit 1. 2. for each result pair -> query the files table: select *, where file_group = $pair.group AND created_at <= pair.exp_date Now I know the prisma DSL has ways to mitigate this for "simple" cases where there is only 1 condition to join on, but I am not sure how I would do it with both of these conditions, as it would need to reference the result of the previous query somehow. So I guess my question is, is there a way to do this in a single prisma client call, or am I better off manually parsing the result of the first request, collecting all the file group IDs and dates and then passing these on to the second request?
5 replies
CC#
Created by Up on 8/11/2023 in #help
✅ EF Core Relations don't seem to work properly
I'm trying to model a fairly complex set of relations in EntityFramework core / ASP.NET, but am failing to create a new entry as the system insists it already exists; yet the corresponding table in the DB is empty
43 replies
CDCloudflare Developers
Created by Up on 4/8/2023 in #pages-help
Trying to secure a CF pages site with custom auth; getting "too many redirects" error
I'm trying to use ZeroAuth to protect access to a site that's hosted on CF pages. However, instead of the default email OTP code, I've set up a custom auth server that I'd like to use. But after successfully logging in, I get a "too many redirects" error instead of the page loading. Note: This happens both on the custom domain as well as the .pages.dev one, but fwiw the .pages.dev site will load fine if you manually reload it after logging in and getting that above error.
3 replies
CDCloudflare Developers
Created by Up on 3/13/2023 in #workers-help
deploying to selfhosted workerd
Is there any way to run a worker project on a selfhosted workerd instance that's running in a container? So far I've only found wrangler's --experimental-local flag but that instead tries to spin up a new instance
9 replies
CC#
Created by Up on 8/21/2022 in #help
ASP.NET MVC Legacy Route Hell
So I have a very old API that was originally written in MVC. this api manages projects where each project has an ID + user-friendly slug, and then has a bunch of files that each have file name + file ID. now I have an MVC route mapping that I will need to know how it resolves, so I can then extract those properties from the URL back to my own application.
4 replies
CC#
Created by Up on 8/14/2022 in #help
C++ Interop - writing a shim to use an existing c++ library [Answered]
So I'm currently trying to make a shim for a C++ library that I can then call from C#. The original library uses CMake, not MSBuild, so I've set up Cmake, let it generate the .vcxproj files, made a 2nd C++ project for my shim classes and made it depend on the generated projects. Then I've added that + the generated projects into my C# msbuild solution. Now I am trying to call a hello world function that I made in my shim library form C#, but that immediately fails with no indicator as to what went wrong. all I get is System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'. How I declared it on the C++ side:
extern "C" {
void __declspec(dllexport) __stdcall CLIP_Hello();
}
extern "C" {
void __declspec(dllexport) __stdcall CLIP_Hello();
}
How I declared it on the C# side:
[DllImport("ClipShim", EntryPoint = "CLIP_Hello", CallingConvention = CallingConvention.StdCall)]
public static extern void Hello();
[DllImport("ClipShim", EntryPoint = "CLIP_Hello", CallingConvention = CallingConvention.StdCall)]
public static extern void Hello();
any help appreciated!
101 replies