version |
---|
0.7.0-SNAPSHOT |
Template and Example using Webpack for rapid development of an REST API server with endpoints for managing requests and connections to other servers and/or database/storage tools.
This example can also be used to quickly create a server with your own endpoints to do whatever you would like on any requests (either user/interaction based, or with a cron job to make it on a scheduled basis)
Node v10+ and npm (tested with v10.15.1)
See package.json(github) for full list of current dependencies
- Hapi v18 -- Server Library
- Webpack + Loaders -- managing the build process
- Babel -- compiling newer ECMA2016+ into browser-capable javascript
- FlowJS -- adding types to javascript
- ESLint -- enforcing javascript code style
- Mocha, Chai, and Sinon -- unit testing
- EsDoc -- creating easy javascript documentation
- MariaDB -- Connecting to mysql/mariadb server for storage
- YamlJS -- Parsing YAML files
How to use this template to create a quick HTTP REST server:
- Download and update node + dependencies
- After installing node run
npm install -D
- After installing node run
- Update
conf/config.yaml
with any changes to settings - Add endpoint definitions to OpenAPI config in
./openapi.yaml
- Add Unit tests in
src/controllers/
(Test Driven Development) - Add Controller Files to
src/controllers/
- For now, add reference to controller in
src/entry.js
(with other controllers) - Controller endpoints will be served at
/api
(or whatever is set in config.yaml)
- For now, add reference to controller in
- Run
npm run doc
to update the documentation - Run
npm run start-watch
to compile and run server + tests in watch mode- Navigate to http://localhost:3333/docs/swagger/index.html to see swagger-ui with your new endpoint
npm run start-watch
to run open the server and run Webpack to watch for changes, recompiling, running the tests and restarting the server when it is done
npm run test-watch
to run Mocha and with all tests associated with the project, watch for changes on the files to re-run the tests
npm run dev-watch
to run only webpack to watch for changes on the files and recompile/rerun tests
npm run test
to run all of the unit tests for the application one time
npm run dev
to run a development version of the server
npm run build
to compile development version of server to dist/
npm run doc
to generate static documentation in the doc folder
npm run lint
to run linter and see any errors/warnings
npm run clean
clean the workspace (remove dist/
)
npm run help
to print the contents of help.txt
to the command line
TODO
npm run build-prod
... TODO: compile application to production version
npm start
.. TODO: start production Server
npm stop
.. TODO: stop production Server
npm restart
will restart once start/stop completed