Code Monkey home page Code Monkey logo

jetty-angular2-spa's Introduction

jetty-angular2-spa

Single Page App using Jetty for API server and Angular 2 for the front end framework

Prerequisites

Apache Maven: https://maven.apache.org/ npm: https://www.npmjs.com/

To run BE server

cd <project-root-directory>

mvn clean install

cd webapp-server

mvn exec:java

To run FE server

cd webapp-client

npm install (only needed for the first build to get all required packages)

npm start

Important Concepts

Let us try to separate the concerns of Backend and Frontend. The Frontend should handle all issues related to showing client information and Backend should handle issues with application level logic. The Frontend is written in Angular2 and handles generating all of the HTML and routing on the client side. The Backend is a simple rest server which does not worry about generating dynamic pages or serving static content. It handles application level logic like what to do with the data from the Frontend.

Frontend Server

We use Gulp to create a server to serve the Frontend files. There is only one root HTML file index.html in webapp-client (hence single page application). The rest of the "pages" are generated by Angular's routing capabilities.

The gulp server has a proxy set up so that all requests that start with /api get routed to the Backend server. So for example, the default Frontend server runs at http://localhost:9000 and the default Backend server runs at http://localhost:8080. So if we make a call to http://localhost:9000/api/health/ping, that call gets proxied to http://localhost:8080/api/health/ping.

Backend Server

We use embedded Jetty 9 to run the Backend server. The Backend code also tries to separate out concerns by splitting relevant work into the various submodules of this project. While the modules are very small, they serve as an example of how to set up a multi module project using Maven, and can definitely grow larger based on code needs.

jetty-angular2-spa's People

Contributors

shudas avatar

Stargazers

 avatar Denys Miller avatar Dainis avatar Octavian Savencu avatar  avatar

Watchers

 avatar Dainis avatar

jetty-angular2-spa's Issues

pom property is wrong

The projects pom.xml:
<properties> <guice.version>3.0</guice.version> <resteasy.version>3.0.16.FINAL</resteasy.version> </properties>

3.0.16.FINAL should be 3.0.16.Final, otherwise mvn clean install will fail.

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.