Loopback 4 test configurations are not picked up - loopback

I followed Loopback4 datasources documentation and placed sample.datasource.json and sample.test.datasource.json files under src/datasources. Whenever I run npm run test my repository is injected with original datasource but not the test datasource.
My datasource configuration file sample.datasource.json is
{
"name": "sample",
"connector": "postgresql",
"url": "postgres://postgres:user#localhost:5432/somedb",
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "****",
"database": "somedb"
}
and my test configuration file sample.test.datasource.json is
{
"name": "sample",
"connector": "memory",
"localStorage": "sample-test",
"debug": true
}
Here is my repository file sample.repository.ts placed under src/repositories.
export class SampleRepository extends DefaultCrudRepository<SomeModel,string> {
constructor(
#inject('datasources.sample') dataSource: SomeDataSource,
) {
super(SomeModel, dataSource);
}
}
I exported NODE_ENV to "test" and tried to run npm run test.

Hello from the LoopBack team :)
LoopBack 4 does not support environment specific configuration yet. We are discussing this feature in the GitHub issue #1464, there is also a discussion about modifying datasource configuration specifically for tests - see issue #1396.
There are workaround possible, see the following resources for inspiration:
https://loopback.io/doc/en/lb4/Deploying-to-IBM-Cloud.html#updating-application
https://itnext.io/loopback-4-database-configuration-8f085399268

Related

TYPO3 CMS 8.7.27: Call to a member function getPackagePath() on null

After installing extensions in typo3 CMS 8.7.27, I got following error.. Seems like the ExtensionManagementUtility can't load the ah_contentapi.
This is my composer.json file in root (/var/www/html/typo3) for loading my extensions:
{
"repositories":[
{
"type":"composer",
"url":"https://composer.typo3.org/"
},
{
"type":"package",
"package":{
"name":"Bm/ah-content-api",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_config_typo3.git",
"type":"git",
"reference":"master"
}
}
},
{
"type":"package",
"package":{
"name":"Bm/ah-contentelements",
"version":"0.0.1",
"type":"typo3-cms-extension",
"source":{
"url":"https://user#bitbucket.org/company/ah_contentelements_typo3.git",
"type":"git",
"reference":"master"
}
}
}
],
"name":"typo3/cms-base-distribution",
"description":"TYPO3 CMS Base Distribution",
"license":"GPL-2.0-or-later",
"require":{
"helhum/typo3-console":"^4.9.3 || ^5.2",
"typo3/cms-about":"^8.7.10",
"typo3/cms-belog":"^8.7.10",
"typo3/cms-beuser":"^8.7.10",
"typo3/cms-context-help":"^8.7.10",
"typo3/cms-documentation":"^8.7.10",
"typo3/cms-felogin":"^8.7.10",
"typo3/cms-fluid-styled-content":"^8.7.10",
"typo3/cms-form":"^8.7.10",
"typo3/cms-func":"^8.7.10",
"typo3/cms-impexp":"^8.7.10",
"typo3/cms-info":"^8.7.10",
"typo3/cms-info-pagetsconfig":"^8.7.10",
"typo3/cms-rte-ckeditor":"^8.7.10",
"typo3/cms-setup":"^8.7.10",
"typo3/cms-sys-note":"^8.7.10",
"typo3/cms-t3editor":"^8.7.10",
"typo3/cms-tstemplate":"^8.7.10",
"typo3/cms-viewpage":"^8.7.10",
"typo3/cms-wizard-crpages":"^8.7.10",
"typo3/cms-wizard-sortpages":"^8.7.10",
"typo3/cms":"^8.7",
"dmitryd/typo3-realurl":"2.*",
"GridElementsTeam/Gridelements":"8.2.*",
"clickstorm/cs_seo":"3.*",
"Bm/ah-content-api":"0.0.1",
"Bm/ah-contentelements":"0.0.1"
},
"scripts":{
"typo3-cms-scripts":[
"typo3cms install:fixfolderstructure",
"typo3cms install:generatepackagestates"
],
"post-autoload-dump":[
"#typo3-cms-scripts"
]
},
"extra":{
"typo3/cms":{
"web-dir":"public"
},
"helhum/typo3-console":{
"comment":"This option is not needed ay more for helhum/typo3-console 5.x",
"install-extension-dummy":false
}
},
"autoload":{
"psr-4":{
"Bm\\AhContentelements\\":"public/typo3conf/ext/ah_contentelements/Classes",
"Bm\\AhContentapi\\":"public/typo3conf/ext/ah_content_api/Classes"
}
}
}
I already cleared cache in install tool at:
1. -> important actions -> clear all cache
2. -> clean up -> Clean typo3temp/ folder
piece from composer.lock:
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is #generated automatically"
],
"content-hash": "954afd2318d54ec9b1dd0e4d7f9b445b",
"packages": [
{
"name": "Bm/ah-content-api",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/hippovibe/ah_config_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
{
"name": "Bm/ah-contentelements",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://stevenhippovibe#bitbucket.org/stevenhippovibe/ah_contentelements_typo3.git",
"reference": "master"
},
"type": "typo3-cms-extension"
},
The Error occurs when the extension folder name under typo3conf/ext/<folder_name> doesn't match extension key used in some places of the system (e.g. using EXT:your_extension_key/... syntax in TypoScript).
Changing folder name fixed similar problem for me.
Check the PHP version and try to change it from i.e. 7.4 to 7.3.
I once had this problem with an extension that should be compatible with PHP 7.4, but wasn't in real life. This solved the problem for me.
Question here is:
How did you update to 8.7.27 (which composer command was executed)
How does your composer.lock look like?
Do you use TYPO3 console or any other special composer plugins / CLI commands to e.g. generate PackageStates.php?
I just ran into the same error message under TYPO3 9.5.5.
Solution:
Deinstall one TYPO3 extension after the other and try it out again. This will lead you to the extension which has an error. Most probably the error is inside of the file ext_localconf.php or ext_tables.php .
I got this error detail:
PHP Warning: Use of undefined constant FH_DEBUG_EXT - assumed 'FH_DEBUG_EXT' (this will throw an Error in a future version of PHP) in /var/www/html/global-extensions/ext/div2007/ext_localconf.php line 15
This has nothing to do with your error. But it can be that you have an error in one of your installed extensions or even in a backup of an extension, e.g. a folder named as extensionname.bak .
Also these recommendations can help:
https://wiki.typo3.org/Exception/CMS/1476107295

LDAP passport strategy for Hyperledegr composer

I have been trying to use LDAP passport strategy for authentication in hyperledger composer rest server. I am using below configuration for ldap passport:
export COMPOSER_PROVIDERS='{
"ldap": {
"provider":"ldap",
"authScheme":"ldap",
"module":"passport-ldapauth",
"authPath":"/auth/ldap",
"successRedirect":"/",
"failureRedirect":"/",
"server":"{
"url":"ldap://localhost:389",
"bindOn":"cn=admin,dc=example, dc=com",
"bindCredentials":"*****",
"searchBase":"ou=admin,dc=example,dc=com",
}"
}
}'
While starting composer-rest-server with authentication its showing error
SyntaxError: Unexpected token
in JSON at position 210
at JSON.parse (<anonymous>)
at Promise.then (/home/mfgteg/.nvm/versions/node/v8.9.3/lib/node_modules/composer-rest-server/server/server.js:127:34)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
I got the correct format. Thanks to a link I found on IBM site
I used the following configuration :
export COMPOSER_PROVIDERS='{
"ldap": {
"provider": "ldap",
"authScheme": "ldap",
"module": "passport-ldapauth",
"authPath": "/auth/ldap",
"successRedirect": "/",
"failureRedirect": "/",
"server": {
"url": "ldap://localhost:389",
"bindDn": "cn=admin,dc=example, dc=com",
"bindCredentials": "*****",
"searchBase": "ou=admin,dc=example,dc=com"
}
}
}'
However I am yet to figure out what to mention in "callbackURL".
Use the variable provided below. Just change the successRedirect and credentials as per your configuration. Also in case you are running Client application on some other machine, you may need to change the localhost in url to your machine IP address.
Note : I have tested this with open LDAP configured.
COMPOSER_PROVIDERS='{
"ldap": {
"provider": "ldap",
"authScheme": "ldap",
"module": "passport-ldapauth",
"authPath": "/auth/ldap",
"successRedirect": "Where you want to redirect",
"failureRedirect": "/ldap",
"session": true,
"json": true,
"LdapAttributeForLogin": "cn",
"LdapAttributeForUsername": "cn",
"server": {
"url": "ldap://localhost:389",
"bindDN": "cn=admin,dc=hsc,dc=com",
"bindCredentials": "xxxxx",
"searchBase": "ou=users,dc=hsc,dc=com",
"searchFilter": "(cn={{username}})"
}
}
}'

Vapor MongoDB Provider Error

I am trying to run a Vapor app on my local machine and have MongoDb installed and running.
I have this as my mongo.json: {
"user": "test",
"password": "password",
"database": "reading_journal",
"host": "127.0.0.1",
"port": 2701
}
which is correct in terms of the info for the local DB.
My main.swift:
import Vapor
import FluentMongo
import VaporMongo
let drop = Droplet(providers: [VaporMongo.Provider.self])
drop.get { req in
let lang = req.headers["Accept-Language"]?.string ?? "en"
return try drop.view.make("welcome", [
"message": Node.string(drop.localization[lang, "welcome", "title"])
])
}
drop.resource("users", UserController())
drop.resource("posts", PostController())
drop.run()
Yet in the log I get: "Could not initialize provider Provider: Socket failed with code 61 ("No data available") [connectFailed] "Unknown error"
Is there some other initialization that needs to be done? This is a brand new MongoDB DB.
Any help would be greatly appreciated!
In my case, I had to add "host": "0.0.0.0" in the mongo.json
That error usually happens if MongoDB is not running on the correct port. Make sure whatever you have in your mongo.json file matches what port MongoDB is running on.

How to add a ETW provider to an existing service fabric cluster using powershell?

I have already created a service fabric cluster with azure diagnostics and it is functional currently with my services deployed into that cluster. I have an ETW EventSource in my service that I would like to start collecting events from because my service code already uses this event source to write my service related events. Since the cluster is already enabled for azure diagnostics and my services are already deployed into that cluster, I think it is a simple matter of updating the ETW provider with my event source in this service fabric cluster. Here is the exported template (only a partial is shown that is relevant for azure diagnostics):
{
"properties": {
"publisher": "Microsoft.Azure.Diagnostics",
"type": "IaaSDiagnostics",
"typeHandlerVersion": "1.5",
"autoUpgradeMinorVersion": true,
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": "50000",
"EtwProviders": {
"EtwEventSourceProviderConfiguration": [
{
"provider": "Microsoft-ServiceFabric-Actors",
"scheduledTransferKeywordFilter": "1",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableActorEventTable"
}
},
{
"provider": "Microsoft-ServiceFabric-Services",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
},
{
"provider": "Bb.ServiceFabric.Infrastructure.Container",
"scheduledTransferPeriod": "PT1M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
}
],
"EtwManifestProviderConfiguration": [
{
"provider": "cbd93bc2-71e5-4566-b3a7-595d8eeca6e8",
"scheduledTransferLogLevelFilter": "Information",
"scheduledTransferKeywordFilter": "4611686018427387904",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricSystemEventTable"
}
}
]
}
}
},
"StorageAccount": "sfdgsmsraghuplaygrou6827"
}
},
"name": "VMDiagnosticsVmExt_vmNodeType0Name"
}
I would like to update following EtwProviders/EtwEventSourceProviderConfiguration to contain following section (as MyCompany.MyServices.MyStatelessService is the name of my service's EventSource):
{
"provider": "MyCompany.MyServices.MyStatelessService",
"scheduledTransferPeriod": "PT5M",
"DefaultEvents": {
"eventDestination": "ServiceFabricReliableServiceEventTable"
}
}
Here are my questions:
Is this the correct way of inserting an ETW provider/EventSource (from my service) into an existing cluster (that is already enabled with azure diagnostics)?
Can I add this event source (as a ETW event source provider) using a powershell command(s)?
If so, what is the exact powershell command (using all the information from the above code fragment)?
Note: I am using .net framework 4.5.2.
All seems good with the added configuration above. Just be aware that for ETWProviders the EventDestination cannot contain hyphens (-), yours don't so you are ok.
To update the Windows Azure Diagnostics (WAD) agent configuration, you can use either PowerShell or Cloud Explorer in Visual Studio.
For the former, simply update the ARM template and use the New-AzureRmResourceGroupDeployment cmdlet. See here for further information: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-diagnostics-how-to-setup-wad/#update-diagnostics-to-collect-and-upload-logs-from-new-eventsource-channels
For using Cloud Explorer in Visual Studio. Browse to your Virtual Machine Scale Set (as this is the Azure resource that holds the WAD configuration). Right-click and choose Update Diagnostics. In the dialog shown, you have the option to upload a private and public configuration file. Simple take a .json document containing the {"WadCfg": {}} element, and upload that as a public configuration.
If you need to update the private configuration specifies the storage account name and AccessKey:
{
"storageAccountName": "",
"storageAccountKey": "",
"storageAccountEndPoint": "https://core.windows.net",
}
Hope this helps.
Mikkel

Centrifuge not using MongoDB?

I just installed centrifuge (https://centrifuge.readthedocs.org/en/latest/) and created a configuration.json file and placed it in /var/www/ folder.
When I try to run centrifuge centrifuge config = /var/www/configuration.json, the server starts. However when I go to the default path http://localhost:8000 in the admin panel it keeps saying DataStructure used as SQLite.
Here's my configuration.json file
{
"password": "admin",
"cookie_secret": "secret",
"api_secret": "secret",
"structure": {
"storage": "centrifuge.structure.mongodb",
"settings": {
"host": "localhost",
"port": 27017,
"name": "centrifuge",
"pool_size": 10
}
},
state: null
}
I checked and the MongoDB server is running on port 27017.
It seems you are starting Centrifuge using incorrect command line arguments. Try copy and paste into your terminal:
centrifuge --config=/var/www/configuration.json