While Logging the Request object in Express is amazingly easy, doing so with the response is not quite as straight forwards.
We need to utilize a couple of tricks and some patching to get things working smoothly and get all the information we are sending back to the client.
We can also use this technique to perform some other manipulation rather than just logging, some use cases might be:
Firstly we need to create a basic middleware which can log our req, nothing new here other than our middleware is a higher order function which takes a logger making it more re-usable. …
In this post were going to bootstrap an Express application, bung on typescript and get GraphQL up and running in no time at all. 🚀
All the code discussed and given as examples is available in the repo and I encourage you to checkout the article tag for a nice snapshot.
We will be using ts-node in this example, it allows us to run typescript directly without any additional boilerplate 🤯. Feel free to add in transpiling if necessary 😒.
I recently came across a little known feature of Windows WSL. The ability to launch GUI apps!
I’ve started doing much more of my environment management in WSL rather than Windows recently, excellent tools from Jetbrains and VSCode make coding in this environment a doddle.
While installing some packages I noticed that I accidentally installed a desktop environment, this got me thinking, would it be possible to run some GUI tools.
Turns out it is and its incredibly easy!
You will need an X11 display server for windows.
I personally used https://en.wikipedia.org/wiki/Xming.
This allows the apps to be rendered on the screen. …
It’s entirely possible to get your Spring Boot application up and running in docker in less than 10 minutes.
Let’s run through this process first in theory, then in practice. We will start by covering what we are trying to achieve, followed by installing some dependencies and making sure everything is in place to hit the ground running.
By the end we will have a fully working Spring boot application deployed to your local docker installation and we will have it running with health checks.
To run our application we are going to need:
Many automation libraries exist for python which help scrape sites and perform testing. Projects like Roboform, BeautifulSoup and requests all provide excellent features.
One slightly lesser known name to Python projects is Selenium. It’s an industry accepted automation and testing framework for UI’s. Unlike other web browsing/scraping libraries it actually plays out inside a browser as though the system was being interacted with.
A major hurdle in web scraping can be how JS causes the site to change after loading. We might find that a request response being parsed in something like BeautifulSoup is missing lots of parts. This is because sites that use JS need a browser such as chrome to actually run the JS code. …
Picking up from where we left on in the previous guide, we are going to start to look into how we can work with our project and its files.
You should now be able to go ahead and trigger a Gradle build at the root of the project.
This will trigger the following series of events:
If you have spent any amount of time with the Python programming language, you might have come across the main scope conditional. It looks something like this:
if __name__ == "__main__":
What this method does is perfectly summarised in the Python Docs for the standard library:
A module can discover whether or not it is running in the main scope by checking its own __name__, which allows a common idiom for conditionally executing code in a module when it is run as a script or with python -m but not when it is imported
Let’s take a look at some examples, why we might find it and under what conditions it is triggered. …
Python is full of extremely powerful functional programming expressions. Across all programming languages, one of the most commonly used of these is the ternary operator.
We might recognize this operator from other languages as:
(condition) ? (return if true) : (return if false)
In comparison to most programming languages, Python has a somewhat unusual syntax and that’s because it’s not actually a ternary operator at all. Python has a Conditional Expression using the
else keywords to replace
The syntax for this Conditional Expression can be summarised as:
(return if true) if (condition) else (return if false)
You can see the ordering is slightly different when comparing to the more commonly found ternary operator, however, the operation has the same common…
I don’t intend on making a long deep dive into CORS during this short blog. But we should know the fundamentals.
CORS is an access control mechanism. It’s designed to prevent unauthorised access to an API.
It uses HTTP headers to manage this ACL.
It uses Pre-flight requests when queries are sent across domains. So for example from your frontend server to your backend server.
The below flow chart, courtesy of Wikipedia highlights the path of a cross origin request.
Chances are if you have made a cross origin request using your frontend framework the browser has blocked it because it did not contain the relevant access control headers. …
A nifty feature of the Jetbrains IDE tools is the file nesting. You may have seen on occasion that the IDE will compress files of the same name into a tree with the parent at the top and the children below. Say for example when js is minified the .min.js file can be displayed in a tree display under the main .js file.
We can use this to our advantage when working with Angular by compressing the file tree’s which can become quite populated in a large project.
Looking at this home-page component we can see a rather cluttered native view with the .html, .scss, .spec.ts and .ts …