In this training we will see the advantages developing with Node. We will also introduce the Document-oriented databases using Mongo / Mongoose.
Each sample contains a README.md
file that indicates the purpose of the sample plus a step by step guide to reproduce it.
In this sample we are going to install and configure Node.js and VS Code.
In this sample we are going to create a hello.js
file with console.log
message and a VS Code launch.json
file to run our first Node server.
In this sample we are going to create a simple NodeJS server that listen on port 3000
.
In this sample we are going to learn how to keep clean our code using callbacks.
In this sample we are going to use the global object process
and playing with the exit
and uncaughtException
events.
In this sample we are going to learn about Buffer
. We will create three samples managing buffers.
In this sample we are going to play with Node.js
addons.
In this sample we are going to learn how to require Node built-in
modules. As example we are going to use os
module and show some methods like hostname
, loadavg
and freemem
.
In this sample we are going to learn how to create a custom module and export it to be used in other file using CommonJS modules
.
In this sample we are going to learn how to create and configure a package.json
file, install a npm third library and use it.
In this sample we are going to demonstrate how to get a blocking code.
In this sample we are going to learn about setImmediate
vs setTimeout
methods.
In this sample we are going to learn how to use nextTick
method.
In this sample we are going to working with async code using callbacks
, Promises
and async/await
.
In this sample we are going to create a basic sample to work with Node.js Events
.
In this sample we are going to use previous sample, require it from other file and create different instances of EventEmitter
.
In this sample we are going to learn how to migrate sync function using events
to async
code.
In this sample we are going to create two EventEmitter
s instances splitted in two files and one unique node process
. That is, each EventEmitter
has its own file. So, we'll have the client
and server
files.
We need a comunication between client
and server
. To simplify it, the server
receives a client
instance like:
const client = new EventEmitter();
const server = require('./server')(client);
class Server extends EventEmitter {
constructor(client) {
}
...
}
...
module.exports = (client) => new Server(client);
The aim of this sample is implement a Task list
where the server
are listening each command
(event) emitted
by client.
The commands are:
add
: Add a task to the list.delete
: Remove a task from the list.ls
: Show all tasks in the list.help
: Give info about commands.
NOTE: if
client
emits other commands different than previous one, it responses withUnknown
message.
The workflow could be:
- The
client
emitcommands
that user writes in the terminal/console.Server
is listening thatcommands
. - The
server
emit aresponse
for each command.Client
is listening thatresponse
.
In this sample we are going to create a basic server using server.on('request')
and see info about HTTP
server response.
In this sample we are going to learn the differences between res.write
and res.end
.
In this sample we are going to learn how to make HTTP request from Node.
In this sample we are going to learn how create an http server and manage different routes.
In this sample we are going to see some os
module methods.
In this sample we are going to create an app for delete files older than 7 days.
In this sample we are going to create an app for truncate a corrupted file with duplicated code.
In this sample we are going to implement app
to watch files in specific folder.
In this sample we are going to send an http request
to understand a readable stream
.
In this sample we are going to learn how to improve performance reading big files using pipes
.
In this sample we are going to play with Readable
class from stream
module.
In this sample we are going to play with Writable
class from stream
module.
In this sample we are going to play with Duplex
class from stream
module.
In this sample we are going to play with Transform
class from stream
module.
In this sample we are going to use the zlib
module to crompress a file and using streams
and pipes
.
In this sample we are going to install and configure MongoDB.
In this sample we are going to install mongodb
via npm
and use it to create a connection with a database.
In this sample we are going to create a new database
and collection
and connect to it.
In this sample we are going to insert new user
in users
collection.
In this sample we are going to reuse the db
object and create queries
to find
documents.
In this sample we are going to implement some database
business and create queries
to update
documents.
In this sample we are going to implement some database
business and create queries
to remove
documents.
We are a team of long-term experienced freelance developers, established as a group in 2010. We specialize in Front End technologies and .NET. Click here to get more info about us.
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend