-
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 9b9a1ef
Showing
24 changed files
with
904 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,19 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 2 | ||
tab_width = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{md,yml,yaml,json,graphql}] | ||
indent_style = space | ||
|
||
[*.{md,yml,yaml}] | ||
trim_trailing_whitespace = false | ||
|
||
[.registry-*] | ||
insert_final_newline = false |
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,63 @@ | ||
root: true | ||
env: | ||
es2022: true | ||
node: true | ||
parserOptions: | ||
ecmaVersion: 13 | ||
sourceType: module | ||
extends: | ||
- eslint:recommended | ||
# - plugin:sonarjs/recommended | ||
- plugin:unicorn/recommended | ||
rules: | ||
camelcase: off | ||
capitalized-comments: off | ||
indent: [error, tab] | ||
linebreak-style: [error, unix] | ||
no-console: off | ||
no-debugger: off | ||
# no-multi-assign: off | ||
# no-multiple-empty-lines: | ||
# - error | ||
# - | ||
# max: 2 | ||
# maxBOF: 2 | ||
# maxEOF: 0 | ||
# no-new-func: off | ||
no-undef-init: off | ||
no-unused-expressions: | ||
- error | ||
- | ||
allowShortCircuit: true | ||
allowTernary: true | ||
allowTaggedTemplates: true | ||
padding-line-between-statements: off | ||
quotes: [error, single] | ||
# require-atomic-updates: off | ||
semi: [error, never] | ||
semi-spacing: | ||
- error | ||
- | ||
before: false | ||
after: true | ||
spaced-comment: off | ||
# unicorn/consistent-destructuring: off | ||
unicorn/filename-case: off | ||
# unicorn/import-style: | ||
# - error | ||
# - | ||
# styles: | ||
# util: false | ||
# path: | ||
# named: true | ||
# unicorn/no-abusive-eslint-disable: off | ||
unicorn/no-array-reduce: off | ||
# unicorn/no-negated-condition: off | ||
# unicorn/no-null: off | ||
unicorn/no-useless-undefined: off | ||
unicorn/no-zero-fractions: off | ||
# unicorn/prefer-dom-node-dataset: off | ||
unicorn/prefer-includes: off | ||
# unicorn/prefer-object-from-entries: off | ||
unicorn/prefer-query-selector: off | ||
unicorn/prevent-abbreviations: off |
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,7 @@ | ||
# * text=auto | ||
* text eol=lf | ||
|
||
*.png binary | ||
*.jpg binary | ||
|
||
/.yarn/** linguist-vendored |
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,35 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [20.x] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install pnpm | ||
run: npm i -g pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Run test | ||
run: pnpm test | ||
|
||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
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,18 @@ | ||
.conf/local.sh | ||
.vite | ||
.registry-* | ||
|
||
# node | ||
node_modules | ||
|
||
# Logs | ||
logs | ||
*.log | ||
*.log* | ||
|
||
# Coverage | ||
coverage/** | ||
!coverage/lcov.info | ||
|
||
_init | ||
_cleanup |
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,28 @@ | ||
variables: | ||
KUBE_NAMESPACE: boilerplate | ||
HELM_RELEASE_NAME: gql-yoga | ||
|
||
include: | ||
- project: "inovacao/devops/template-cicd" | ||
file: "sonar-js.yaml" | ||
- project: "inovacao/devops/template-cicd" | ||
file: "test-nodejs.yaml" | ||
- project: "inovacao/devops/template-cicd" | ||
file: "build-nodejs.yaml" | ||
- project: "inovacao/devops/template-cicd" | ||
file: "deploy.yaml" | ||
|
||
test: | ||
extends: .test | ||
|
||
sonar: | ||
extends: .sonar_js | ||
|
||
build: | ||
extends: .build | ||
|
||
stages: | ||
- test | ||
- sonar | ||
- build | ||
- deploy |
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,9 @@ | ||
engine-strict=true | ||
resolution-mode=highest | ||
auto-install-peers=true | ||
|
||
# TEx pkgs | ||
//gitlab.textecnologia.io/api/v4/packages/npm/:_authToken=glpat-SzBHz58z8KCtXSqvKFAR | ||
//gitlab.textecnologia.io/api/v4/:_authToken=glpat-SzBHz58z8KCtXSqvKFAR | ||
@xet:registry=https://gitlab.textecnologia.io/api/v4/packages/npm/ | ||
@texsvelte:registry=https://gitlab.textecnologia.io/api/v4/packages/npm/ |
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,15 @@ | ||
*.css | ||
.* | ||
bin | ||
build | ||
coverage | ||
dist | ||
node_modules | ||
package | ||
# template.js | ||
vite.config.js.timestamp-* | ||
|
||
*.json | ||
*.yaml | ||
*.yml | ||
*.md |
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,16 @@ | ||
arrowParens: avoid | ||
bracketSameLine: false | ||
bracketSpacing: false | ||
# embeddedLanguageFormatting: auto | ||
insertPragma: false | ||
htmlWhitespaceSensitivity: css | ||
printWidth: 720 | ||
proseWrap: preserve | ||
quoteProps: as-needed | ||
requirePragma: false | ||
semi: false | ||
singleAttributePerLine: true | ||
singleQuote: true | ||
trailingComma: all | ||
tabWidth: 4 | ||
useTabs: true |
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,162 @@ | ||
# Boilerplate GraphQL Yoga | ||
|
||
[![Build Status][ci-img]][ci] | ||
[![Coverage Status][coveralls-img]][coveralls] | ||
|
||
[ci-img]: https://github.com/lagden/boilerplate-gql-yoga/actions/workflows/nodejs.yml/badge.svg | ||
[ci]: https://github.com/lagden/boilerplate-gql-yoga/actions/workflows/nodejs.yml | ||
[coveralls-img]: https://coveralls.io/repos/github/lagden/boilerplate-gql-yoga/badge.svg?branch=main | ||
[coveralls]: https://coveralls.io/github/lagden/boilerplate-gql-yoga?branch=main | ||
|
||
|
||
Boilerplate para desenvolvimento de uma aplicação. | ||
|
||
- [Instalação](#instalação) | ||
- [Como utilizar](#como-utilizar) | ||
- [watch](#watch) | ||
- [teste](#teste) | ||
- [Imagem](#imagem) | ||
- [Deploy](#deploy) | ||
- [Exemplo](#exemplo) | ||
- [Middlewares](#middlewares) | ||
- [License](#license) | ||
|
||
|
||
## Instalação | ||
|
||
Utilize `@tadashi/boilerplate-create` para iniciar o projeto. | ||
|
||
``` | ||
npm i -g @tadashi/boilerplate-create | ||
boilerplate-create | ||
``` | ||
|
||
ou | ||
|
||
``` | ||
npx --yes @tadashi/boilerplate-create | ||
``` | ||
|
||
E siga as instruções do prompt. | ||
|
||
|
||
## Como utilizar | ||
|
||
Após finalizado o `scaffolding` do projeto, instale os pacotes. | ||
|
||
```shell | ||
bin/node/pkg.js | ||
bin/node/zera -m npm | ||
``` | ||
|
||
Feito isso, o projeto está pronto para funcionar. | ||
|
||
Para rodar **local**, utilize: | ||
|
||
```shell | ||
bin/local/start | ||
``` | ||
|
||
E via **docker**, utilize: | ||
|
||
```shell | ||
bin/docker/start | ||
``` | ||
|
||
⚠️ **Ressalvas** | ||
|
||
No **docker**, caso seja instalado um novo pacote, é necessário fazer o `build` da imagem novamente. | ||
Pare o container (`bin/docker/stop` ou `control + c`) e rode novamente passando o parâmetro `-b`: | ||
|
||
```shell | ||
bin/docker/start -b | ||
``` | ||
|
||
|
||
### watch | ||
|
||
O **watch** reinicia a aplicação caso ocorra alguma alteração. | ||
Rodando via **docker** isso ocorre por padrão, mas **local** é necessário fazer algumas instalações e configurações. | ||
|
||
```shell | ||
bin/local/start -w | ||
``` | ||
|
||
|
||
### teste | ||
|
||
Para executar os testes. | ||
|
||
**local:** | ||
|
||
```shell | ||
bin/local/test | ||
``` | ||
|
||
**docker:** | ||
|
||
```shell | ||
bin/docker/test | ||
``` | ||
|
||
|
||
## Imagem | ||
|
||
Crie os arquivos de usuário e senha do **registry** que serão utilizados para fazer o `push` da imagem. | ||
|
||
```shell | ||
echo 'username' > .registry-user | ||
echo 'password' > .registry-passwd | ||
``` | ||
|
||
Verifique as suas variáveis de ambiente `.env-*`. | ||
E para fazer o `push` da imagem de sua aplicação, execute: | ||
|
||
```shell | ||
bin/docker/image -e production | ||
``` | ||
|
||
|
||
## Deploy | ||
|
||
Para executar o **deploy** é necessário alguns binários instalados: | ||
|
||
- **envsubst** by Bruno Haible | ||
- **rsync** by Andrew Tridgell, Wayne Davison and others | ||
|
||
O fluxo do sistema de **deploy** é simples: | ||
|
||
1. Carrega as variáveis de ambiente (`staging` ou `production`) | ||
2. Executa o script `bin/docker/image` (se passado o parâmetro `-i` esse processo é ignorado) | ||
3. Cria o arquivo `docker-compose-{VERSION}.yml` utilizando o **envsubst** | ||
4. Envia os arquivos para o servidor via **rsync** | ||
5. Executa o `docker stack deploy` no servidor | ||
|
||
```shell | ||
bin/docker/deploy -e production | ||
``` | ||
|
||
|
||
## Exemplo | ||
|
||
Chamada de exemplo da API via **curl**. | ||
|
||
```shell | ||
curl 'http://127.0.0.1:5001/gql' \ | ||
-H 'content-type: application/json' \ | ||
-d '{ | ||
"source": "query Hello($name: String!) { hello(name: $name) }", | ||
"variableValues": {"name": "Sabrina"}, | ||
"operationName": "Hello" | ||
}' | ||
``` | ||
|
||
|
||
## Donate ❤️ | ||
|
||
- BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4 | ||
|
||
|
||
## License | ||
|
||
MIT © [Thiago Lagden](https://github.com/lagden) |
Oops, something went wrong.