Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for April, 2017

Enhanced JavaScript with TypeScript

Tuesday, April 25th, 2017 by Servage
typescriptTypeScript is a relatively new programming language from Microsoft. It is a superset of JavaScript and adds some useful features to make JavaScript coding easier and less prone to errors. What does that mean and what are these useful features? Let’s find out! Static Type Checking As the name suggests, TypeScript introduces type checking. In practise this means that variables can now have a type. In typical JavaScript, all variables are created with the var keyword in ES5 and with let in ES6. The variables are automatically assigned the correct type based on what value the variable holds. This makes JavaScript a dynamically typed language. However, TypeScript is a statically typed language since ...

Getting started with BDD and Behat

Tuesday, April 18th, 2017 by Servage
bdd-behatBehat is a popular behavior-driven development (BDD) framework. In Behavior-driven development, developers write the behavior of their application before implementing it with PHP. This way of working helps you design and plan your application instead of jumping right into coding and thinking afterwards if issues arise. Today we will see how BDD can be used with Behat and other tools that work closely together with it. BDD Workflow with Behat The workflow of BDD is quite similar to that of TDD. The first task is to write down the behavior of a feature that is about to be implemented. In Behat, this is done using Gherkin, an easy-to-read language that even those who ...

Modernized strings in ES6 JavaScript

Friday, April 14th, 2017 by Servage
ES6ECMAScript 6 (ES6) has brought a lot of great features to JavaScript over the years and continues to do so as the specification is being developed. One of the new features is called template strings, which is often used in for example modern Angular or React development. It allows developers to use strings in more advanced and easier ways. This includes a new way to use multi-line strings, using strings inside variables and more with a cleaner syntax. Multi-line Strings You have likely used the concatenation operator (+) or a backslash (\) to make multi-line strings in the past. While this works fine, the syntax is is not very clean and makes the ...

Protecting your application from cross-site attacks

Sunday, April 9th, 2017 by Servage
xss-shieldCross-site scripting (XSS) is an attack where a user embeds malicious code as part of a website. This can be done for instance by submitting a comment on a blog website. If the comment contains a malicious script, it will be executed by all visitors who read the blog article. These attacks are quite common, and there are many varieties of XSS scripting. Let’s find out what methods are available to protect web applications from these vulnerabilities. Escaping User Input This is arguably the most important thing to do to prevent XSS attacks. On many websites, users are allowed to freely fill out forms that save the input in a database. Let’s consider ...

Testing APIs with mock data

Wednesday, April 5th, 2017 by Servage
api-mockIt is common to see a front-end application that gets its data from a back-end API. If you are working on one and don’t have a working API yet, where could you get data to test your application? You could always hardcode some fake data into the application itself, but what if you could use a real API and real HTTP requests instead? Let’s look into some free API mocking services that allow you to do this. JSONPlaceholder jsonplaceholder.typicode.com is an API testing service with a set of commonly used data. You can fetch users, posts, todos and even photos and their thumbnails from the API. In some cases, all type of data ...

Comparing development environments

Sunday, April 2nd, 2017 by Servage
development-environmentWhen it comes to web development, there are many development environments to choose from. Roughly speaking, a development environment means the computer on which you run the applications you are developing. Such a computer can be virtual or physical and local or remote. This time we will compare popular development environments, such as Vagrant, and see what advantages and disadvantages each has. Vagrant Vagrant is one of the newest and most used development environments by professional developers. Here is how it works: You install Vagrant and a virtualization environment compatible with it, either VirtualBox or VMWare. Next, you open a command line and tell Vagrant which type of development environment you would like ...