Giter Site home page Giter Site logo

thedegeneratedev5150 / nodejs-modularity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ievolved/nodejs-modularity

0.0 0.0 0.0 47 KB

Example refactoring cumbersome vanilla NodeJS to something more modular and eloquent.

JavaScript 85.52% CSS 0.27% HTML 14.21%

nodejs-modularity's Introduction

NodeJS-Modularity


Example refactoring cumbersome vanilla NodeJS to something more modular and eloquent. The idea is to use a NodeJS application as it might be written by someone just learning about NodeJS and demonstrate how to gradually refactor the code to be both reusable and modular.

Start with modularity-1 and read the comments. Then modularity-2 and read the comments, then modularity-3 and read the comments. Along the way make note about how the code improves.

Learning objectives

  • maintain ES6 syntax compliance
  • identify code that is duplicated many times and then change it so it is used only once
  • introduction to routing by reducing multiple if-elseif-else statements into a basic routing mechanism
  • structuring request methods by GET/POST/Etc. and dropping into a 405 if method not used
  • structuring request urls by url name and dropping into a 404 if a url not found
  • breaking reusable functions into another file for reusability (part of the modularity) objective
  • sending a response with content-type, status codes

At module 4:

  • create custom async function (when breaking an async call into a reusable function that must return a result)

nodejs-modularity's People

Contributors

shawnthehumble 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.