Skip to content
Snippets Groups Projects
Commit 719523f3 authored by Julieta Dubra Raimunde's avatar Julieta Dubra Raimunde
Browse files

configuracion inicial

parent 5ef0183e
No related branches found
No related tags found
No related merge requests found
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"airbnb-typescript/base",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2021
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"rules": {
"linebreak-style": [
"error",
"windows"
],
"import/extensions": "off",
"import/prefer-default-export":"off",
"@typescript-eslint/camelcase":"off",
"@typescript-eslint/no-var-requires":"off"
}
}
node_modules
----Como correr los test ----
Para crear un test para un correspondiente archivo se debe proceder de la siguiente forma:
-Para un archivo ```ejemplo.ts``` crear dentro de la carpeta __test__ un archivo llamado ```ejemplo.test.js```
-Dentro del archivo ejemplo.test.ts incluir el archivo ejemplo.ts con ```const sum = require('./../ejemplo');```
-Para cada función a probar ```funcionEjemplo(arg)``` la forma de diseñar un test es:
-```test(Desc, () => {expect(funcionEjemplo(ejemploArg)).toBe(resultado);});```
-Aqui los argumentos son:
-```funcionEjemplo``` = es la funcion que esta siendo probada, que tiene como inputs ```arg```
-```Desc``` = es un string, que debe describir brevemente el test que se lleva a cabo
-```ejemploArg``` = son los argumentos con los cuales se testeará la ```funcionEjemplo```
-```resultado``` = es el retorno esperado de ```funcionEjemplo``` con los argumentos ```ejemploArg```
-Pueden agrupar los test con ```describe("Nombre del grupo de tests", () =>{}```, dentro de ese bloque se especifican los test al igual que antes, cambiando ```test``` por ```it```
Los tests son ejecutados de las siguientes formas:
-Manualmente pueden ejecutarse todos mediante ```npm run test```
-Individualmente cada test puede ser ejecutado con ```npm test -- -t "Nombre del test" ``` (El nombre es el argumento del ```describe``` previamente mencionado)
-Alternativamente todos los test son ejecutados al llevar a cabo un push. Si uno de los test no es exitoso, el push no se lleva a cabo
\ No newline at end of file
Source diff could not be displayed: it is too large. Options to address this: view the blob.
{
"name": "backend_users",
"version": "1.0.0",
"description": "Herramienta de calculo de requerimiento energetico ponderado para una poblacion. Este repositorio contiene la parte del backend especifica al manejo de usuarios.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://gitlab.fing.edu.uy/julieta.dubra/repp_backend_users.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"config.json": "0.0.4",
"cors": "^2.8.5",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"gulp-eslint": "^6.0.0",
"helmet": "^4.6.0",
"openapi-types": "^9.3.0",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.1.6",
"tsconfig.json": "^1.0.10",
"winston": "^3.3.3",
"xlsx": "^0.17.1",
"yamljs": "^0.3.0"
},
"devDependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"@types/node": "^16.7.10",
"@types/swagger-jsdoc": "^6.0.1",
"@types/swagger-ui-express": "^4.1.3",
"@types/winston": "^2.4.4",
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^7.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": "^4.3.8",
"jest": "^27.0.6",
"lint-staged": "^11.1.2",
"nodemon": "^2.0.12",
"ts-node": "^10.2.1",
"typescript": "^4.4.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"./node_modules/.bin/eslint --fix",
"git add"
]
}
}
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
import {
Handler, Request, Response, Router,
} from 'express';
import { SheetParserResponse } from '../Models/SheetParserResponse';
import SheetService from '../Services/SheetService';
import logger from '../Logger/logger';
const router = Router();
const parseSheet: Handler = async (req: Request, res: Response) => {
const sheet: Buffer = req.body;
try {
const parsedSheet: SheetParserResponse = SheetService.parseSheetService(sheet);
return res.status(200).send(parsedSheet);
} catch (error) {
const e = error as Error;
logger.info(e.message);
return res.status(400).json({ error: e.message });
}
};
router.post('/', parseSheet);
export default router;
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
BORRAR CUANDO CREEN UN ARCHIVO, ES PARA PODER HACER EL PUSH INICIAL
\ No newline at end of file
/* eslint-disable no-console */
import express, { Application } from 'express';
import 'dotenv/config';
import cors from 'cors';
import swaggerUi from 'swagger-ui-express';
import helmet from 'helmet';
import YAML from 'yamljs';
import Routes from './routes';
// import logger from './Logger/logger';
const app: Application = express();
const PORT = process.env.PORT || 8000;
app.use(helmet.hidePoweredBy());
// swagger init
const swaggerDocument = YAML.load('./swagger.yaml');
// middlewares
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
app.use(express.json({
limit: '50mb',
}));
app.use(express.urlencoded({ extended: false }));
app.use(cors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
}));
app.use(express.raw({
limit: '50mb',
}));
app.use(Routes);
app.listen(PORT, (): void => {
console.log(`REPP Backend running here 👉 https://localhost:${PORT}`);
logger.info('Server initiated');
});
import { Request, Response, Router } from 'express';
import SheetController from './Controllers/SheetController';
const router = Router();
router.get('/', (req: Request, res: Response): void => {
res.send('Hey! This is REPP API, you can go to /api-docs to learn more!');
});
router.use('/sheetParser', SheetController);
export default router;
openapi: 3.0.0
info:
version: 1.0.0
title: REPP Backend
description: ''
security:
- BearerAuth: []
tags:
- name: Auth
- name: Parser
- name: Calculation
paths:
/login:
post:
tags:
- Auth
summary: Login to get an access token
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserCredentials'
responses:
'200':
description: Ok.
security: []
/sheetParser:
post:
tags:
- Parser
summary: Given a sheet returns SheetParserResponse
requestBody:
content:
application/octet-stream:
schema:
format: binary
required: true
responses:
'200':
description: Ok.
security:
- BearerAuth: []
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
schemas:
Menores:
properties:
edad:
type: integer
peso:
type: integer
Mayores:
properties:
edad:
type: integer
peso:
type: integer
talla:
type: integer
SheetParserResponse:
properties:
hombresMenores:
type: array
items:
$ref: '#/components/schemas/Menores'
mujeresMenores:
type: array
items:
$ref: '#/components/schemas/Menores'
hombres:
type: array
items:
$ref: '#/components/schemas/Mayores'
mujeres:
type: array
items:
$ref: '#/components/schemas/Mayores'
UserCredentials:
properties:
user:
type: string
pass:
type: string
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment