A simple api skeleton using fastify with TypeScript Support, for Node.js.
- Docker Support: Docker is guaranteed to be identical on any system
- Highly performant: Fastify is one of the fastest web frameworks
- Logging: Fastify has a integration with best logger to almost remove this cost, Pino!
- TypeScript ready: We work with type declaration, object oriented with classes, interfaces and statically typed like C# or Java
- Coding Standards: Help you to maintaince a clean code and to find and fix problems in your code
- git
- docker
- docker-compose
We must pass our commands to the Docker container. This is a really long command:
docker-compose -f docker-compose.cli.yml run --rm yarn install
For this reason, it is recommended to create an alias for docker-compose -f docker-compose.cli.yml run --rm
and call it dcli
(Docker CLI).
add a new line into your shell
alias dcli='docker-compose -f docker-compose.cli.yml run --rm'
Ps.: Oh My Zsh is a powerfull shell framework which features major extensions such as plug-ins and themes for
zsh
(recomended)
It goes to help you to improve your commits and reviews (PR/MR) like coding standards, unit tests and more.
Install nodejs >= 10:
curl -sL install-node.now.sh/lts | bash
Install husky:
npx husky install
Clone this repository:
Inside the project execute the following instructions:
cp .env.dist .env && cp docker-compose.override.yml.dist docker-compose.override.yml
docker-compose pull
Install composer dependencies:
dcli yarn install
Launch the containers with:
docker-compose exec -d
Finally, you can test it with:
curl http://127.0.0.1:4444
The first step is to make a gitlab token with following permissions:
- Go to Gitlab personal access tokens
- Create a new token.
- Assign the permissions.
- Click on
Create personal access token
.
Second step is to save gitlab token into .bashrc
or .env
(see the Quick Start section):
nano ~/.bashrc
add it in the end:
export GITLAB_TOKEN=YOUR_TOKEN
finally reload bashrc
source ~/.bashrc
If you have installed the zsh, save your token into
.zshrc
.
yarn tests:
dcli yarn run test
Lint files:
dcli yarn run fix
List commands:
dcli yarn run dev:cli
Command help:
dcli yarn run dev:cli example -h
To register a command, change src/config/commands.config.ts
:
import NewExampleCommand from '../commands/new-example.command';
Container.import([
// ...
NewExampleCommand,
]);
See the to more examples https://github.com/tj/commander.js
Fastify-decorator has support to Dependency injection (DI), click here to see more exampĺes