Sign in

A Computer Science Student

Hello Peppos!!!

A Distributed system, at the most basic level, it’s a collection of computers or systems that are ‘combined’ to form a single computer for the user, if one system fails it doesn’t damage the whole system, they all have one shared state and operate concurrently.

They are connected through a network to share information easily, this connection can be an IP address or even cabling.

This article was based on the following articles:

Types of Distributed Systems

These systems may be Client/Server Systems (Distributed) or Peer to Peer Systems …

Client/Server Systems


Hello Peppos!!!!

So you want to upload and downloads files from your API, worry no more cause in this tutorial we are going to implement a solution that does exactly that using LoopBack 4.

Getting the Packages and Creating the project

First things first, get the Loopback 4 Package to start building the API.

npm install -g @loopback/cli

Then to create a new project:

lb4 app

Answer the following questions this way for the App(or conforming to your project needs):

? Project name: Upload-Download
? Project description: An API made with LoopBack 4.
? Project root directory: (upload-download)
? Application class name: (UploadApplication)
? Select features to enable in the project…

Hello Peppos!!!!

So you have made your first node.js application, and you need a way to document your methods, variables and paths to the world.

Worry no more cause the Swagger package is here to help you.

This little package makes a fancy and organized interface that shows all the documentation that you insert into it.

Here’s an example of the full project that we will do today:


Hello Peppos!!

Today we are going to add Authentication to the Todo App that we previously made to make the application’s API more secure.

LoopBack4 has a Authentication package with the name of @loopback/authentication in which secures your app’s API’s endpoints with custom authentication strategies and an @authenticate decorator.

This tutorial is based on the tutorial on the LoopBack4 Website.

Take a look on the final project if you have any problems or errors in the making of this tutorial.

JSON Web Token Approach


Hello Peppos!!

LoopBack is a Node.js and TypeScript framework based on Express, open-source and Highly customizable. It allows you to quickly create APIs in a really easy way.

In this tutorial we are going to create a Todo App API using this framework, make sure that Node.js and MongoDB are installed before doing this project.

This tutorial is based on the Todo Tutorial made by LoopBack4.

Installing and running LoopBack4 for the first time

Installing LoopBack4 is as easy as running the following command:

npm install -g @loopback/cli

Then to create a new project:

lb4 app

Answer the following questions this way for the Todo App(or conforming to…


Hello peppos!!

Today we are going to make a CRUD app using the mongoDB database (i made a tutorial on installing on manjaro here) and using Node.js (install tutorial here, also on manjaro).

>>>>>ALSO, USE POSTMAN<<<<<

Building the Environment…

After creating the folder that will host the project, we initiate the project with:

npm init

Also, we will need the following packages:

  • Express.js — Framework that allows developing of web apps in a simple way.
  • body-parser — Used to manipulate JSON files
  • mongoose — Database that supports the project

Install the needed packages with:

npm install --save express body-parser mongoose

Create the index.js


Hello peppo!

You can probably use this tutorial on Arch (although if you are using Arch you probably know more than me), but i think this tutorial doesn’t translate very well to Debian based systems, but don’t worry, there are many tutorials out there to help you.

NOTICE: The yay package manager will be necessary.

Getting the package

To get the mongodbpackage wefirst need to get a package to extract that kind of packages called base-devel :

yay -S base-devel

And select all the repository cores

Then get the mongodbwith:

yay -S mongodb

If you want UI interface get the mongodb-compass with:

yay…


REST Architecture

REST REpresentational State Transfer is an architecture model that uses the HTTP protocol for communication with the GET, POST, PUT and DELETE methods.

The best known representation methods to present a resource are JSON and XML. For more info click here.

Starting out…

After creating a directory for our project you need to…

  • Initialize the project.
npm init
  • Get the needed packages.
npm install --save hapi

Getting POSTMAN

Postman is a great tool when trying to dissect RESTful APIs for testing. …


EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow. It’s just plain JavaScript.

Taken from https://ejs.co/

As we can see, EJS is a tool that lets us use HTML code on our Node,js program, we are going to make a little example showing how EJS interacts on the Node.js environment.

It’s supposed that Node.js is already installed on the computer before this tutorial.

Dependencies and Building the Environment

So, after creating the directory and opening a terminal in that location we initiate the project with:

npm…


We already seen how it is easy to create an HTTP server in the end of my first tutorial.

Today we are going to see how Node.js responds requisitions with the base on the URL.

Let’s consider 3 categories for your server:

  • Express
  • Node
  • OWM

The JavaScript code to implement a service that satisfies our needs would be:

var http = require('http');

var server = http.createServer(function(req, res) {
var cat = req.url; //gets the url
switch(cat){
case '/exp':
res.end('Express'); //reponds
break;
case '/node':
res.end('Node'); //reponds
break;
case '/owm':
res.end('Open Weather Maps'); //reponds
break;
default:
res.end('Welcome …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store