Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

A code sample of a set of web services that provide an autofill service

Notifications You must be signed in to change notification settings

wesleyboar-fka-iosulfur/wesleyb-sample-docker-autofill

Repository files navigation

Docker-Based Back-End & Front-End Autofill Service

This is the Node web service of an old code sample by Wesley B. It is not maintained.

This project contains the client web app and the server web API. It is also bundled in a single docker.

Goal

Build a UI and backend for an auto complete using the backend you write as well as the frontend of your choosing.

Requirements

Show more…

Backend

  • Language:
    • [Node, Node via TypeScript, PHP, Python or Java]
  • Architecture:
    1. [API service has at least] one endpoint that can return data over http to a client.
      • This will all run on a single machine, so https is not required.
    2. The API should accept at least a string to use as a search for the front-end.
  • Instruction:
    1. [S]ufficient documentation such that […] developer with docker can [build and run app]
    2. [A curl] command to execute your api

Frontend

  • autocomplete component
  • a document showing […] exact steps [to run on developer] machine

Requirements

Quick Start

Services

  1. Build image (also installs app dependencies).
    docker build --tag wesb-school-autofill-image https://github.com/wesleyboar/wesleyb-sample-schoology.git
    
  2. Run container, then start all services.
    docker run --hostname animal.farm --publish 9000:9000 --name wesb-school-autofill-container wesb-school-autofill-image   npm run serve
    
  3. Open relevant URL from final output on the command line.

DNS

The domain animal.farm, and some subdomains, are required (and not yet configurable). They are assumed to be functional by:

  1. API call in client app
  2. CORS solution on server
  3. CLI instructional output
  4. URLs in documentation

To use these URLs, edit the DNS or /etc/hosts file on the local host, so that specific domains are directed to localhost i.e. 127.0.0.1.

Example (/etc/hosts)

127.0.0.1	animal.farm
127.0.0.1	www.animal.farm
127.0.0.1	api.animal.farm
127.0.0.1	docs.animal.farm

Warning: There is a real domain https://www.animal.farm. You will not have access to that website while these changes are in effect.

Directories

These directories are manually maintained.

./
    |_ api           // source files of the server web API
    |_ client        // source files of the client web app
    |_ data          // data for web server and web API

These directories are automatically maintained.

./
    |_ docs          // developer documentation for web services
    |_ node_modules  // node package installation
    |_ public        // user-facing static files for client web app

Development

Rules

  • Use PEP 350 to prefix relevant comments.

Commands

Separate instructions exist for running these commands:

npm start

  1. npm build
  2. npm serve

npm build(:cached)

  1. Install dependencies for service.
    • npm build will (re-)install all dependencies
    • npm build:cached will use available dependencies
  2. Build service.
  3. Repeat steps 1 and 2 for next service.

npm serve(:docs)

Run a web server.

  • npm serve will run a prodcution web server for all services
  • npm serve:docs will run an ad-hoc server for documentation

npm docs(:api|:client)

Compile documentation.

  • npm docs will compile documentation for all services
  • npm docs:api will compile documentation for server API only
  • npm docs:client will compile documentation for client app only

npm test

Run tests from all services.

on Docker

Known Methods:

  1. Run container image with initial command. (more info)
    docker run --hostname animal.farm --publish 9000:9000 --name wesb-school-autofill-container wesb-school-autofill-image   your command
    
  2. Execute command on running docker container. (more info)
    docker exec wesb-school-autofill-container   your command
    
  3. Enter bash shell on running docker container. (more info)
    docker exec --interactive --tty wesb-school-autofill-container   bash
    

on Local Host

Requirements:

  • Node.js 10.X
  • Run commands from this (./) directory.
  • Run command npm install at least once beforehand.