Create a RESTful API with authentication using Web API and Jwt

Published on March 15, 2016 in .NET, C#, Entity Framework · Read time 23 minutes

Web API is a feature of the ASP .NET framework that dramatically simplifies building RESTful (REST like) HTTP services that are cross platform and device and browser agnostic. With Web API, you can create endpoints that can be accessed using a combination of descriptive URLs and HTTP verbs. Those endpoints can serve data back to the caller as either JSON or XML that is standards compliant. With JSON Web Tokens (Jwt), which are typically stateless, you can add an authentication and authorization layer enabling you to restrict access to some or all of your API. The purpose of this tutorial is to develop the beginnings of a Book Store API, using Microsoft Web API with (C#), which authenticates and authorizes each requests, exposes OAuth2 endpoints, and returns data about books and reviews for consumption by the caller. The caller in this case will be Postman , a useful utility for querying API’s. In a follow up to this post we will write a front end to interact with the API directly. Set up Open Visual Studio (I will be using Visual Studio 2015 Community edition , you can use whatever version you like) and create a new Empty project, ensuring you select the Web API option…

How to debug websites on your mobile device using Google Chrome

Published on January 31, 2016 in Other · Read time 3 minutes

I can’t believe I have survived this long as a web developer without knowing you can debug websites (JavaScript, CSS, HTML, TypeScript etc.) directly on your mobile device using Google Chrome developer tools. If you are currently using emulators/simulators or testing solutions such as Browser Stack, you will love this easy and free solution. Be warned, however, you will be expected to download 6+ gigabytes of stuff before the magic begins. I’ve only tested this on my Samsung Galaxy S6 Edge (running Android 5.1.1) but I believe it also works on an iPhone. Prerequisite Software Before connecting your phone to your computer, please ensure you have all of the following software installed; A recent version of the Java Development Kit (JDK) Android Software Development Kit (SDK) Android SDK Platform Tools If you have a Samsung mobile device, ensure you have the Samsung Android USB Driver for Windows installed. If you don’t please download a suitable driver for your device. Google maintains a helpful (although not comprehensive) list of drivers to help you out. Set up your device Setting up your device is pretty simple. Start by connecting it to your computer with a USB cable and…

How to avoid burnout

Published on November 19, 2015 in Career · Read time 6 minutes

You work hard 7 days a week, and you do your best to stay up to date with the latest industry trends. Inevitably you will become demoralized and demotivated and eventually suffer a partial or full-on collapse where all your progress comes to a grinding halt. After a period of time (days, weeks or months!) you get back on track and pick up where you left off, eventually leading to the inevitable burnout cycle where you end up back where you were. I’ve been through this cycle several times, and I’ve even blogged about it before , but now I have learnt the ultimate techniques to break the endless cycle and find a more maintainable work-life balance. Here are my 5 ultimate tips to avoid burnout. Stop Start by reducing your workload. You are probably doing some or all of the following on a regular basis; Watching training videos, doing some form of professional online training Freelance or other paid work for friends, family, or professionally Contributing to open source, or some form of unpaid work where you have responsibilities and deadlines Your day job You probably can’t stop doing your day job, so you will want to give that the highest precedence. However, I can’t tell you how…

TypeScript beginners guide

Published on October 02, 2015 in TypeScript · Read time 8 minutes

TypeScript is a tool that enables you to write better JavaScript. You may have heard that TypeScript is a superset of JavaScript, but what does that mean? TypeScript is JavaScript. If you know JavaScript already, then you already know JavaScript. You can convert an existing JavaScript file to TypeScript simply by changing the file extension. TypeScript has a very low barrier to entry (you can easily write it using Notepad) and has a small learning curve. TypeScript has a transpiler, called tsc which transforms (compiles, if you like) your code from TypeScript to JavaScript. If you use any TypeScript paradigms, then your code cannot be understood directly by a JavaScript execution engine ( V8 for example). You can, however, enable source maps and debug your TypeScript code directly. Developers: “Why should I bother using TypeScript?” When I talk to developers about TypeScript, the first thing they ask me is “Why should I bother using TypeScript?” or “I already understand JavaScript and I’ve been using it for x years, so I don’t feel the need to use it…“. This is a great platform to explain to people why they should use TypeScript. Not because I’m on some personal mission or…

Writing AngularJS 1.x with TypeScript

Published on September 24, 2015 in TypeScript · Read time 31 minutes

AngularJS 1.x is a front end JavaScript framework that has gained huge traction and popularity in the development community. AngularJS greatly simplifies previously hard tasks like two-way data binding, templating, the MVC design pattern, despendency injection and more. Using TypeScript, we can create more robust and scalable AngularJS code to deliver the ultimate user experience whilst avoiding the traditional spaghetti code nightmare that JavaScript applications can often descend into. AngularJS version 1.x is written in JavaScript. Its successor, Angular 2.x, is written using TypeScript. It was originally going to be written in Google’s propriety language AtScript, but the teams have merged the projects and are now working together on TypeScript. All the code for this project is available to view on GitHub . There is also a demo project on GitHub pages . Note : This tutorial assumes you have some knowledge of Angular 1.x. Note : This tutorial tries to stay editor independent, meaning the concepts apply to TypeScript specifically and not to an editor. When necessary, screenshots showing relevant information will be of VS Code . VS Code is a free, cross platform editor hat has…