|
1 | | -# Node.js Starter Overview |
| 1 | +# Simple Autocomplete Service |
2 | 2 |
|
3 | | -The Node.js Starter demonstrates a simple, reusable Node.js web application based on the Express framework. |
| 3 | +A Node.js app that uses an attached Redis database to provide an autocomplete API for data uploaded as text files. Multiple separate autocomplete indexes are supported. |
4 | 4 |
|
5 | | -## Run the app locally |
| 5 | +The autocomplete API is CORS-enabled, so that it can be accessed from any web page and conforms to the jQuery autocomplete standard. |
6 | 6 |
|
7 | | -1. [Install Node.js][] |
8 | | -2. Download and extract the starter code from the Bluemix UI |
9 | | -3. cd into the app directory |
10 | | -4. Run `npm install` to install the app's dependencies |
11 | | -5. Run `npm start` to start the app |
12 | | -6. Access the running app in a browser at http://localhost:6001 |
| 7 | +## API |
| 8 | + |
| 9 | +### GET /api |
| 10 | + |
| 11 | +Returns a JSON array of autocomplete indexes that are available |
| 12 | + |
| 13 | +e.g. |
| 14 | + |
| 15 | +```js |
| 16 | +[] |
| 17 | +``` |
| 18 | + |
| 19 | +or |
| 20 | + |
| 21 | +``` |
| 22 | +["animals","trees","actors"] |
| 23 | +``` |
| 24 | + |
| 25 | +### GET /api/:name?term= |
| 26 | + |
| 27 | +Parameters |
| 28 | + |
| 29 | +* term - the search term to autocomplete |
| 30 | + |
| 31 | +Returns a JSON array of possible autocompletions |
| 32 | + |
| 33 | +e.g. |
| 34 | + |
| 35 | +``` |
| 36 | +["Pedro","Pejman Montazeri","Pepe Reina","Pepe","Per Mertesacker","Peter Odemwingie"] |
| 37 | +``` |
| 38 | + |
| 39 | +### POST /api/:name (multi-part file upload) |
| 40 | + |
| 41 | +Parameters |
| 42 | + |
| 43 | +* file - the text file containing a list of items to be added to the auto-complete index |
| 44 | + |
| 45 | + |
| 46 | +### DELETE /api/:name |
| 47 | + |
| 48 | +Delete the named autocomplete index. |
| 49 | + |
| 50 | +## Lockdown mode |
| 51 | + |
| 52 | +If you have uploaded your content into the Simple Autocomplete Service but now want only the `GET /api/:name` endpoint to continue working, then you can enable "Lockdown mode". |
| 53 | + |
| 54 | +Simply set an environment variable called `LOCKDOWN` to `true` before running the Simple Autocomplete Service: |
| 55 | + |
| 56 | +```sh |
| 57 | +export LOCKDOWN=true |
| 58 | +node app.js |
| 59 | +``` |
| 60 | + |
| 61 | +or set a custom environment variable in Bluemix. |
| 62 | + |
| 63 | +This prevents your data being modified until lockdown mode is switched off again, by removing the environment variable. |
13 | 64 |
|
14 | | -[Install Node.js]: https://nodejs.org/en/download/ |
|
0 commit comments