Nest custom repository function not define - repository

I have a small question about custom repositories in nestjs.
I have the following logic when a request comes in (for example for user entity).
A controller for the user requests -> service -> repository calls custom function.
So i have the following repository:
I inject the repository in service class
And register in module file
But when calling signup function I got error:
I did research and also try to add #InjectRepository(UserRepository) in service but it sill not work
Environments:
node: 16.13.0
#nestjs/typeorm": "^8.1.4",
typeorm: "^0.3.7"
nestjs: 8.2.8
Thank in advance

try BaseRepository in typeorm-transactional-cls-hooked
#EntityRepository(UserEntity)
export class UserRepository extends BaseRepository<UserEntity>{
.
.
.
}

Related

Add IHttpHandler to Blazor project

In order to be able to serve audio from a SqlServer database in a Blazor project I need to have an IHttpHandler in the project. I could add an AudioHandler.ashx and AudioHandler.ashx.cs file to the project, but what else (NuGet package for instance) do I need to add in order to be able to use the IHttpHandler interface like:
public class AudioHandler : IHttpHandler
{
}
And how can I register this handler so it can be called from Javascript?
Thanks a lot in advance!

Issue when configuring Hangfire in ASP.NET app

I'm attempting to wire up Hangfire in my ASP.NET application (not Core) using the Global.asax.cs route explained in their documentation. However, none of their extensions methods on GlobalConfiguration.Configuration seem to be working for me. It appears, for one example, that SetDataCompatibiltyLevel() method extends Hangfire.IGlobalConfiguration, which my GlobalConfiguration.Configuration does not inherit from. I even backed off a few versions of Hangfire and it doesn't seem to make a difference. When I attempt to access the extensions method directly, I get this:
Prefix GlobalConfiguration class with the Hangfire namespace – System.Web.Http namespace defines its own GlobalConfiguration class, so you get a conflict. And that another class is referenced, most likely because you have the System.Web.Http namespace included in the beginning of the file.
Hangfire.GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibiltyLevel.Version_170);
You can also combine all the calls to the GlobalConfiguration class in a single chain:
Hangfire.GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibiltyLevel.Version_170)
.UseXXX()
.UseYYYStorage();

register server wide javax.ws.rs.client.ClientRequestFilter on JBoss EAP 7

Is it possible to register a javax.ws.rs.client.ClientRequestFilter server wide on JBoss EAP 7? I would like to intercept all outbound JAX-RS calls to dynamically add some context information in HTTP headers.
For JAX-WS calls I was able to do this with https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/developing_web_services_applications/#jax_ws_handler_chains. I can't find any documentation on a similar mechanism for JAX-RS.
Or alternatively, is there maybe another way to intercept outbound HTTP calls in general?
For a per server solution, according to Using HttpHandler class in Undertow "you need to package your handler(s) into a module, and configure custom-filter in undertow subsystem."
The module.xml example and undertow configuration has been given as well as filter source code!
Update
There's an example of using the HTTPExchange here though I dont really care much for that site. SO also has this slightly related example - it does look like it can work similarly to the JAX-WS Handlers/Interceptor How to properly read post request body in a handler
Another good example file upload using httphandler I know they're different that dealing with JAX-RS but still may apply.
I implemented it by creating a module with the following contents:
package be.fgov.kszbcss.tracer.jaxrs;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
public class TracerResteasyClientBuilder extends ResteasyClientBuilder {
#Override
public ResteasyClient build() {
return super.build().register(TracerJaxRsClientRequestFilter.class);
}
}
/META-INF/services/javax.ws.rs.client.ClientBuilder
be.fgov.kszbcss.tracer.jaxrs.TracerResteasyClientBuilder
And registering it as a global module on JBoss EAP.

How to inject UrlHelper in Web API 2 using StructureMap.WebApi2 nuget package

I am using StructureMap.WebApi2 nuget package for Web API 2 project for managing the depedency injection.
The Web API controllers use constructor injection to inject a UrlHelper dependency which should be resolved by StructureMap Ioc.
I am trying the following approach to set the UrlHelper for web api controller:
public class FooController : ApiController
{
private UrlHelper _UrlHelper;
public ModelFactory(HttpRequestMessage request)
{
_UrlHelper = new UrlHelper(request);
}
}
But with the above code I am getting the following error:
No default Instance is registered and cannot be automatically determined for type 'System.Net.Http.HttpMethod' There is no configuration specified for System.Net.Http.HttpMethod
Can anyone suggest me the best possible ways to resolve the above issue?
Your problem is that StructureMap tries to resolve the greediest constructor first, in this instance taking a look at the source code for HttpRequestMessage reveals the following constructors:
public HttpRequestMessage(HttpMethod method, string requestUri);
public HttpRequestMessage(HttpMethod method, Uri requestUri);
This is where your HttpMethod issue is coming from. StructureMap tries to create an instance of HttpRequestMessage but has no idea how to resolve the method and requestUri dependencies.
In this instance you need to manually configure your dependency within your StructureMap configuration so it knows how to create an instance of HttpRequestMessage like so:
this.For<HttpRequestMessage>().Use(new HttpRequestMessage());
Alternatively, to create instances of overloaded constructors then you'll need to manually resolve the overloaded dependencies (I would recommend using a factory for this in order to keep your SM configuration nice and clean. Here is an example of how you can do this).

Is there an Azure Websites functionality equivalent to Azure Web Roles RoleEntryPoint

I want to run some code from a library before Application_Start and i was wondering if that is possible using just Azure websites or if I have to purchase an Azure Web Role instance and use RoleEntryPoint?
Have you tried using the WebActivator NuGet package? Have a look on GitHub for further details but the basics of it are simply adding an attribute and an initialisation method to your application. For example:
using System;
[assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.Bootstrapper), "PreStart")]
namespace MyApp {
public static class Bootstrapper {
public static void PreStart() {
// Add your start logic here
}
}
}
The code in PreStart will run before Application_Start.
There are other attributes you can use for doing things on shutdown (ApplicationShutdownMethodAttribute) and for post startup (PostApplicationStartMethodAttribute).