Software Engineering
0
Answer link
After updating to recent version of @nestjs/mongoose, serving nest backend started throwing the dependency error like below:
Error: Nest can't resolve dependencies of the XYZService (?). Please make sure that the argument XYZModel at index [0] is available in the XYZModule context.
Potential solutions:
- If XYZModel is a provider, is it part of the current XYZModule?
- If XYZModel is exported from a separate @Module, is that module imported within XYZModule?
@Module({
imports: [ /* the Module containing XYZModel */ ]
})
There are several issues on nest github repo, but there isn't any offitial suggested solution.
It appears that, this issue happens when we have some sort of version incompatibility, for example, if you downgrade to @nest/mongoose@8.0.1, this issue disappears.
Solution without downgrading:
You have to mention the connection name in addition to model name in the @InjectModel decorator.
Before fix:
constructor(
@InjectModel("XYZModel")
protected model: Model<XYZDocument>
) {}
After fix:
constructor(
@InjectModel("XYZModel", "XYZConnection")
protected model: Model<XYZDocument>
) {}
Here is the code in @nestjs/mongoose library (in mongoose.utils.ts file), that appends Model keyword to the collection name, that results in the error:
export function getModelToken(model: string, connectionName?: string) {
if (connectionName === undefined) {
return `${model}Model`;
}
return `${getConnectionToken(connectionName)}/${model}Model`;
}
Hope it helps.
1
Answer link
There are several posts on Godaddy support forum, mentioning about using the subdomain forwarding in 'Manage DNS' section to forward example.com to www.example.com. The forwarding only works if you exactly type example.com in address bar.
if (req.headers.host.match(/^www/) !== null ) {
res.redirect('http://' + req.headers.host.replace(/^www\./, '') + req.url);
} else {
next();
}
})
But that feature does not work in following cases:
- If your URL is more than a domain name. e.g. example.com/xyz will not get forwarded to www.example.com/xyz
- If you type https://example.com it will not be forwarded to https://www.example.com
If you want the above cases to work, GoDaddy wants you to host your website on their own Hosting platform, so if you are AWS/Google Cloud/Azure/Digital Ocean customer, then you are out of luck with the domain forwarding option in GoDaddy.
How to fix it:
- Remove the subdomain forwarding from GoDaddy's Manage DNS.
- Add A record with @ entry, pointing to the IP address of your hosting server(from where you serve your website)
- Implement the URL handling/forwarding in your website
You need to handle all the root to www traffic on your own, where you have hosted your website. And there are several ways to host your website, so it would depend on how you have implemented your deployment. Here are a couple of examples
- If you are using Kubernetes with ingress controller, then you can add this annotation to your ingress resource: nginx.ingress.kubernetes.io/from-to-www-redirect: "true", more details here: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#redirect-fromto-www
- If you have plain nginx server then you can redirect the root domain to www using something like: https://stackoverflow.com/questions/7947030/nginx-no-www-to-www-and-www-to-no-www
- If you are not using any load balancers or reverse proxies then you have to redirect the requests in your web server itself. Node.js express example can be written something like:
if (req.headers.host.match(/^www/) !== null ) {
res.redirect('http://' + req.headers.host.replace(/^www\./, '') + req.url);
} else {
next();
}
})
0
Answer link
The average is called mean in statistical language. To be more accurate, it's called arithmetic mean.
The answer to this question has not yet been written
1
Answer link
An ingredient is a substance that forms part of a mixture (in a general sense). For example, in cooking, recipes specify which ingredients are used to prepare a specific dish. Many commercial products contain secret ingredients that are purported to make them better than competing products. In the pharmaceutical industry, an active ingredient is that part of a formulation that yields the effect expected by the customer.
National laws usually require prepared food products to display a list of ingredients, and specifically require that certain additives be listed.
In most developed countries, the law requires that ingredients be listed according to their relative weight[1] in the product. If an ingredient itself consists of more than one ingredient (such as the cookie pieces which are a part of "cookies and cream" flavor ice cream), then that ingredient is listed by what percentage of the total product it occupies, with its own ingredients displayed next to it in brackets.
The term constituent is often used to refer to substances that constitute the tissue of living beings. Thus all ingredients are constituents, but not all constituents are ingredients.
The answer to this question has not yet been written