Skip to content

Fix/publishing accommodation #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b1f449b
Squashed 'frontend/' content from commit 43a91e1
alicecadete28 Dec 9, 2024
1a09df3
Merge commit 'b1f449bbde19ed04817eb16ef76d59296b5d22a8' as 'frontend'
alicecadete28 Dec 9, 2024
58b0db5
Squashed 'backend/' content from commit f8aeda3
alicecadete28 Dec 9, 2024
ff94643
Merge commit '58b0db50e2302883be0783d4e50003c84e9b6afc' as 'backend'
alicecadete28 Dec 9, 2024
45e510c
colocando primeiras features
aline-fortaleza Dec 14, 2024
ea6492e
Feature de ALine
aline-fortaleza Dec 14, 2024
8d82a6f
Create luisa.feature
luisaleiria Dec 14, 2024
91faf5a
Update luisa.feature
luisaleiria Dec 14, 2024
b4daa76
Merge pull request #1 from luisaleiria/luisaleiria-features
alicecadete28 Dec 14, 2024
4d45ff1
criacao do meu arquivo .feature
alicecadete28 Dec 14, 2024
7506d52
Merge branch 'alicecadete28:main' into main
aline-fortaleza Dec 14, 2024
e581944
Update alice.feature
alicecadete28 Dec 14, 2024
59b1d88
Merge pull request #3 from alicecadete28/alicecadete28-patch-1
aline-fortaleza Dec 14, 2024
f46c13c
Merge pull request #2 from aline-fortaleza/main
alicecadete28 Dec 14, 2024
5c73292
Create danilo.feature
DaniloLDCarvalho Dec 15, 2024
361af7f
Update danilo.feature
DaniloLDCarvalho Dec 15, 2024
1601046
Update danilo.feature
DaniloLDCarvalho Dec 15, 2024
65bdabf
edicoes no alice.feature
alicecadete28 Dec 15, 2024
6e97fa6
edicoes no meu .feature
alicecadete28 Dec 15, 2024
d425805
Merge pull request #6 from DaniloLDCarvalho/main
aline-fortaleza Dec 15, 2024
fcada62
adicioando as minhas features
biagcleao Dec 15, 2024
2d2cfe8
Adição do arquivo feature da "editar reservas"
arthurmarsar0 Dec 15, 2024
8c6bb68
Delete marsaro.feature
arthurmarsar0 Dec 15, 2024
18cc874
Adição do arq .feature da "Editar Reservas"
arthurmarsar0 Dec 15, 2024
32365df
Merge pull request #7 from arthurmarsar0/main
aline-fortaleza Dec 15, 2024
588a4a5
Merge branch 'alicecadete28:main' into main
biagcleao Dec 15, 2024
17af49b
Create allan-feature
Alcristi Dec 15, 2024
cc0ad44
Update allan-feature
Alcristi Dec 15, 2024
ba7ebf8
Merge pull request #9 from Alcristi/allan-feature
luisaleiria Dec 15, 2024
f50886b
Merge branch 'alicecadete28:main' into main
biagcleao Dec 15, 2024
15f74c2
Merge pull request #10 from biagcleao/main
arthurmarsar0 Dec 15, 2024
c58a1c1
update feature
Alcristi Dec 16, 2024
5e06ec5
Fix feature
Alcristi Dec 16, 2024
abd542c
Merge pull request #11 from Alcristi/main
alicecadete28 Dec 16, 2024
de10faf
feat: edition of the publishing-accomodation feature
alicecadete28 Dec 22, 2024
caca352
<feat: edition of the publishing-accomodation feature>
alicecadete28 Dec 22, 2024
6ca5944
feat: add new scenario
alicecadete28 Dec 23, 2024
857f70a
feat: edition of 4th scenario
alicecadete28 Dec 23, 2024
0c5fe77
feat: add new scenario
alicecadete28 Dec 23, 2024
cada74a
feat: correcting conflits and manteining only 5 scenarios
alicecadete28 Dec 23, 2024
80b1106
fixing scenario
alicecadete28 Dec 23, 2024
a4c6c0c
pulled from main and corrected conflicts
alicecadete28 Dec 23, 2024
08e74ca
editin last line
alicecadete28 Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#Configuracoes para defini os parametros do editor de texto, Ex tamanho do espacamento dentre outros.
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace =
2 changes: 2 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ENV=DEV
PORT=5001
10 changes: 10 additions & 0 deletions backend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["no-unused-expressions"],
"rules": {
"no-unused-expressions": [
"warn",
{ "allowShortCircuit": true, "allowTernary": true }
]
}
}
36 changes: 36 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
coverage/

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# TypeScript cache
*.tsbuildinfo

