Skip to content

BuildOASP4FnApplication

Dalfons0 edited this page Jun 20, 2017 · 31 revisions

Build your OASP4Fn application

In this chapter we are going to build a serverless backend with OASP4Fn. The main objective of this tutorial is to take an initial contact with OASP4Fn and the necessary tools we gonna use in the development, so at the end of it the user will be enough confident to start developing a new project with OASP4Fn without problems.

Result of the tutorial: Jump the Queue

Install tools

In this section we’re going to introduce all the necessary tools we’re gonna need to start programming and a initial configuration if necessary.

Visual Studio Code

Download the installer from the official page and install it. Once installed, the first thing you should do is install the extensions that will help you during the development, to do that follow this steps:

  1. Install Settings Sync extension.

  2. Open the command palette (Ctrl+Shift+P) and introduce the command: Sync: Download Settings.

  3. Provide GIST ID: d976bc200f0403d8045b7e4ee39d4361.

In the case that you are unable to set up the extensions using the method mentioned, you can also use the scripts provided in this repository.

Node.js

Go to the node.js official page and download the version you like the most, the LTS or the Current as you wish.

Typescript

Let’s install what is going to be the main language during development: TypeScript. This is a ES6 superset that will help us to get a final clean and distributable JavaScript code. This is installed globally with npm, the package manager used to install and create javascript modules in Node.js, that is installed along with Node, so for install typescript you don’t have to install npm explicitly, only run this command:

npm install –g typescript

Yarn

As npm, Yarn is a package manager, the differences are that Yarn is quite more faster and usable, so we decided to use it to manage the dependencies of OASP4Fn projects.

To install it you only have to go to the official installation page and follow the instructions.

Even though, if you feel more confortable with npm, you can remain using npm, there is no problem regarding this point.

Serverless

Lastly, we gonna install the serverless framework, that gonna help us deploying our handlers in our provider we have chosen.

npm install –g serverless

Starting our project through a template

To start with the tutorial we gonna use the oasp4fn application template, so use the following command to clone it in your local machine:

This template comes with the structure that has to have an oasp4fn application and the skeleton of some handlers. This handlers are stored on event folders, which we can add or remove adjusting to our needs, so how we only gonna use http events, we gonna access to the cloned folder an remove the s3 folder inside the handlers folder:

Clone this wiki locally