Postgraphile "Only `POST` requests are allowed." error - postgraphile

I have Postgres running locally. I can access the database locally with psql postgres:///reviewapp and with \dt I can see a few tables.
If I run npx postgraphile -c "postgres:///reviewapp" I dont get any errors in the terminal:
PostGraphile v4.12.4 server listening on port 5000 🚀
‣ GraphQL API: http://localhost:5000/graphql
‣ GraphiQL GUI/IDE: http://localhost:5000/graphiql (RECOMMENDATION: add '--enhance-graphiql')
‣ Postgres connection: postgres:///reviewapp
‣ Postgres schema(s): public
‣ Documentation: https://graphile.org/postgraphile/introduction/
‣ Node.js version: v14.15.5 on darwin x64
‣ Join Mark in supporting PostGraphile development: https://graphile.org/sponsor/
* * *
However when I go to http://localhost:5000/graphql I have an error on the screen:
{"errors":[{"message":"Only POST requests are allowed."}]}

You're visiting the /graphql endpoint which speaks GraphQL (over POST requests), but you're sending it a web request (over GET). Instead, use the /graphiql end point to view the GraphiQL GraphQL IDE - this endpoint speaks web, and will give you a nice interface for communicating with the /graphql endpoint. See this output from the PostGraphile command:
‣ GraphQL API: http://localhost:5000/graphql
‣ GraphiQL GUI/IDE: http://localhost:5000/graphiql (RECOMMENDATION: add '--enhance-graphiql')
I recommend you add the --enhance-graphiql option to the PostGraphile CLI to get an even more powerful IDE in the browser.

It is because when you type in your address into the address bar of your browser, a GET request is being sent, while your Postgraphile instance only accepts POST requests. So this is the problem. You either avoid sending GET requests, or try and ensure that Postraphile accepts GET requests as well.
A very simple solution would be to create a very simple and small website that will act as a proxy and upon load, it would send a POST request to http://localhost:5000/graphql
There is a GitHub ticket where a middleware is suggested, read this for further information: https://github.com/graphile/postgraphile/issues/442

Related

HTTP request inside Azure CLI GitHub action fails with SSL expired error

