Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 94abf68
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:44:20 2022 -0500

    Update WebAuthn

commit 902f3be
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:35:11 2022 -0500

    Update Version GitHub Actions

commit d981a5e
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:27:01 2022 -0500

    Update  Unit Test

commit b72e5fe
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:16:57 2022 -0500

    Update .env

commit f0250f4
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:08:10 2022 -0500

    Update build.yml

commit 531cd04
Author: SkyZeroZx <[email protected]>
Date:   Sat Oct 8 18:02:21 2022 -0500

    Add Unit Test

commit 68f233a
Author: SkyZeroZx <[email protected]>
Date:   Mon Oct 3 00:40:55 2022 -0500

    Update Docker Compose TZ Env

commit 855d146
Author: SkyZeroZx <[email protected]>
Date:   Mon Oct 3 00:20:15 2022 -0500

    Update Schedule Service

commit 4ad5aca
Author: SkyZeroZx <[email protected]>
Date:   Thu Sep 29 20:17:56 2022 -0500

    Update DockerCompose Add AWS Bucket

commit fd8095b
Author: SkyZeroZx <[email protected]>
Date:   Thu Sep 29 20:15:28 2022 -0500

    Add AWS S3 Service

commit 2ac6213
Author: SkyZeroZx <[email protected]>
Date:   Fri Sep 23 23:57:20 2022 -0500

    Test with Fastify

commit c467367
Author: SkyZeroZx <[email protected]>
Date:   Fri Sep 23 22:30:20 2022 -0500

    Fixed Cache Module in User Module

commit 7a2e1fd
Author: SkyZeroZx <[email protected]>
Date:   Fri Sep 23 22:23:47 2022 -0500

    Update Cache Rules

commit d1069a9
Author: SkyZeroZx <[email protected]>
Date:   Thu Sep 22 22:02:34 2022 -0500

    Add Cache Module & Licence Module

commit 7d37164
Author: SkyZeroZx <[email protected]>
Date:   Thu Sep 22 00:06:59 2022 -0500

    Update Services

commit 6ecf562
Author: SkyZeroZx <[email protected]>
Date:   Sat Sep 17 00:02:25 2022 -0500

    Update package.json
  • Loading branch information
SkyZeroZx committed Oct 8, 2022
1 parent a8d1172 commit 1a194e4
Show file tree
Hide file tree
Showing 130 changed files with 16,362 additions and 11,375 deletions.
56 changes: 56 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# JWT TOKEN SECRET KEY
JWT_TOKEN=EXAMPLE_TOKEN_KEY

# DATABASE PROPERTIES
DATABASE_HOST=localhost
DATABASE_USERNAME=root
DATABASE_PASSWORD=root
DATABASE_NAME=sky-krono
DATABASE_PORT=3306

# DEFAULT USER ADMIN
[email protected]
DEFAULT_USER_PASSWORD=Admin1

# EMAIL PROPERTIES
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=465
[email protected]
EMAIL_PASSWORD=Admin1

# WEB PUSH PROPERTIES
PUBLIC_KEY=YOUR_PUBLIC_KEY
PRIVATE_KEY=YOUR_PRIVATE_KEY
EMAIL_WEB_PUSH=mailto:[email protected]

# WEB AUTHENTICATION PROPERTIES
RP_ID=YOUR_RP_ID #EXAMPLE skyzerozx.com or localhost
RP_ID_ARRAY=["localhost","skyzerozx.com"]
ORIGIN=["http:https://localhost:4200", "https://skyzerozx.com"]


# TIME ZONE PROPERTIES SEE DOCUMENTATION https://date-fns.org/v2.29.2/docs/Time-Zones
TZ=America/Bogota

# CACHE NESTJS PROPERTIERS
CACHE_MAX_ITEMS=100
CACHE_TTL=2

# CACHE MYSQL DATABASE PROPERTIES
ENABLED_MYSQL_CACHE=true

