Coder Social home page Coder Social logo

usingexpress's Introduction

usingExpress

Just playing and exploring with Express, I'm going to write here the new things I learn.

Using Exports:

https://youtu.be/hyYbs3SANRo

I'm exporting the const 'connection', so it can be used(import) from another file By default a module is "encapsulated", so anything you want to use out of that module you need to tell Node that you are going to use it in another module (file).

//The second one is the most recommended

//module.exports = connection;
//exports.connection = connection;

What is middleware?

https://www.youtube.com/watch?v=_GJKAs7A0_4

  • Basically, middleware is code or functions running in the server, between the request and response. Middleware runs from top to button in our code, and it runs that way until we exit the process or explicity sends a response to the browser.

get = Only runs for "get" requests. use = Runs for every type of request.

  • Code always stops every time that a middleware is executed, that's why we use the function next(), to keep the code running after it ends the execution.

  • There are a lot of 3rd part middlewares that can be used to with funcionalities like: cookies, validations, security, etc. Most of those middlewares are made to help us, so we don't need to create one from the scratch because we can use the ones created.

  • Express has some middlewares that allow you to request for example, static files, you need to specify the directory where those files (css, images, etc) are going to be accessed in this case. Example: app.use(express.static(__dirname + '/public'));


Route method

https://www.youtube.com/watch?v=iM_S4RczozU&t=435s

usingexpress's People

Contributors

brayanorozco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.