I'm initiating API/RPC connection to NEAR Protocol using JsonRpcProvider like that:
const provider = new nearAPI.providers.JsonRpcProvider(
`https://rpc.${networkId}.near.org`
)
I'm getting this warning
JsonRpcProvider(url?: string) deprecated use `JsonRpcProvider(connectionInfo: ConnectionInfo)` instead index.js:18:18
I can't find any example of how to use it in JS. The only ConnectionInfo object I could found is https://near.github.io/near-api-js/interfaces/utils_web.connectioninfo.html
The way you can use it is like that:
let connInfo = { url: "https://rpc.${networkId}.near.org" }
// sets up a NEAR API/RPC provider to interact with the blockchain
const provider = new nearAPI.providers.JsonRpcProvider(connInfo)
Related
I know in Web3js you can connect to an Infura web socket like so:
const Web3 = require('web3')
const web3 = new Web3(
new Web3.providers.WebsocketProvider("wss://mainnet.infura.io/ws/v3/<project_id>")
)
but how do I connect using Ethers.js? I've tried searching the internet but the answer isn't immediately obvious.
Found it in the Ether.js docs:
const provider = new ethers.providers.WebSocketProvider(
"wss://mainnet.infura.io/ws/v3/<project_id>"
)
the mainnet is used by default, but you can specify also specify a test network:
// Using a test network
const provider = new ethers.providers.WebSocketProvider(
"wss://rinkeby.infura.io/ws/v3/<project_id>", "rinkeby"
)
I am completely new to FHIR and have stumbled upon this NuGet package "Hl7.Fhir.STU3" and want to use it to search for Healthcare Services as defined here: https://digital.nhs.uk/developer/api-catalogue/e-referral-service-fhir#api-Default-a010-patient-service-search.
I so far have this limited code and understand I need to pass some form of search criteria but have no idea how to proceed. All I ever get back from the NHS client is:
"Root object has no type indication (resourceType) and therefore cannot be used to construct an FhirJsonNode. Alternatively, specify a nodeName using the parameter."
My code is:
var settings = new FhirClientSettings
{
Timeout = 10,
PreferredFormat = ResourceFormat.Json,
PreferredReturn = Prefer.ReturnMinimal,
};
var client = new FhirClient("https://sandbox.api.service.nhs.uk/referrals/FHIR/STU3/HealthcareService/$ers.searchHealthcareServicesForPatient", settings);
client.RequestHeaders.Add("Authorization", "Bearer g1112R_ccQ1Ebbb4gtHBP1aaaNM");
client.RequestHeaders.Add("nhsd-ers-ods-code", "R69");
client.RequestHeaders.Add("nhsd-ers-business-function", "REFERRING_CLINICIAN");
client.RequestHeaders.Add("X-Correlation-Id", Guid.NewGuid().ToString());
var services = client.Search<HealthcareService>();
I would really appreciate any assistance.
The URL you have set as your FHIR server endpoint is actually the URL for the operation call, so that will not work. If you set the server URL to "https://sandbox.api.service.nhs.uk/referrals/FHIR/STU3/", you should be able to use the FhirClient to do an operation call:
// Note that you have to send parameters in with your request, so set them up first:
var params = new Parameters();
params.Add("requestType", new Coding("https://fhir.nhs.uk/STU3/CodeSystem/eRS-RequestType-1", "APPOINTMENT_REQUEST"));
// etc...
var result = c.TypeOperation<HealthcareService>("ers.searchHealthcareServicesForPatient", params);
The $ sign in the original url is not part of the operation name, so I have omitted that in the request. The FhirClient will add the $ on the outgoing request.
I am getting the below error when I try to use
const select = new PrismaSelect(info).value;
[Nest] 65877 - 17/05/2021, 16:45:13 [ExceptionsHandler] Cannot find module '.prisma/client'
My PrismaClient is in a custom path rather than the default, as I am using a monorepo for multiple microservices.
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "darwin"]
output = "../src/.generated/prisma/client"
}
Is there a way to point PrismaSelect to the correct Client?
The solution was shared by the author of the package
Import custom instance of Prisma Client
import { Prisma } from '../../.generated/prisma/client';
Pass dmmf object to PrismaSelect constructor
const select = new PrismaSelect(info, { dmmf: [Prisma.dmmf] }).value;
My project has a declarative way of defining schema and resolvers, which is maintained in a separate repository. My graphql server polls the result of this to look for updates to the schema.
Using apollo-server-express#1, I had direct access to the graphqlExpress middleware, so when the schema changed I could construct a new instance of it and throw away the old one, something like this
const { graphqlExpress } = require('apollo-server-express');
let api;
const constructAPI = () => {
try {
const newSchema = createSchema();
api = graphqlExpress(({ headers }) => ({
schema: newSchema,
}));
logger.info({ event: 'GRAPHQL_SCHEMA_UPDATED' });
};
schemaPoller.on('change', constructAPI);
module.exports = router => {
// Note that we wrap the api controller in a function that passes
// the original args through because a new api controller is generated
// every time the schema changes. We can't pass express a direct
// reference to the api controller on startup, or it will
// never update the reference to point at the latest version of the
// controller using the latest schema
router
.route('/')
.get((...args) => api(...args))
.post((...args) => api(...args));
return router;
};
In apollo-server-express#2, access to the middleware is hidden away, and there are 2 new, more declarative ways of using the library, neither of which - at first glance - appear compatible with updating the schema without stopping the server, fetching the new schema and starting again with the new data, which is downtime I'd like to avoid.
Can anyone suggest a way of getting this setup to work with apollo#2?
The following exception:
SocketIOException: Unexpected handshake error in client (OS Error: errno = -12268)
#0 _SecureFilterImpl.handshake (dart:io-patch:849:8)
#1 _SecureSocket._secureHandshake (dart:io:7382:28)
#2 _SecureSocket._secureConnectHandler._secureConnectHandler (dart:io:7294:21)
#3 _Socket._updateOutHandler.firstWriteHandler (dart:io-patch:773:64)
#4 _SocketBase._multiplex (dart:io-patch:408:26)
#5 _SocketBase._sendToEventHandler.<anonymous closure> (dart:io-patch:509:20)
#6 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)
results from the following code:
String url = "https://www.google.com";
HttpClient client = new HttpClient();
HttpClientConnection conn = client.getUrl(new Uri(url));
conn.onResponse = (HttpClientResponse resp) {
print ('content length ${resp.contentLength}');
print ('status code ${resp.statusCode}');
InputStream input = resp.inputStream;
input.onData = () {
print(codepointsToString(input.read()));
};
input.onClosed = () {
print('closed!');
client.shutdown();
};
};
Note that if I replace the url with "http" instead of "https", it works as expected.
Bug report is here.
Update: See the answer of William Hesse for Dart version >= 1.12.
I have the same error with Dart SDK version 0.2.9.9_r16323. In the issue 7541 :
The SecureSocket library needs to be initialized explicitly before using secure networking. We are working on making it initialize automatically the first time you use it, but that is not committed yet. To use just the default root certificates (well known certificate authorities), call SecureSocket.initialize()
in your main() routine, before you do any networking.
Thus, by adding SecureSocket.initialize() before your code, it works as expected.
After r16384 this explicit initialization is optional.
SecureSocket.initialize() is now optional. If you don't call it, it is the same as if you had called it with no parameters. If you call it explicitly, you must do so once, and before creating any secure connections. You need to call it explicitly if you are making server sockets, since they need a certificate database and a password for the key database.
The secure networking library has changed since this question was written. There is no SecureSocket.initialize() function anymore, and many other methods and objects have changed names. The working equivalent code for Dart 1.12 and later is:
import "dart:io";
main() async {
Uri url = Uri.parse("https://www.google.com");`
var client = new HttpClient();
var request = await client.getUrl(url);
var response = await request.close();
var responseBytes = (await response.toList()).expand((x) => x);
print(new String.fromCharCodes(responseBytes));
client.close();
}