API Introduction
Polite Fork Off As A Service (or PFOaaS) - https://pfoaas.desigeek.com/ is a modern REST API that solves the problem of one telling people to politely fork off. 😇
There are days when we all need such a service for various reasons, and I think it is a great way to release some pent-up frustration. 🖤 It is also a great way to get some laughs too. This is of course meant for hard code engineers, writing RPC free code 😜
API Usage
The API is simple to use; you make a GET request to the API endpoint and the relevant parameters. You can also use the API from the command line too. There are a few options to choose for the response format - plain text, JSON, XML, and HTTP. If you don’t select an option the default is HTML. The JSON response also supports a callback.
All the operations are idempotent, so you can make the same request multiple times and get the same response.
Here is a sample usage using the /row/:from
operation which requires one parameter - the name of the person wishing this. 💀 The output shown below is in plain text.
curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/row/Amit
The same operation in JSON format:
curl -H 'Accept: application/json' https://pfoaas.desigeek.com/row/Amit
Some of the other operations require more than one parameter such as the /shakespeare/:name/:from
that can be invoked as follows:
curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/shakespeare/Putin/Amit
There is a notion of filters, which are output modifiers. These are added to the URL as a query parameter and can be chained together. For example, the same operation as above but with the i18n
filter showing the output in Russia (Русский).
curl -H 'Accept: text/plain' https://pfoaas.desigeek.com/row/Amit?i18n=ru
The i18n
is used to translate the output to another language via the ISO 639-1 language code, and supports the following languages:
Language | ISO 639-1 |
---|---|
English | en |
Italian / Italiano | it |
Spanish / Español | es |
French / Français | fr |
Dutch / Deutsch | de |
Norwegian / Nederlands | nl |
Swedish / Svenska | sv |
Portuguese / Português | pt |
Russia / Русский | ru |
Japanese / 日本語 | ja |
Chinese / 汉语 | zh |
Korean / 한국어 | ko |
Turkish / Türkçe | tr |
API Details and Code
You can see all the API usage and examples at https://pfoaas.desigeek.com/ . I won’t go into the details here, but you can see the code on GitHub here .
You can see a simple theme in the code, and easy to follow along. This is a simple
NodeJs app that is hosted on Azure. If you want to run it locally, you can clone the repo and run npm install
, and then npm start
. The app will be available at http://localhost:5000
.
You can also run this as a docker container, and build the container yourself; the Dockerfile is included in the repo.
I would welcome any contributions and am open to adding more operations to the API. If you prefer to do this, adding a new PFOaaS operation is as follows:
- Fork the repo
- Branch into a feature branch (e.g.
feature/operation-name
)- See the operations in the
/lib/operations
folder for examples.
- See the operations in the
- Add specs using the
spec/operations
as examples. Note, the specs are needed for the operation to be added to the API. - Push the changes to your fork and merge
- Submit a PR. 👍
I look forward to seeing your contributions and hope this helps you de-stress and get you to smile. 😄 💜