Skip to content
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

Synchronize develop with master after release v1.1.1 #2

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 1.1.0 (2021-04-07)
## [1.1.1](https://github.com/governify/collector-osseco/compare/v1.1.0...v1.1.1) (2023-05-08)



# [1.1.0](https://github.com/governify/collector-osseco/compare/f8dd85600becfb24c0495d7ad2d0bcc312491a9a...v1.1.0) (2021-04-07)


### Bug Fixes
Expand Down
47 changes: 3 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,11 @@
# Governify Collector v2 Template (POST collector)
# OSSECO Collector Analyzer
[![Node.js CI](https://github.com/governify/collector-osseco/workflows/Node.js%20CI/badge.svg?branch=master)](https://github.com/governify/collector-osseco/actions)
<a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-semistandard-brightgreen.svg" alt="Standard - JavaScript Style Guide"></a>
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Coverage Status](https://coveralls.io/repos/github/governify/collector-osseco/badge.svg?branch=main)](https://coveralls.io/github/governify/collector-osseco?branch=main)
[![dependencies Status](https://david-dm.org/governify/collector-osseco/status.svg)](https://david-dm.org/governify/osseco)
[![devDependencies Status](https://david-dm.org/governify/collector-osseco/dev-status.svg)](https://david-dm.org/governify/collector-osseco)

## Overview
This is a template for creating a new collector for the Governify echosystem.
## Collector OSSECO
This is a the main repo for the OSSECO Collector Analyzer

## Installation of the template
1. Create your repository on GitHub with a README.md file and clone it into your system.
2. Download this repository as a ZIP and paste all the files into your repository overwritting the readme file.
3. Modify this README.md and the badges urls to referenciate the new repository.
4. Activate project on coveralls for the badge to start working (Must be a public) and add this to the `/.github/workflows/nodejs.yml` file at the end.
```yml
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```

David-dm badges will not work unless the repository is public.

## Usage
### Explanation
The POST controller will do the following when requested:
1. Validate the input.
2. Divide the dsl.metric.window into a set of periods.
3. Create the identifier of the computation and return it to the client.
4. Ask for the metric for each period generated on step 2 to the computationCalculator (This is what you should implement).
5. When all the metrics are returned to it, it generates an array and sets it to the identifier generated on step 3 for the client to ask for it.

The POST controller, when requested, will ask the POST controller for the computation and will respond depending:
- If the computation is **null**, it means it still working. This returns a **202** code.
- If the computation is an **array**, it means it is everything calculated. This returns a **200** with the computation.
- If the computation is a **string**, it means there was a validation error. This returns a **400** code with the error message.
- If the computation is **undefined**, it means the identifier does not exist. This returns a **404** code.
- If the computation is **anything else**, what should not happen, it returns a **500** code.

### Implementation
- **Code**: All you have to do is to go to the file `/controllers/computationCalculator/index.js` and implement your code resolving the metric in the structure defined there. You have the entire DSL from the POST and a period to calculate the metric. Do not use the window of the DSL because the controller already divided the periods.

- **Test**: There is a test implemented which starts the server and makes a POST request, and with the computationId received, makes a GET request to obtain the computation. To fit it with your code just create a DSL petition which response should never change and copy the DSL and the computations of the GET response into the initializeDataAndServer function on the test.js file (lines 79-144)

- **Validation**: The system is validating the dates to fit ISO 8601 standard. If you need to change it or to validate any other field you can do it on the function validateInput in the apiv2computationsControllerService.js file (lines 60-82). All you have to do is to reject the promise with an error if a field is invalid.

- **Swagger spec**: If you need to change the POST data, the DSL or the responses you can do it by going to /api/oas-doc.yaml and doing it there. We encourage you to use the given one but it may be necessary in some cases. Modifying the DSL should cause no problems at all.

## About
This project leverages the mega-awesome [oas-tools](https://github.com/isa-group/oas-tools) middleware which does most all the work.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "computation-list",
"version": "1.1.0",
"version": "1.1.1",
"description": "No description provided (generated by OAS Codegen)",
"main": "index.js",
"scripts": {
Expand Down