A function who serves as argument to another function, the second one can call it.
Advantages | Disadvantages |
---|---|
Simple, conceptually | Rough, when nesting many (Callback hell) |
Universal, they are JS native | Little intuitive, to understand the flow is tedious |
· First callback argument allways will be the error.
Object which represent the end or fail of a asinconous operation.
Advantages | Disadvantages |
---|---|
Easily chaining, clair and easy to chain hadling a flow | No exceptions, require .catch() method to handel errors |
Powerfull, really capable to handle complex async ops |
· use promise instead callbacks. Watch out with promise hell.
An async function returns a Promise object. If the function return a value the promise resolve that value and if throws an error or falls on a exception it reject that error or exception.
The await stops an async execution until a promise will resolve or reject. |
· requires a tryCatch block.
Libuv it's a C++ library to manage OS events. It's who 'talks' to the OS.
Works togheter with V8.
Libuv has a queue of finished events (Systems events). For each loop Libuv checs that queue, if are something perform a callback to V8.
Non-blocking IO: Capability to make actions without stop others.
Note: V8, Libuv and Javascript are all sincronous.
NodeJS performs actions asynchronous (if we tell to do it)
Protocol over which communicate the client and server.
Software which delivers contents requered by the client. It's distinct to a server (hardware).
Some details:
- Node can create it's own web server. Includes the tools for it.
- Low fault tolerance. An unhandled error can down a server.
- Frameworks vs vanilla. Both ways can be taken to mount a webserver.
The client sends a request to the server, the server process it and return a response. Both, client and server, knows information about each other (like OS, browser, ports and so on) by the request and response.
METHOD | Standard use |
---|---|
GET | Read a resource |
POST | Create a new resource |
PUT | Update an existing resource |
PATCH | Update a property of an existing resource |
DELETE | Remove an existing resource |
A middleware it's code that run between the start of therequest and the endpoint of the server.
Model View Controller Code design pattern who sepair the code about responsibilities.
SQL databases starts using at 80s. NoSQL databases are newer.
SQL | NoSQL |
---|---|
Organize the information on chunks relating between them through unique Id | Extremely usefull when we need to store very changing data |
Group the info in "tables" | Group the info in "collections" |
Meets ACID props (make the system strong and less vulnerable) | |
Engines: MSSQL, Oracle, Postgres, MySQL, SQLite, and more | Engines: MongoDB, Cassandra, RethinkDB, FirebaseDB, Redis, and more |
Object Relational Mapping it's a software model which map db tables on entities for a easily handling.
Object Document Mapping, same as ORM but document oriented.
It's the process property which store the command line arguments passed to node when the command runs.
By default argv stores:
- node path.
- file which node runs path.
- and more, the rest of params.
Visual interface which can user interact with a software or process.
Piece of software that handle business logic and data persistence.
Piece of software that works as base and organization on a software development. Frameworks examples
- Frontend: Angular, React, Vue, Svelte, Ember.
- Backend: NextJS, sails, express, adonis.
When use a framework? | When NO use a framework? |
---|---|
Looking for community support | Have not community support |
Fast developmente time | We don't know the language |
Other tools transparent integration | We fall into the frameworks fashion |
Open source programming language, Microsoft leadered, with OOP tools for big projects. It's a superset of Javascript.
Note: tsc CLI for Typescript.
YES TS | NO TS |
---|---|
Big projects | Weak OOP knowledge |
Teams with strong OOP knowledge | Type it's a problem |
Constant evolving |
Language writen over another.
An API:
- Reduce software coupling.
- Aggregate differential value to an enterprise.
It's a group of protocols and difinitions used to develop and integrate software. API stands for Application Programming Interface.
General and reusable solution to a common problem on software development. This group of technics anwers questions like:
- What programming language use?
- What framwork?
- Use disegne patterns?
- How handle project scafolding?
- What DB to use?
- So on
Some common architectures are:
- Client/server architecture.
- N layers architecture.
- Bus events architectures.
- Master/slave architecture.
- Anothers
Commonly used for APIs and desktop apps.
Low coupling apps like mobile apps and APIs
REST stands for REpresentational State Transfer. REST are some principles which describe how to resources are defined and accessed through a web service.\
A web server which implements REST principles is called RESTful.
Some RESTful details:
- Clean and intuitive URIs.
- Use JSON or XML format info.
The REST architecture focus on:
- Performance.
- Scalability.
- Simplicity.
- Portability.
- Reliability.
- Client/server
The backend and frontend (in this case for web apps) are completly separated. Two diferent frameworks.
- Layers system
The layers are sorted hierarchically and restricted to the layers next to.
- Stateless
A request must contain all data for the server understand and build the context to process it.
- Uniform interface
Are guided for:
- Resource identification.
- Resource manipulation.
- Self-descriptive repsonses.
- State administration (throught HATEOAS)
These four pilars are handled throught: HTTP Verbs, Media types and HETEOAS.
- Cache
Derived of stateless, all responses need explicitly tagged as cacheble or not cacheble.
- Code on demand (optional).
Allow a client access to resources not knowing how to process it.
Docker it's a container handler. Docker it's a container handler. The main idea it's the creation of isolateds, lightweight and portable containers in which the apps runs so getting easily deploys.
It's a tool developer and testers oriented.
- To create a container we need an image, DockerHUB it's a good place to start looking for.
- An image it's created by a Dockerfile.
- A Dockerfile it's instruction based.
- An image could be shared and reused.
- The container data persists ONLY on volumes.
It's one and only autonomic programm unit.
Advantages | Disadvantages |
---|---|
Easy to develop | No flexible |
Easy to test | Hard to maintain |
Easy work alone | Hard to scale |
Easy to deploy | Unreliable potential |
"Microservices are reached by pain, not pleasure"
Collection of autonomous and small services.
Features:
- One and only resposability.
- Persistence.
- Resilience.
- Logs.
- API good defined.
Advantages | Disadvantages |
---|---|
Easy scale | Hard e2e test |
Allo technologies mixing | More chance to duplicates |
Trustable potential | Information integrity |
Tranparents deploy | More specialized workteams |
Process where every change to our app must be tested and verified by tests.
Some tools: TravisCI, Azure DevOps, Jenkins...
Similar to CI but the tests must to ensure that every change are production ready. The production deploy still manual.
Similar to continuous delivery but runs until production.
Steps to follow on a devops process.
#NodeJS
#JavaScript
#ES6
#express.js
#HTTP
#SQL
#NoSQL
#sequelize
#mongoose
#backend
#frontend