# System files
.DS_Store
Thumbs.db

# Editor files
.vscode/

# Build files
dist/
lib/

# Env
.env
.env.test
.env.dev
.env.prod

# Deploy
.vercel
4 changes: 4 additions & 0 deletions backend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint
4 changes: 4 additions & 0 deletions backend/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
4 changes: 4 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
80 changes: 80 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ESS Back-end Node.js

This is the Back-end base project in Node.js for the Software and Systems Engineering discipline, offered by the Informatics Center (CIn) of the Federal University of Pernambuco (UFPE).

## Table of Contents

1. [Getting Started](##getting-started)
2. [Scripts](#scripts)
3. [Dependencies](#dependencies)
4. [Architecture](#architecture)

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

### Prerequisites

To run this project, you'll need to have the following software installed on your system:

- Node.js
- npm (Node Package Manager)

### Installing

Clone the repository and install the dependencies by running the following command in the project directory:

```
npm install
```

### First time running ?

Run the follow scripts

```
chmod +x .husky/pre-commit
chmod +x .husky/pre-push
```

```
npm run
```

### Environment

This project uses `.env` files to manage environment variables. You can create a `.env.dev` file in the project directory and set the environment variables in the file (iou can create it from .`env.example`). The `env` script in the `package.json` file uses the `env-cmd` package to load the environment variables from the `.env.dev` file.

### Running the Server

To start the server, run the following command:

```
env=dev npm run start
```

This command will run the TypeScript compiler in watch mode and start the server using nodemon.

## Scripts

The following scripts are available in the `package.json` file:

- `start`: Runs the TypeScript compiler in watch mode and starts the server using nodemon.
- `build`: Compiles the TypeScript code.
- `test`: Runs the Jest tests for the project.
- `prettier`: Formats the code using Prettier.
- `lint`: Lints the code using ESLint.

## Dependencies

The following dependencies are used in the project:

- [env-cmd](https://github.com/toddbluhm/env-cmd): A simple way to manage your environment variables in npm scripts.
- [express](https://github.com/expressjs/express): Fast, unopinionated, minimalist web framework for Node.js.
- [typescript](https://github.com/microsoft/TypeScript): A typed superset of JavaScript that compiles to plain JavaScript.
- [jest](https://github.com/microsoft/TypeScript): Jest is a delightful JavaScript Testing Framework with a focus on simplicity.
- [pino](https://github.com/pinojs/pino): Very low overhead Node.js logger.

## Architecture

To understand and learn more details about the structure of the project, click [here](./docs/architecture-pattern.md) to be redirected to the README that contains this information.
82 changes: 82 additions & 0 deletions backend/docs/architecture-pattern.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Architecture Pattern

The base project was created to give a quick "start" to the discipline's team projects. But, at the same time, we didn't want to give up a certain level of organization that helps to develop features safely and makes it easier to create tests.

## Table of Contents

1. [Layered architecture](#layered-architecture)
2. [What is the Model for?](#what-is-the-model-for)
3. [Dependency Injection](#dependency-injection)
4. [Database](#database)
5. [Routes](#routes)
6. [Conclusion](#conclusion)

---

# Layered architecture

Layered architecture is a software design approach where the software is separated into different layers (functional areas), each with a specific role and responsibility. In a typical layered architecture, you will find the following layers:

## Entities Layer

This layer represents the business data and the rules or logic that govern access to and updates of this data. These are typically the business objects (like Users, Products, Orders, etc.) and are independent of any specific technological choice (database, external services, etc.). They just contain data and methods to manipulate this data.

## Repository Layer

This layer acts as a bridge between the entities (business data) and the database. It is responsible for all database operations like create, read, update, and delete (CRUD). It basically interacts with your database or any other storage system.

## Service Layer

This layer contains the business logic of your application. It uses the repository layer to persist or retrieve the business data, performs necessary processing and passes the data to the controller. The service layer acts as an intermediary between the web layer (controllers) and the data access layer (repositories).

## Controller Layer

This layer is responsible for handling user requests and controlling the flow of the application. It interacts with the service layer to perform business operations and sends back the responses to the client. In a web application, these are typically the endpoints of your API.

The layered architecture approach helps in separating concerns, making the software solution scalable, and also promotes high cohesion and low coupling. This design pattern is beneficial because it aligns with the Single Responsibility Principle (SRP), which is a key aspect of SOLID principles in software design and architecture. Each layer has a specific role and does not need to concern itself with the responsibilities of any other layer. This makes each layer independently modifiable and testable, leading to a software design that is easier to maintain and expand.

---

# What is the Model for?

Models here are not absolutely essential, but are primarily used as a final representation of returned data. Unlike entities, which we can think of as a direct representation of a database table in code, we use models to represent what we could return in an endpoint.
For example, when retrieving a user from the database, we might not want to return its password. In this case, the model could represent a user excluding the password field.

But we can follow for example the idea of [​​DTOs](https://www.okta.com/identity-101/dto/), which would also be a good idea.
Feel free to explore alternatives for representing these data operations.

# Dependency Injection

Is a design pattern that allows a system to be more flexible, testable, and modular. It's a form of Inversion of Control (IoC) which means that the control is inverted - instead of an object controlling its own dependencies, it's controlled by an outside party.

In our case, we came up with a "homemade" solution that, overall, works very well. We use the Injector class, which is in charge of controlling our application's dependencies through its methods: registerService, getService, registerRepository and getRepository. The use of this class can be seen in the index.ts file, located in the **src/di folder**.

# Database

The idea of ​​a base project may seem complex when it proposes to cover many possibilities of use. Considering a practical and simple case, in this base project we are using the idea of ​​a "database" at runtime. In the **src/database/index.ts** file, we can observe the implementation of a simple interface for a database, where each "table" would be a set of key-values. Please don't see this as a limiter. If you prefer, you can choose to use a real database, be it SQL or NoSQL. By maintaining a similar level of project organization, the benefits will be the same.

To manipulate our database with base methods, we have a class called BaseRepository. This will be extended by other repositories, thus allowing the inheritance of these methods and the reuse of our code's logic.

# Routes

Worth mentioning is our backend routes/endpoints definition file located at **src/routes/index.ts**. Its idea is simple: for each new controller, you can configure it inside 'export default' using **'app.use'**.

```
export default (app: Express) => {
app.use(
prefix,
new TestController(router, di.getService(TestService)).router
);
app.use(
prefix,
new ExampleController(router, di.getService(ExampleService)).router
);
};

```

There is already an example in the file and the approach would be the same for all controllers. Thus, the controllers and their endpoints are registered and recognized in the application.

# Conclusion

Certainly, there are more details about the functionalities that are used in the project. However, the **Test** example case already covers many aspects, including testing. The base project is designed to make it easy, not to limit your preferences. What needs to be emphasized is that the main idea is the architecture used, which clearly distributes code responsibilities, thus facilitating maintenance and testing.
12 changes: 12 additions & 0 deletions backend/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: '',
testRegex: ['.steps.ts$'],
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
setupFilesAfterEnv: ['./setupTests.ts'],
};

Loading