# AWS S3 PROPERTIES
AWS_REGION=YOUR_REGION_AWS
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID_AWS
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY_AWS
AWS_BUCKET=YOUR_BUCKET_NAME


#LOGGER PROPERTIES
APP_NAME=SKY-KRONO
LOG_FOLDER=LOG
DATE_PATTERN=YYYY-MM-DD
TIMESTAMP_FORMAT=YYYY-MM-DD hh:mm:ss.SSS A
MAX_SIZE=20m
MAX_DAYS=14d

45 changes: 12 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Run Install Dependences
run: npm i
- uses: actions/cache@v2
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
Expand All @@ -28,62 +29,40 @@ jobs:
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/cache@v2
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Run All Unit Tests
run: npm run test:cov
- uses: actions/cache@v2
- uses: actions/cache@v3
id: build-unit-test
with:
path: ./*
key: ${{ github.sha }}
- uses: actions/upload-artifact@v3
with:
name: reports-unit-test
path: coverage/*
e2e-testing:
name: E2E Testing SuperTest
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 16
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name : E2E Test
run: npm run test:e2e:cov
- uses: actions/upload-artifact@v3
with:
name: reports-e2e-test
path: coverage-e2e/*
path: coverage/*
sonarcloud:
name: SonarCloud
needs: [build , unit-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/cache@v2
- uses: actions/cache@v3
id: build-unit-test
with:
path: ./*
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/coverage-e2e
credentials.txt
querys.sql
dev_querys.sql

#ENV
.env
Expand Down
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"material-icon-theme.folders.associations": {},
"material-icon-theme.files.associations": {},
"material-icon-theme.activeIconPack": "nest"
}
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<p align="center">
<a href="http:https://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
</p>

<h1 align="center">Sky Krono API NestJS</h1>
<p align="center">Es el API REST para la WebAPP/PWA SkyKrono integrado con Web Authentication para el inicio de sesion passworless</p>
<p align="center">
Expand All @@ -14,14 +13,16 @@

- [Pre-Requisitos](#pre-requisitos-)
- [Instalación](#instalación-)
- [Scripts SQL](#Scripts-SQL)
- [Environment](#Environment)
- [Desarrollo](#desarrollo-%EF%B8%8F)
- [Unit-Test](#unit-test)
- [E2E-Test](#E2E-test)
- [Build](#build)
- [Despligue](#despliegue-)
- [Analisis de Codigo](#analisis-de-codigo-)
- [Integración Continua](#integración-continua)
- [Logger](#logger)
- [Documentación](#documentacion)
- [Construido](#construido-con-)

## Comenzando 🚀
Expand All @@ -36,7 +37,7 @@ _Software requerido_
NodeJS >= 14.X
NPM >= 8.X
NestJS >= 9.X
MySQL >=7.X
MySQL >=8.X
```

_Software opcional_
Expand All @@ -63,6 +64,20 @@ _Previamente a ejecutar el servidor en desarrollo configurar el archivo .env con

_Dirigirse a la ruta http:https://localhost:3000/ donde tendra el API REST levantada_

### Scripts SQL

_Se tiene el archivo ```script.sql``` en la raiz del proyecto , el cual contiene los scripts de creacion de Store Procedure y Events/Jobs en MySQL_

_Se requiere ejecutar para el correcto funcionamiento de las tareas programadas como registro de licencias , dias libres de los trabajadores_

![Scripts SQL](/docs/sql/sql.png)

### Environment

_Se tiene el archivo ```env.template``` , el cual posee un ejemplo de cada valor de las valores de entorno para poder desplegarlas en nuestro propio ambiente local o cloud_

![Env](/docs/env/env.png)

## Desarrollo ⚙️

_Las siguientes instrucciones serviran para ejecutar en su entorno local la pruebas unitarias realizadas para el proyecto_
Expand All @@ -79,22 +94,6 @@ _La carpeta con la cobertura del codigo se creara en la raiz del proyecto con la

![Unit Test Coverage](/docs/unit-test/unit-test-coverage.png)

### E2E Test

_Los test fueron desarrollados en Jest con ayuda de SuperTest realizados a la API , para validar el funcionamiento adecuado en un entorno más real_

_Para ejecutar todos los E2E Test y reporte de cobertura de codigo ejecutar el comando_

```
npm run test:e2e:cov
```

_La carpeta con la cobertura del codigo se creara en la raiz del proyecto con la siguiente ruta coverage-e2e/Icov-report/index.html el cual se puede visualizar_

![E2E Test Coverage 1](/docs/e2e/e2e-test-1.png)

![E2E Test Coverage 1](/docs/e2e/e2e-test-2.png)

### Build

_Para generar el build de producción del proyecto ejecutar el siguiente comando:_
Expand Down Expand Up @@ -162,6 +161,15 @@ _Se creo la carpeta `.github/workflows` con el archivo `build.yml` que contiene
![CI 1](/docs/ci/ci-1.png)


## Documentacion

_Se realizo la documentación del API Rest usando Swagger el cual puede encontrar en la ruta http:https://localhost:3000/docs/ en la configuración por default_


![Swagger 1](/docs/swagger/swagger-1.jpg)

![Swagger 2](/docs/swagger/swagger-2.jpg)

## Logger

_Se integro winston para reemplazar el logger de NestJS para realizar seguimiento y conservacion de los logs segun sea requerido_
Expand Down Expand Up @@ -194,6 +202,7 @@ _Las herramientas utilizadas son:_
- [Prettier](https://prettier.io/) - Formateador de Codigo
- [WebAuthn](https://webauthn.guide/) - Estándar web del proyecto FIDO2 de la Alianza FIDO
- [TabNine](https://www.tabnine.com/) - Autocompletador de Codigo
- [Swagger](https://swagger.io/) - Automatización de Documentación
- [Winston](https://github.com/winstonjs/winston) - Logger para NodeJS

## Versionado 📌
Expand Down
9 changes: 8 additions & 1 deletion docker-compose.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ services:
RP_ID : ${RP_ID} # WEB AUTH PROPERTIES
RP_ID_ARRAY : ${RP_ID_ARRAY}
ORIGIN : ${ORIGIN}
TIME_ZONE : ${TIME_ZONE} # TIME ZONE PROPERTIES
TZ : ${TZ} # TIME ZONE PROPERTIES
CACHE_MAX_ITEMS : ${CACHE_MAX_ITEMS} # CACHE PROPERTIES
CACHE_TTL : ${CACHE_TTL}
ENABLED_MYSQL_CACHE : ${ENABLED_MYSQL_CACHE}
AWS_REGION : ${AWS_REGION} # AWS S3 PROPERTIES
AWS_ACCESS_KEY_ID : ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY : ${AWS_SECRET_ACCESS_KEY}
AWS_BUCKET : ${AWS_BUCKET}
DATE_PATTERN : ${DATE_PATTERN} # LOGGER PROPERTIES
APP_NAME : ${APP_NAME}
MAX_SIZE : ${MAX_SIZE}
Expand Down
Binary file modified docs/docker/docker-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docker/docker-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/env/env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logger/logger-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/logger/logger-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/sonar/sonar-properties.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sql/sql.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/swagger/swagger-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/swagger/swagger-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/unit-test/unit-test-coverage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as superTest from 'supertest';
import { AppModule } from '../src/app.module';

describe('AppController (e2e)', () => {
let app: INestApplication;

Expand All @@ -15,9 +15,7 @@ describe('AppController (e2e)', () => {
await app.init();
});



it('/ (GET)', async() => {
return superTest(app.getHttpServer()).get('/').expect(200).expect('Sky Calendar API');
it('/ (GET)', async () => {
return superTest(app.getHttpServer()).get('/').expect(200).expect('Sky Calendar API');
});
});
Loading

0 comments on commit 1a194e4

Please sign in to comment.