An API Boilerplate project built with Node.js and Typescript.
- ⏱ Runtime: Node.js
- 🖥 API Framework: Fastify
- 🔏 Type System: TypeScript
- 🧪 Test Runner: Jest
- 👕 Linter: ESLint
- 📦 Continuous Integration: Azure DevOps
- 🍴 Fork the repository
- 👯♀️ Clone it to your computer
- 🏃♀️ Run npm run install && npm run dev
- 📝 Edit any of the files in src/
- 👀 Watch as the app magically rebuilds and relaunches itself
The following npm scripts can be run using npm run <script>
. This project relies on opn
and rimraf
utilities in order to support cross-platform opening and deleting files.
build
- build the TypeScript files and output tolib/
build:watch
- automatically rebuild files if changes are detected insrc/
clean
- recursively delete thelib/
andcoverage/
directoriesclean:build
- recursively delete thelib/
directoryclean:coverage
- recursively delete thecoverage/
directorycoverage
- run the test suite and generate code coverage reportscoverage:open
- run npm run coverage then open the results in a browserdev
- concurrently runbuild:watch
andstart:watch
lint
- run the linter configured by TSLint on thesrc/
directorystart
- run the app fromlib/
. Make sure to use npm run build first!start:watch
- relaunch the server if new changes are detected inlib/
test
- run unit tests defined in thetests/
directorytest:ci
- run unit tests and generate necessary files for CI integration
Matterhorn implements example usage of both command line arguments and environment variables. It uses yargs-parser
to manage command line arguments. Command line arguments are passed in through the start command: node lib/index.js <command line arguments>
. The --log
argument has been enabled as an example. Running npm run start
starts up the project without any command line arguments. This command is intended to be used in production, so logging is disabled by default (i.e. we don't pass the --log
argument). If you are using this command to test your code locally and want to see the logging output, then run npm run start -- --log
. This passes the command line argument through npm and into the aliased command.
Environment variables work in a similar way to command line arguments. They can be set in multiple ways depending on the terminal and operating system you are using. In a bash terminal you can specify environment variables as you use any of the above mentioned scripts by prepending the assignment to the command. For example, this project has the PORT environment variable enabled. In a bash terminal run PORT=8080 npm run start
to run the API on port 8080.
Open an issue if you'd like to report a bug or a feature. Make sure to write a detailed description and indicate if you will or will not be resolving the issue yourself.
If you are interested in contributing make sure to follow these practices:
- Prepend branches with
fix/
,feature/
, ordocs/
depending on the change being made - NPM commands
test
,lint
, andbuild
run without failing. - If you are solving an open issue, reference it in the Pull Request description using
Ref #<issue number>
.
🦉 Ethan Arrowood Original Author - Follow on: Twitter @ArrowoodTech & GitHub @Ethan-Arrowood
🚀 Alyssa Cooper Maintainer - Follow on: Twitter @ayecoops & GitHub @Alyssa-Cooper