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.
Build a UI and backend for an auto complete using the backend you write as well as the frontend of your choosing.
Show more…
- Language:
- [Node, Node via TypeScript, PHP, Python or Java]
- Architecture:
- [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.- The API should accept at least a string to use as a search for the front-end.
- Instruction:
- [S]ufficient documentation such that […] developer with docker can [build and run app]
- [A
curl
] command to execute your api
- autocomplete component
- a document showing […] exact steps [to run on developer] machine
- Docker 19.X
- manipulate DNS (see Quick Start: DNS)
- Build image (also installs app dependencies).
docker build --tag wesb-school-autofill-image https://github.com/wesleyboar/wesleyb-sample-schoology.git
- 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
- Open relevant URL from final output on the command line.
The domain animal.farm
, and some subdomains, are required (and not yet configurable). They are assumed to be functional by:
- API call in client app
- CORS solution on server
- CLI instructional output
- 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
.
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.
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
- Use PEP 350 to prefix relevant comments.
Separate instructions exist for running these commands:
- Install dependencies for service.
npm build
will (re-)install all dependenciesnpm build:cached
will use available dependencies
- Build service.
- Repeat steps 1 and 2 for next service.
Run a web server.
npm serve
will run a prodcution web server for all servicesnpm serve:docs
will run an ad-hoc server for documentation
Compile documentation.
npm docs
will compile documentation for all servicesnpm docs:api
will compile documentation for server API onlynpm docs:client
will compile documentation for client app only
Run tests from all services.
Known Methods:
- 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
- Execute command on running docker container.
(more info)
docker exec wesb-school-autofill-container your command
- Enter bash shell on running docker container.
(more info)
docker exec --interactive --tty wesb-school-autofill-container bash
Requirements:
- Node.js
10.X
- Run commands from this (
./
) directory. - Run command
npm install
at least once beforehand.