Commit 27607b93 authored by Diego F. Ticona Ramos's avatar Diego F. Ticona Ramos
Browse files

commit inicial backend cliente-qa-ppe

parents
/node_modules/
/dist/
*.env
/src/config/app.config.ts
\ No newline at end of file
# Instalación
Proceso de instalación y configuración para entornos de desarrollo.
## Clonar el proyecto
```bash
git clone git@gitlab.com:educonnect1/app-aleman.git
cd app-aleman
git checkout develop
```
## Configuración de la aplicación web (webclient)
```bash
cd webclient
yarn install
```
Crea los archivos de configuración:
| Archivo de configuración | Archivo de ejemplo |
| ------------------------------------ | ------------------------------------------- |
| `webclient/src/config/app.config.ts` | `webclient/src/config/app.config.ts.sample` |
| `webclient/.env` | `webclient/.env.example` |
Ingresar a cada uno de los ficheros y actualizar los valores según sea necesario.
### Despliegue en desarrollo
```bash
yarn start
```
### Despliegue en producción
Ver el archivo [DEPLOY.md](./DEPLOY.md).
## Configuración del servicio (backend)
```bash
cd backend
npm install
```
Crea los archivos de configuración:
| Archivo de configuración | Archivo de ejemplo |
| ------------------------------------------- | -------------------------------------------------- |
| `backend/src/config/app.config.ts` | `backend/src/config/app.config.ts.sample` |
| `backend/src/config/serviceAccountKey.json` | `backend/src/config/serviceAccountKey.json.sample` |
| `backend/ormconfig.env` | `backend/ormconfig.env.sample` |
Ingresar a cada uno de los ficheros y actualizar los valores según sea necesario.
**Nota.-**
- Algunos parámetros de configuración se obtienen desde la Consola de Google y Firebase,
dentro de cada archivo de configuración se indica la forma de obtenerlos.
- Luego de tener listo todos los archivos de configuración ejecutar los siguientes comandos para completar la instalación.
```bash
# Crea la base de datos
npm run setup
```
Configuración inicial de firebase:
```bash
# Elimina todos los usuarios de firebase
npm run delete-firebase-users
# Crea los usuarios para firebase
npm run create-firebase-users
```
### Despliegue en desarrollo
```bash
npm run dev
```
### Despliegue en producción
Ver el archivo [DEPLOY.md](./DEPLOY.md).
# app-aleman
Configurando base de datos:
=====
1. Crear una base de datos vacía
2. Duplicar el archivo `ormconfig.env.sample` y guardarlo con el nombre `ormconfig.env`
3. Colocar el nombre de la base de datos creado en el punto 1 y cambiar los datos de conexión
Iniciar el backend
=====
Ejecutar en modo desarrollo:
```script
npm run dev
```
\ No newline at end of file
import { MigrationInterface, QueryRunner } from "typeorm";
import { UsuarioSQLModel } from "../../src/core/usuario/UsuarioSQLModel";
export class Usuarios1628577399820 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const items = [
{
id: "7f05529f-62e4-443c-805f-5732cc47ebf2",
email: "dticona@agetic.gob.bo",
rol: "ADMINISTRADOR",
estado: "ACTIVO",
nombres: "Administrador",
primerApellido: "AAGCS",
segundoApellido: "Agetic",
nombreCorto: "admin",
direccion: "Calle Pedro Salazar, Edif. FNDR. Piso 3",
celular: "12345678",
ci: "123456",
ciudad: "La Paz",
},
];
const usuarios = items.map((item) => {
const u = new UsuarioSQLModel();
u.id = item.id;
u.email = item.email;
u.rol = item.rol;
u.estado = item.estado;
u.nombres = item.nombres;
u.primerApellido = item.primerApellido;
u.segundoApellido = item.segundoApellido;
u.nombreCorto = item.nombreCorto;
u.direccion = item.direccion;
u.celular = item.celular;
u.ci = item.ci;
u.ciudad = item.ciudad;
return u;
});
await queryRunner.manager.save(usuarios);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["node_modules", "dist"],
};
TYPEORM_CONNECTION = mysql
RDS_HOSTNAME = localhost
RDS_USERNAME = root
RDS_PASSWORD = r00t
RDS_DB_NAME = colegioaleman_db
RDS_PORT = 3306
{
"name": "plataforma_educativa_backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"deploy": "eb deploy",
"start": "node dist/src/server.js",
"test": "jest",
"build": "tsc",
"dev": "mkdir -p dist && cp ormconfig.env dist/ && tsc-watch --target es2017 --outDir ./dist/src --onSuccess \"node dist/src/server.js\"",
"eslint": "./node_modules/.bin/eslint src",
"format": "prettier --write \"src/**/*.{ts,tsx,scss,css,json}\"",
"typeorm": "ts-node --files -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config src/core/base/ormconfig.ts",
"setup": "tsc && cp ormconfig.env dist/ && npm run schema:drop && SETUP=true node dist/src/server.js && npm run migrate",
"migrate": "npm run typeorm -- migration:run -c seed",
"schema:drop": "npm run typeorm -- schema:drop",
"tester": "npm run test -- --detectOpenHandles --forceExit"
},
"author": "",
"license": "ISC",
"dependencies": {
"@google-cloud/storage": "^5.14.0",
"@types/express-list-endpoints": "^4.0.1",
"@types/html-to-text": "^8.0.1",
"@types/jest": "^26.0.0",
"@types/mime-types": "^2.1.1",
"@types/moment": "^2.13.0",
"@types/shallowequal": "^1.1.1",
"@types/uuid": "^8.0.0",
"@types/winston": "^2.4.4",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dayjs": "^1.10.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-list-endpoints": "^6.0.0",
"express-useragent": "^1.0.15",
"html-to-text": "^8.0.0",
"mime-types": "^2.1.32",
"mkdirp": "^1.0.4",
"moment": "^2.29.1",
"morgan": "^1.10.0",
"multer": "^1.4.2",
"mysql": "^2.18.1",
"reflect-metadata": "^0.1.13",
"shallowequal": "^1.1.0",
"tsc-watch": "^4.2.9",
"typeorm": "^0.2.31",
"typescript": "^4.1.3",
"uuid": "^8.1.0",
"winston": "^3.3.3"
},
"devDependencies": {
"@types/body-parser": "^1.19.0",
"@types/cors": "^2.8.10",
"@types/express": "^4.17.11",
"@types/express-useragent": "^1.0.1",
"@types/mkdirp": "^1.0.2",
"@types/morgan": "^1.9.3",
"@types/multer": "^1.4.5",
"@types/node": "^14.14.31",
"@typescript-eslint/eslint-plugin": "^4.14.0",
"@typescript-eslint/parser": "^4.14.0",
"aws-sdk": "^2.935.0",
"concurrently": "^5.2.0",
"eslint": "^7.2.0",
"jest": "^26.6.3",
"nodemon": "^2.0.4",
"prettier": "^2.0.5",
"ts-jest": "^26.1.0",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.10.1",
"typescript": "^3.9.7"
}
}
This diff is collapsed.
import { FacturaView } from "./FacturaView";
import { AbstractController } from "../../view/base/AbstractController";
import { Request, Response } from "express";
import { FacturaState } from "../../core/factura/FacturaEntity";
// import MonitorService from "../../core/monitor";
// import ProfesorService from "../../core/profesor";
function isFacturaProps(obj: unknown): obj is FacturaState {
if (
typeof obj === "object" &&
(
obj?.hasOwnProperty("id_transaccion") ||
obj?.hasOwnProperty("codigo_seguimiento") ||
obj?.hasOwnProperty("cuf")
)
) {
return true;
}
return false;
}
export class FacturaController extends AbstractController<
FacturaView,
FacturaState
> {
constructor(view: FacturaView) {
super(view, isFacturaProps);
}
getValidatedInput(req: Request): FacturaState {
if (isFacturaProps(req.body)) return req.body;
throw TypeError();
}
}
import { FacturaServiceType } from "../../core/factura";
import {
FacturaEntity,
FacturaState,
} from "../../core/factura/FacturaEntity";
import { AbstractView } from "../../view/base/AbstractView";
// import { Result } from "../../core/base/Result";
// Modules
// import { IdObjectType } from "../../view/base/View";
// import { FacturaResult } from "../../core/factura/FacturaService";
export class FacturaView extends AbstractView<
FacturaServiceType,
FacturaEntity,
FacturaState
> { }
import { FacturaView } from "./FacturaView";
import { FacturaController } from "./FacturaController";
import FacturaService from "../../core/factura";
import { Router } from "express";
const view = new FacturaView(FacturaService);
const controller = new FacturaController(view);
const routes = Router();
routes.get("/factura", (req, res) => controller.getAll(req, res));
routes.get("/factura/:id", (req, res) => controller.getById(req, res));
routes.put("/factura/:id", (req, res) => controller.update(req, res));
routes.post("/factura", (req, res) => controller.create(req, res));
export { view, controller, routes };
test("Crear factura", async () => {
expect(true).toBe(true);
});
import { routes as usuarioRoutes } from "./usuario";
import { routes as facturaRoutes } from "./factura";
import { routes as pagoRoutes } from "./pago";
import { routes as parametroRoutes } from "./parametro";
// import { routes as cursoRoutes } from "./curso";
// import { routes as estudianteRoutes } from "./estudiante";
// import { routes as padreRoutes } from "./padre";
// import { routes as eventoRoutes } from "./evento";
// import { routes as asistenciaRoutes } from "./estudiante/asistencia";
// import { routes as permisoRoutes } from "./estudiante/permiso";
// import { routes as notificacionRoutes } from "./notificaciones";
import { Router } from "express";
const routes = Router();
routes.use("/admin", usuarioRoutes);
routes.use("/admin", facturaRoutes);
routes.use("/admin", pagoRoutes);
routes.use("/admin", parametroRoutes);
// routes.use("/admin", padreRoutes);
// routes.use("/admin", eventoRoutes);
// routes.use("/admin", asistenciaRoutes);
// routes.use("/admin", permisoRoutes);
// routes.use("/admin", notificacionRoutes);
export default routes;
import { PagoView } from "./PagoView";
import { AbstractController } from "../../view/base/AbstractController";
import { Request, Response } from "express";
import { PagoState } from "../../core/pago/PagoEntity";
function isPagoProps(obj: unknown): obj is PagoState {
if (
typeof obj === "object" &&
(
obj?.hasOwnProperty("id_transaccion") ||
obj?.hasOwnProperty("notificacion")
)
) {
return true;
}
return false;
}
export class PagoController extends AbstractController<
PagoView,
PagoState
> {
constructor(view: PagoView) {
super(view, isPagoProps);
}
getValidatedInput(req: Request): PagoState {
if (isPagoProps(req.body)) return req.body;
throw TypeError();
}
}
import { PagoServiceType } from "../../core/pago";
import {
PagoEntity,
PagoState,
} from "../../core/pago/PagoEntity";
import { AbstractView } from "../../view/base/AbstractView";
// import { Result } from "../../core/base/Result";
// Modules
// import { IdObjectType } from "../../view/base/View";
// import { PagoResult } from "../../core/pago/PagoService";
export class PagoView extends AbstractView<
PagoServiceType,
PagoEntity,
PagoState
> { }
import { PagoView } from "./PagoView";
import { PagoController } from "./PagoController";
import PagoService from "../../core/pago";
import { Router } from "express";
const view = new PagoView(PagoService);
const controller = new PagoController(view);
const routes = Router();
routes.get("/pago", (req, res) => controller.getAll(req, res));
routes.get("/pago/:id", (req, res) => controller.getById(req, res));
routes.put("/pago/:id", (req, res) => controller.update(req, res));
routes.post("/pago", (req, res) => controller.create(req, res));
export { view, controller, routes };
test("Crear pago", async () => {
expect(true).toBe(true);
});
import { ParametroView } from "./ParametroView";
import { AbstractController } from "../../view/base/AbstractController";
import { Request, Response } from "express";
import { ParametroState } from "../../core/parametro/ParametroEntity";
function isParametroProps(obj: unknown): obj is ParametroState {
if (
typeof obj === "object" &&
(
obj?.hasOwnProperty("clave") ||
obj?.hasOwnProperty("valor")
)
) {
return true;
}
return false;
}
export class ParametroController extends AbstractController<
ParametroView,
ParametroState
> {
constructor(view: ParametroView) {
super(view, isParametroProps);
}
getValidatedInput(req: Request): ParametroState {
if (isParametroProps(req.body)) return req.body;
throw TypeError();
}
}
import { ParametroServiceType } from "../../core/parametro";
import {
ParametroEntity,
ParametroState,
} from "../../core/parametro/ParametroEntity";
import { AbstractView } from "../../view/base/AbstractView";
// import { Result } from "../../core/base/Result";
// Modules
// import { IdObjectType } from "../../view/base/View";
// import { PagoResult } from "../../core/pago/PagoService";
export class ParametroView extends AbstractView<
ParametroServiceType,
ParametroEntity,
ParametroState
> { }
import { ParametroView } from "./ParametroView";
import { ParametroController } from "./ParametroController";
import ParametroService from "../../core/parametro";
import { Router } from "express";
const view = new ParametroView(ParametroService);
const controller = new ParametroController(view);
const routes = Router();
routes.get("/parametro", (req, res) => controller.getAll(req, res));
routes.get("/parametro/:id", (req, res) => controller.getById(req, res));
routes.put("/parametro/:id", (req, res) => controller.update(req, res));
routes.post("/parametro", (req, res) => controller.create(req, res));
export { view, controller, routes };
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment