const {log} = console;

setTimeout( ()=> log("execute this code later...") , 1500 )
import http from "http";

const server = http.createServer( (request,response)=> {
    response.statusCode = 200;
    response.setHeader('Content-Type', 'text/plain');
    response.end('hello world')
})

server.listen(3000 ,()=> console.log('listening on localhost:3000'))
import http from "http";
import fs from "fs/promises";

const server = http.createServer( async (request,response)=> {
    response.setHeader('Content-Type', 'text/plain');
    try{
      const data = await fs.readFile('/somefolder/somefile.txt','utf8');
      response.statusCode = 200;
      response.end(data)
    }catch(error){
      response.statusCode = 500;
      response.end(error.message)
    }
})

server.listen(3000 ,()=> console.log('listening on localhost:3000'))
import http from "http";
import fs from "fs";

const server = http.createServer( (request,response)=> {
    const stream = fs.createReadStream('/someHugeFile.txt');
    stream.on('data', data => response.write(data));
    stream.on('end',()=> response.end());
    stream.on('error', (error)=> log(error.stack));
})

server.listen(3000 ,()=> console.log('listening on localhost:3000'))
import http from "http";
import fs from "fs";

const server = http.createServer( (request,response)=> {
    const stream = fs.createReadStream('/someHugeFile.txt');
    stream.pipe(response);
})

server.listen(3000 ,()=> console.log('listening on localhost:3000'))
http.createServer( (request,response)=> {
   fs.stat('/folder/file.txt', (error,stats)=> {
        if(error) return log(error.stack);
        if(stats.isFile()){
            fs.readFile('/folder/file.txt',(error,data)=> {
                if(error) return log(error.stack);
                response.writeHead(200,{'Content-Type':'text/plain'});
                response.end(`data`);
            })
        }
    });
}).listen(3000 , ()=> log('server is listening on localhost:3000') )

Jest, Vitest

webpack, esbuild, swc

prisma / mongoose

PM2

Monitoring node

Jimp

Lodash

JS extras

Questions?