Giter Site home page Giter Site logo

angular-spa-browserify-example-webapi's Introduction

spa-api-server-example

Dependency Status No Maintenance Intended

Synopsis

Demonstrates REST API endpoints for the angular-spa-browserify-example client.

This API server is built on top of the express-api-server module, which provides built-in web security, error handling, and logging.

It is part of a set of separate Node.js microservices (Static Web Server, Chat Server, Reverse Proxy) to demonstrate a Single Page Web Application stack end-to-end, and is designed with portability and scalability in mind (see Twelve Factors).

Configuration options are passed in by the consumer or via environment variables at runtime.

Features

  • /auth: OAuth endpoints for login and JWT token refresh.
  • /logs: Client to server logging.
  • /todos: Example todo lists resource.

Installation

  1. Install Node.js
  2. Install Gulp: npm -g i gulp
  3. Clone this repo
  4. Install dependencies: npm i
  5. Start the app in dev mode: npm run dev
  6. Point browser to http://localhost:3000/

After installation, the following actions are available:

  • npm run dev : Builds for development, runs a local webserver, and watches for changes.
  • npm test : Runs TypeScript file linting and unit tests once.
  • karma start : Runs unit tests continuously, watching for changes.
  • npm run build : Creates production client assets under the dist/ folder, for deployment with a static webserver or CDN.

And run your server.js with optional runtime environment variables:

$ NODE_ENV=production API_SSL=1 API_PORT=443 node src/api-server.js

See src/config.js for configuration options to override.

Default Environment Variables

  • API_BASE_URL : Base url path for all endpoints (default: "/api").
  • API_USE_CLUSTER : Use a node cluster module (throng) to create processes per CPU core.
  • API_HEAPDUMP : Enable heapdump support (trigger dumps via kill -USR2 {pid}).
  • API_RDB_CONN : RethinkDB connection string.
  • API_JWT_SECRET : JSON Web Token Hash Secret. NOTE: You'll want to ensure this is unique per environment.
  • API_REV_PROXY : The server is behind a reverse proxy when set to "1".
  • API_PORT : The port to run on (default: 8000).
  • API_SSL : Use a HTTPS server when set to "1". Enforces HTTPS by redirecting HTTP users when used with a reverse HTTP/HTTPS proxy.
  • API_SSL_KEY : Path to the SSL key file.
  • API_SSL_CERT : Path to the SSL cert file.

Libraries & Tools

The functionality has been implemented by integrating the following 3rd-party tools and libraries:

  • Express: Fast, minimalist web framework for node
  • Helmet: Secure Express apps with various HTTP headers
  • Gulp: Streaming build system and task runner
  • Node.js: JavaScript runtime environment for server-side development
  • Mocha: The fun, simple, flexible JavaScript test framework
  • Chai: BDD/TDD assertion library for node and the browser
  • Sinon: Standalone test spies, stubs and mocks for JavaScript
  • Mockery: Mock Node.js module dependencies during testing

License

MIT License Copyright © 2015 Christopher Martin

angular-spa-browserify-example-webapi's People

Contributors

cgmartin avatar

Stargazers

 avatar

Watchers

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