This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
generated from aslupin/boilerplate-typescript-fastify-clean-architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 17a779d
Showing
45 changed files
with
10,243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist | ||
test | ||
.vscode | ||
.github | ||
/node_modules | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Unit test - Node (v12.x v14.x) | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
test: | ||
name: Unit test with jest on node v${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [12.x, 14.x] | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: npm install | ||
run: npm install | ||
- name: npm test with jest | ||
run: npm run test:github-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Postman - APIs Test with newman-cli | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
|
||
jobs: | ||
test: | ||
name: APIs Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Building APIs | ||
run: pwd && ls -al && docker-compose up -d | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '12' | ||
- name: Install newman | ||
run: npm install -g newman | ||
- name: Waiting APIs launched | ||
run: make pm-github-action | ||
- name: Run newman | ||
run: make postman-test-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# OS | ||
.DS_Store | ||
|
||
# Tests | ||
/coverage | ||
/.nyc_output | ||
|
||
# IDEs and editors | ||
.vscode | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
|
||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
|
||
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most | ||
# .tfvars files are managed as part of configuration and so should be included in | ||
# version control. | ||
# | ||
# example.tfvars | ||
|
||
# Ignore override files as they are usually used to override resources locally and so | ||
# are not checked in | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Include override files you do wish to add to version control using negated pattern | ||
# | ||
# !example_override.tf | ||
|
||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
# example: *tfplan* | ||
|
||
# Ignore CLI configuration files | ||
.terraformrc | ||
terraform.rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"semi": false, | ||
"printWidth": 120 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SERVICE_NAME := boilerplate-typescript-fastify-clean-architecture | ||
.DEFAULT_GOAL := setup | ||
MONGO_AUTH_NAME := admin | ||
POSTMAN_COLLECTION_PATH := test/_postman/collection/${SERVICE_NAME}_test.postman.collection.json | ||
POSTMAN_ENVIRONMENT_PATH := test/_postman/environment/${SERVICE_NAME}_oopback.postman.environment.json | ||
|
||
mgo-shutdown: shutdown-mongo-on-local | ||
pm-github-action: postman-test-api-on-gh-action | ||
|
||
shutdown-mongo-on-local: | ||
mongo --eval "db.getSiblingDB('${MONGO_AUTH_NAME}').shutdownServer()" | ||
|
||
start-init: | ||
docker-compose up --build --force-recreate --renew-anon-volumes | ||
|
||
compilation-and-run: | ||
npm run build | ||
npm run start | ||
|
||
start: | ||
docker-compose up --build | ||
|
||
stop: | ||
@ echo "> Stop development environment" | ||
@ docker-compose down | ||
@ echo "> ----- Complete -----" | ||
|
||
postman-test-api: | ||
newman run ${POSTMAN_COLLECTION_PATH} -e ${POSTMAN_ENVIRONMENT_PATH} --verbose | ||
|
||
postman-test-api-on-gh-action: | ||
sh postman.api_test.gh_action.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# boilerplate-typescript-fastify-clean-architecture | ||
The repository is template for starting project with "boilerplate-typescript-fastify-clean-architecture" by develop CRUD for TODO APIs. | ||
|
||
note: | ||
- Explain about defination of clean architecture will come soon. | ||
- Now, testing coverage is not 100%. | ||
|
||
### Installation - Todo APIs | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
### Usage | ||
|
||
```bash | ||
docker-compose up | ||
# or | ||
npm run dev | ||
# or | ||
npm run build | ||
npm run start | ||
``` | ||
|
||
### Testing | ||
|
||
#### Unit test | ||
|
||
```bash | ||
npm run test | ||
``` | ||
|
||
#### APIs test | ||
|
||
```bash | ||
npm run test:postman | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// babel.config.js | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
imports: | ||
- { resource: 'development.yml', property: 'development' } | ||
- { resource: 'production.yml', property: 'production' } | ||
- { resource: 'staging.yml', property: 'staging' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
app: | ||
kind: development | ||
port: 8080 | ||
|
||
db: | ||
mongo: | ||
username: root | ||
password: root | ||
host: localhost | ||
port: 27017 | ||
name: todo_template | ||
auth: admin | ||
collection: todo | ||
|
||
queue: | ||
connection: | ||
username: guest | ||
password: guest | ||
host: 127.0.0.1 | ||
port: 5672 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
app: | ||
kind: production | ||
port: 8080 | ||
|
||
db: | ||
mongo: | ||
username: root | ||
password: root | ||
host: mongo | ||
port: 27017 | ||
name: todo_template | ||
auth: admin | ||
collection: todo | ||
|
||
queue: | ||
connection: | ||
username: guest | ||
password: guest | ||
host: rabbitmq | ||
port: 5672 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
app: | ||
kind: development | ||
port: 8080 | ||
|
||
db: | ||
mongo: | ||
username: root | ||
password: root | ||
host: 127.0.0.1 | ||
port: 27017 | ||
name: todo_template | ||
auth: admin | ||
collection: todo | ||
|
||
queue: | ||
connection: | ||
username: guest | ||
password: guest | ||
host: 127.0.0.1 | ||
port: 5672 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
version: "3.1" | ||
services: | ||
boilerplate-typescript-fastify-clean-architecture: | ||
container_name: boilerplate-typescript-fastify-clean-architecture | ||
image: boilerplate-typescript-fastify-clean-architecture:v1 | ||
build: | ||
context: ./ | ||
dockerfile: ./docker/prod.Dockerfile | ||
restart: always | ||
ports: | ||
- 8080:8080 | ||
depends_on: | ||
- mongo | ||
# - rabbitmq | ||
# command: sh -c "dockerize -wait tcp://mongo:27017 -wait tcp://rabbitmq:5672 -timeout 300s -wait-retry-interval 30s npm start" | ||
command: sh -c "dockerize -wait tcp://mongo:27017 -timeout 300s -wait-retry-interval 30s npm run start:production" | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "50m" | ||
max-file: "10" | ||
labels: | ||
kompose.service.type: LoadBalancer | ||
|
||
# rabbitmq: | ||
# container_name: rabbitmq | ||
# image: rabbitmq:management | ||
# ports: | ||
# - "15672:15672" | ||
# - "5672:5672" | ||
# logging: | ||
# driver: "json-file" | ||
# options: | ||
# max-size: "50m" | ||
# max-file: "10" | ||
|
||
mongo: | ||
container_name: mongo | ||
image: mongo:4.0 | ||
ports: | ||
- 27017:27017 | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=root | ||
- MONGO_INITDB_ROOT_PASSWORD=root | ||
- MONGO_INITDB_DATABASE=database | ||
logging: | ||
driver: "json-file" | ||
options: | ||
max-size: "50m" | ||
max-file: "10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM node:14.2 | ||
WORKDIR /home/api | ||
COPY ./package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
COPY . . | ||
RUN ls -la | ||
EXPOSE 8080 | ||
|
||
# Add dockerize | ||
RUN apt-get update && apt-get install -y wget | ||
|
||
ENV DOCKERIZE_VERSION v0.6.1 | ||
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ | ||
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | ||
|
||
CMD ["npm", "run" ,"start:production"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:14.3 | ||
|
||
WORKDIR /home/api | ||
|
||
COPY ./package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
RUN npm run build | ||
COPY . . | ||
EXPOSE 8080 | ||
|
||
CMD ["npm", "run", "start:staging"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
testEnvironment: 'node' | ||
}; |
Oops, something went wrong.