We are using the AZ CLI GitHub Action azure/CLI (https://github.com/marketplace/actions/azure-cli-action)
The script that this workflow calls makes an HTTP request to an external API. This cURL call fails with the following:
curl: (60) SSL certificate problem: certificate has expired
More details here: curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
However I can confirm that the same request works locally.
The problem workflow step looks like this:
- name: Run script
uses: azure/CLI#1.0.4
with:
azcliversion: 2.0.72
inlineScript: |
$GITHUB_WORKSPACE/github/scripts/script.sh
Why does cURL think that the SSL cert for the external API domain is expired, when I can make the same call to the same API domain successfully on my own machine?
It seems the problem was that the azcliversion points to a version of the AZ CLI that has outdated certificates.
The problem was solved by removing the azcliversion field altogether, as the default version is latest, as specified in the docs for the action:
azcliversion – Optional Example: 2.0.72, Default: latest
So the step now looks like this:
- name: Run script
uses: azure/CLI#1.0.4
with:
inlineScript: |
$GITHUB_WORKSPACE/github/scripts/script.sh
Probably related to this: https://twitter.com/letsencrypt/status/1443621997288767491
Our cross-signed DST Root CA X3 expired today. If you are hitting an error, check out fixes in our community forum. We're seeing higher than normal renewals, so you may experience a slowdown in getting your certificates.

WSO2 Enterprise Integrator Unable to call deployed API

I am completely new to WSO2 and I am facing the problem described below.
After deploying the API (composite application *.car file) I am unable to invoke the services of the defined endpoints from WSO2 ESB.
The REST API I am trying to invoke is found deployed on a local tomcat installation, and is located at:
http://localhost:8080/CustomerInfoRestService/customers/
To retrieve a json customer object I would simply add the customer id, like so:
http://localhost:8080/CustomerInfoRestService/customers/2
All the services operations (Get, POST, PUT, DELETE) are tested and invoked successfully. For testing I used the tool 'PostMan'.
I created an ESB project using the WSO2 Integration Studio.
First I defined an endpoint with a URI Template of:
http://localhost:8080/CustomerInfoRestService/customers/{uri.var.custId}
Then I defined a REST API. The properties of the API Resource are as follows:
URL-Style: URI_Template
URI-Template: /customers/{custId}
Methods: GET
In the In-Sequence I added a log mediator, having:
Log Category: INFO
Log Level: CUSTOM
and I defined its message as:
Property Name: message
Property value type: LITERAL
Property Value: Welcome to Customer Service
Directly next to the log mediator is a 'Send' mediator, and I included the defined endpoint above.
Then I deploy the composite application as: right-click -> Export Composite Application Project.
I include both the API and and the endpoint in the generated *.car file.
Now to invoke an API request, I call the service using 'curl':
curl -v http://localhost:8280/CustomerInfoRestService/customers/2
and I get the response:
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8280 (#0)
> GET /CustomerInfoRestService/customers/2 HTTP/1.1
> Host: localhost:8280
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Date: Thu, 13 Jun 2019 10:09:06 GMT
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
It seems not to be found (404 error)
I followed the WSO2 documentation, specifically the integration tutorial "Sending a Simple Message to a Service" to create this project, for reference it is found at:https://docs.wso2.com/display/EI650/Sending+a+Simple+Message+to+a+Service
Any help is greatly appreciated.
Thanks in advance,
Kind Regards,
This kind of response comes when the API is not deployed or active in the ESB. Did you deploy the car file you created? You did not mention that in your steps. Please make sure that you are able to see the API in the management console (Home -> Service Bus -> API).

Basic setup using Symfony 4 messenger, php-enqueue, AWS SQS, AWS SNS

The goal is to be able to send messages using AWS SQS+SNS. This has been a struggle for a few days and I don't know how to make it work.
Symfony 4.2 has a new component, messenger that I wanted to use. It is supposed to work with php-enqueue as a third party transport. I am using that to connect to AWS SQS+SNS.
I can't find any documentation that puts it all together. I see how php-enqueue connects to AWS, but the docs show the config in the code and not in the config yaml or .env files. That is a problem since I want Messenger/enqueue to handle the behind-the-scenes stuff.
I was able to make Symfony Messenger work without php-enqueue for local synchronous messages. But after that... Clearly I am not doing it right. I was hoping someone might have a boilerplate for this configuration.
Here is where I am at. I am just trying to send a message using SQS. I am getting an error:
Error executing "GetQueueUrl" on "https://sqs.us-west-2.amazonaws.com";
AWS HTTP error: Client error: `POST https://sqs.us-west-2.amazonaws.com`
resulted in a `400 Bad Request`
I tried many permutations of keys in the enqueue.yaml file but did not get it right. I used this for help but could not get it to work. https://enqueue.readthedocs.io/en/stable/bundle/config_reference/
->> Edit: I found that you can add the topic and queue names to the DSN. I no longer get the error and a topic is created, but the Queue is not. Now, the message bus is working, but synchronously and locally. No message is sent to AWS.
These are the Composer libs I installed. I am sure that there are too many, but I kept trying to make it work.
"aws/aws-sdk-php": "^3.19",
"enqueue/amqp-lib": "^0.9.8",
"enqueue/enqueue-bundle": "^0.9.8",
"enqueue/messenger-adapter": "^0.2.2",
"enqueue/snsqs": "^0.9.0",
"guzzlehttp/guzzle": "^6.0",
"symfony/amqp-pack": "^1.0",
"symfony/messenger": "4.2.*",
This is my messenger.yaml
framework:
messenger:
transports:
amqp: 'enqueue://default?topic[name]=testQ&queue[name]=testQ'
routing:
# Route your messages to the transports
'App\Message\SmsMessage': amqp
This is enqueue.yaml
enqueue:
default:
transport:
dsn: '%env(resolve:ENQUEUE_DSN)%'
client:~
This is the entry in .env
###> enqueue/enqueue-bundle ###
ENQUEUE_DSN=snsqs::?key={key}&secret={secret}&region=us-west-2
###< enqueue/enqueue-bundle ###
This is the code in a controller to send a message:
public function index(MessageBusInterface $messageBus) {
$message = new SmsMessage('This is so cool');
$messageBus->dispatch($message);
...
}
I had this same issue which i managed to fix.
This is my messenger.yaml config that's working with SQS
transports:
sqs:
dsn: enqueue://default?topic[name]=YOURTOPICNAME&queue[name]=YOURQUEUENAME&receiveTimeout=3
Hopefully this is of use to someone

Not able to create accounts for Private Ethereum Blockchain using Geth and Web3 API

I am unable to create accounts for Private Ethereum Blockchain using Geth and Web3 API.
personal.newAccount(passwd) is not working for me. Please explain how to create account using above command.
And also, I am unable to install "ethereumjs-accounts".
If you try to search the internet why the "geth json rpc personal api" is not working, you will find an excellent answer on Ethereum Stack Exchange which I'd like to quote in full:
First, a note on safety:
You should not make the personal API available over RPC
If you are on a local, trusted machine, you should use IPC instead of RPC. Otherwise, anyone who can connect to your node via RPC can try to brute-force your passwords and steal your Ether.
All administrative APIs are available by default over IPC, so no need to use any flags with geth
To connect via IPC:
Install my library:
npm install web3_extended
var web3_extended = require('web3_extended');
var options = {
host: '/home/user/.ethereum/geth.ipc',
ipc:true,
personal: true,
admin: false,
debug: false
};
var web3 = web3_extended.create(options);
web3.personal.newAccount("password",function(error,result){
if(!error){
console.log(result);
}
});
Replace the host variable with the proper path for your system.
Note: All requests via IPC must be asynchronous.
Some Alternatives:
I don't know why you want to create new accounts via web3, but it's likely not the best way to do what you're trying to achieve. It is much safer and more modular to use a hooked web3 provider with a client-side light wallet or to simply use the Mist browser which handles all accounts for you.
Now for the technique (don't do this)
You need to enable the personal API over RPC. Do this by starting geth with
geth --rpc --rpcapi "db,eth,net,web3,personal"
Then you can use the personal_newAccount method via RPC. It's not implemented in web3.js, so you need to manually issue the RPC request. For example with curl:
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["password"],"id":1}' localhost:8545
creates a new account with password password and returns the address:
{"id":1,"jsonrpc":"2.0","result":"0x05ca0ddf7e7506672f745b2b567f1d33b7b55f4f"}
There is some basic documentation
Alternatively:
Use the unofficial extended web3.js
this allows you to use the personal, admin and miner APIs via a standard web3.js interface.
Published on Feb 16 at 8:34 and released under terms of CC BY-SA 3.0 by Tjaden Hess.
The command must be personal.newAccount()
Then the console asks for passphrase, give your required password then it again asks for confirmation.
An output in the form of Address("0x----------------------------") will appear.It is 1 account/address for your private network.

ejabberd contribution mod_apns does not work

I have added mod_apns to my ejabberd server. You can find this module here.
my ejabberd.yml configuration is like this:
mod_apns:
address: "gateway.sandbox.push.apple.com"
port: 2195
certfile: "/Applications/ejabberd-15.10/conf/cert.pem"
keyfile: "/Applications/ejabberd-15.10/conf/key.pem"
password: "myPassword"
the address is sandbox since I am still in development phase. And I have tested my cert.pem and key.pem and they are valid and working.
I send my device token to ejabberd server like this:
<iq type="set" to="myEjabberdServer.com">
<register xmlns="https://apple.com/push">
<token>myDeviceTokenWithoutAnySpace</token>
</register>
</iq>
I can see my device token is saved in apns_users database.
But I still do not get notifications when my user is offline.
Am I doing anything wrong?
Does it work with gateway.sandbox.push.apple.com?
should my device token be without space and only characters?
I appreciate your help..
You have asked for an alternate approach. This alternate approach takes the process of triggering push notifications by the ejabberd server.
1. Use the mod_interact library. This will provide you an ability to transfer your messages to another url.
2. From there on you can use the direct HTTP call for push notifications