Proxy API paths - proxy

I'm building an API using KOA and have read some best practise on versioning. This answer pointed out that versions should be hidden from the client.
My question is, how would I go about doing this? I've read some mentions of using an API proxy. Would I be using something like "Squid" as a reverse-proxy, or are there better Node/KOA specific solutions for this type of work?

I think GraphQL is the perfect tool to avoid pain in the ass with API.
Yes, in some point it breaks the REST philosophy but gives flexibility.
All you need to build a flexible API with no worry about version is: Koa, Objection + GraphQL.

Related

How to use the incluxdb1-client library of golang to query the data?

My library is github.com/influxdata/influxdb1-client/v2,and I need to use it to operate the VictoriaMetrics, For example, I need to make the following query:
sort_desc(avg(idc_bandwidth_5m_data_cube_just_idc_bandwidth_kilobits{idc=~"$cluster", isp=~"$isp"}[5m]) by (idc))
What should I do? Or is there another better library to use? Help me!!!
Can you give me a sample code?
I'm afraid github.com/influxdata/influxdb1-client/v2 can't be used for reading data from VcitoriaMetrics. You need a library which can send PromQL/MetricsQL queries via HTTP and parse responses. I'm not sure if there are a good Golang lib for that. I've heard only about JS lib.
In general, sending queries and parsing responses to VictoriaMetrics or Prometheus is rarely needed. And when needed, it is usually implemented from scratch. Please use the following link as a reference.
You might be also interested in the following issue I'm afraid github.com/influxdata/influxdb1-client/v2 can't be used for reading data from VcitoriaMetrics. You need a library which can send PromQL/MetricsQL queries via HTTP and parse responses. I'm not sure if there are a good Golang lib for that. I've heard only about JS lib.
In general, sending queries and parsing responses to VictoriaMetrics or Prometheus is rarely needed. And when needed, it is usually implemented from scratch. Please use the following link as a reference.
You might be also interested in the following issue https://github.com/VictoriaMetrics/VictoriaMetrics/issues/108

graphene: is relay needed for a complete, functional server?

Background:
I have a nodejs graphql server, and I want to learn Fastapi by reimplement the server with it.
It seems that graphene is the only option.
I learned graphql with Apollo,(and the server is built with apollo-server) and found all those "relay"-related features and conceptions confusing.
Connections, nodes, edges...
(I did some research and know the meanings of those concepts now)
From other SO questions like this, all(?) relay features can be implemented by other means.
But there is even a graphene.relay, so I doubted my conclusion.
question:
Is relay necessary to built a graphql server?
Just want to make sure it's not a dead end before spending too much time on it.
Relay specs are just a type of specification. It is not necessary to build a GraphQL server. However, if you are specifically referring to graphene-python, then I'd recommend using Relay as it already has complete support for Relay specs.

Any other GraphQL Federation implementations apart from Apollo?

I have been trying to build a federation gateway on top of existing graphql services and am curious if there are any other implementations of the same apart from apollo federation?
I tried to find but couldn't find any. I am also looking for subscription on the federated gateway. Does anybody know any other implementations on the same?
It seems that fastify-gql now supports being a Federation Gateway, with subscription support included.
Yes:
Graphene (for python) with Graphene-Federation implements federation (there is in built support for graphql subscriptions). I have used this for a large-scale project and it works just fine (Although I personally prefer apollo)
I haven't personally used this, but tyk.io seems to have a pretty neat solution for federation: https://tyk.io/blog/an-introduction-to-graphql-federation/
Bramble - https://movio.co/blog/building-a-new-api-platform-for-movio/
Great for GoLang. I haven't used it, but I have a friend who has
Something else that is not pure "federation" per-se - but which would solve your problem easily is GraphQL Mesh. https://www.graphql-mesh.com/
Hope this helps :) !

Apollo GraphQL Server vs graphql-sequelize vs from scratch?

I'm a beginner to javascript and GraphQL, looking to implement a simple app that interacts with a MySQL database and wraps a 3rd party REST API. GraphQL seems like the right fit, and Javascript has first party support.
To get started, should I use Apollo's GraphQL Server or mickhansen's graphql-sequelize (with his dataloader-sequelize) or write one from scratch?
In all cases it seems to use sequelize under the hood, which mickhansen is a major contributor to.
I'm looking for the advice and analysis of more experienced javascript and GraphQL programmers.
I realise the final decision is subjective but I'm looking for a thought out pro/con of all 3 different solutions.
Thanks in advance!
I would recommend not to start writing your server from scratch, but to use existing libraries and seed projects. Personally, I use Typescript with the Apollo stack, combined with several other libraries for splitting the schema to files, and auto-generating types.
This post demonstrates how to modularize your graphql server code, providing a seed project you can clone. Hope it helps! :)
I am currently using Apollo GraphQL with Sequelize. Sequelize is your ORM to interact with the DB, it can function with Apollo which takes care of your GraphQL. GraphQL is a thin api layer anyway. One problem i have been running into is dataloader implementation with vanilla Sequelize. I am trying to figure it out to get it working. I am hoping to work through it this week.

Is there a good DNS server library in ruby?

I want to create a test DNS server in ruby, but could not find anything suitable. I found pnet-dns(http://rubyforge.org/projects/pnet-dns/). This project is incomplete and buggy. Is there any alternative?
A language-agnostic alternative is to use PowerDNS pipe backend. Because it communicates with a name server across a simple pipe, it can be written in any language, including Ruby. (The simple example in the documentation uses Perl but it should be easy to translate.)
RubyDNS is what you're looking for.
Checkout an another approach of DNS server in ruby using celluloid: https://github.com/celluloid/celluloid-dns
The original celluloid-dns is horribly incomplete (v0.0.1). Recently, RubyDNS is being copied into celluloid-dns (I'm doing this as we speak). RubyDNS will be modified to work with the updated celluloid-dns since all core functions will be moved from RubyDNS to celluloid-dns.
If you want something that works right now, use RubyDNS. However, in the future, if you just want the low level APIs, use celluloid-dns.
Have you looked at Dnsruby?
It aims to be fully RFC compliant, although it focuses primarily on the client side. It is, however, possible to write your own server - use Dnsruby::Message#decode to decode incoming packets, and a zone of RRSets holding your test records. You can then encode your packets to send back to the client.

Resources