Giter Club home page Giter Club logo

first-express-controller-lab-abp-11-17's Introduction

Your First Express Controller Lab

Objectives

  1. Build an Express controller.
  2. Define 3 actions for the controller.
  3. Render the appropriate views in each action.
  4. Mount the controller in the app.
  5. Draw routes for the app to the controller actions.

Instructions

Your goals is to build an express application using the C (controllers) in the M-V-C paradigm of application development. Your site will respond to 3 URLs, each mapping to a discrete controller action defined as a function in the SiteController class.

  1. GET '/' should map to SiteController.Index and render site/index creating a Home Page.
  2. GET '/about' should map to SiteController.About and render site/about creating an About Page.
  3. GET '/contact' should map to SiteController.Contact and render 'site/contact creating a Contact Page.

We've given you the views for this application in views/site, so you don't need to worry about them.

Build the controller in controllers/SiteController.js by defining an object for SiteController and attaching functions to handle the express routes directly onto that object.

Remember, functions that are valid express handlers need to accept at least two arguments, generally called req and resp. These functions become the controller's actions. Each function should use the resp to render the apporpriate view.

Finally, make sure to export the controller so you can mount the controller in app.js using require. Then create the routing table in app.js using the express app constant and passing each URL to the appropriate controller action.

You can run the tests with learn. The tests specify the full flow for each URL sequentially.

You can run the server with npm start and preview it in your browser.

first-express-controller-lab-abp-11-17's People

Contributors

aviflombaum avatar adjoa avatar

Watchers

James Cloos avatar  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.