Git Product home page Git Product logo

common's Introduction

AthennaIO ๐Ÿฆด

The Athenna scaffold project used by 'athenna new project' command to create your project.

GitHub followers GitHub stars

Buy Me A Coffee

GitHub language count Repository size License Commitizen

Links

For project documentation click here. If something is not clear in the documentation please open an issue in the documentation repository

Contributing

If you want to contribute to this project, first read the CONTRIBUTING.MD file. It will be a pleasure to receive your help.


With ๐Ÿ’œ by Athenna community

common's People

Contributors

jlenon7 avatar robsontrasel avatar snyk-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

robsontrasel

common's Issues

[Feature]: Implement FakeApi class

๐Ÿš€ Feature Proposal

The FakeApi class will be responsible for creating fake, but not totally fake, endpoints using fastify. This class should have an enjoyable API to create new endpoints, it should be very easy to create endpoints that return the following specific data in the response:

  • body
  • headers
  • status code

It would be very nice if FakeApi helper could be configured using .json files, the same way that Wiremock does. Let's suppose that we have created the resources/fakeapi/create-user.json file:

When calling the await FakeApi.start() helper, it should read the resources/fakeapi folder and register all the routes inside it. The create-user.json content would have the route path, method, status code, headers and body defined for the response:

{
  "path": "/users",
  "method": "POST",
  "statusCode": 201,
  "headers": {
    "Content-Type": "application/json"
  },
  "body": {
    "id": 1,
    "name": "Robson Trasel"
  }
}

Motivation

Sometimes the developer needs to create more realistic tests, where he really needs to make a Http request. We have tryed to use Wiremock for this purpose, but is very hard to configure it for Node.js inside pipelines like Github Actions.

Example

Here is an example of using the FakeApi helper API in runtime:

const path = '/users'
const statusCode = 200
const user = { id: 1, name: 'Joรฃo Lenon' }
const arrayOfUsers = [user]
const headers = {
  Content-Type: 'application/json'
}

await FakeApi.builder()
    .method('GET')
    .path(path)
    .statusCode(statusCode)
    .body(arrayOfUsers)
    .headers(headers)
    // Register the fake route and clear FakeApi static state:
    .register()

const port = 8080

await FakeApi.start(port)

// Requesting to the endpoint we have created:
const users = await HttpClient.get('http://localhost:8080').json()

// Stop the fake server:
await FakeApi.stop()

[Bug]: resolveEnvironment method buildPath is wrong

Version

3.0.1

Steps to reproduce

Call Path.resolveEnvironment()

Expected behavior

Expect that when env IS_TS is true, that the Path.defaultBeforePath becomes just ''.

Actual behavior

The Path.defaultBeforePath is being set as /build.

Additional context

No response

Environment

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 91.56 MB / 16.00 GB
    Shell: 5.8 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm

[Bug]: Adjust NotFoundFileException help and message content

Version

4.15.3

Steps to reproduce

Try to read a file that does not exist. The exception will be thrown.

Expected behavior

I expect to see a better error message that follows the actual API of File.

Actual behavior

The help and message content, talks about the File.create method, which does not exist anymore.

Additional context

No response

Environment

System:
    OS: macOS 13.5.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 182.02 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm

[Feature]: Adjust Path and Module classes to support TypeScript

๐Ÿš€ Feature Proposal

1 - Implement the Path.ext method. This method will be responsible to return js or ts by verifying if the process.env.IS_TS is true or false.
2 - Make Path.getAllJSFilesFrom use Path.ext to determine if the glob pattern will get .js files or .ts.

Motivation

Athenna is totally focused in using JavaScript with ESM. But there is a big portion of developers that prefers to use TypeScript. The tc39/proposal-type-annotations is still in Stage 1. It should take a long time for this proposal to start moving, so we are going to implement helpers to support TypeScript implementation in Athenna scaffolds project.

Athenna will still be developed using JS with ESM.

Example

No response

[Bug]: Method Exception from Is class needs to do a better validation

Version

3.5.0

Steps to reproduce

1 - Create an error class that does not extend vanilla JS/Node.js errors.
2 - Call Is.Exception(new YourCustomError()).

Expected behavior

Expected the return value to be false.

Actual behavior

The result is true.

Additional context

The Exception class could have a simple instance argument called isException. In Is.Exception method, we can continue validating vanilla JS/Node.js errors, and also if isException argument is true and if the prettify method exists inside the error instance.

Environment

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 123.92 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm

[Feature]: Update version to 3.0.0

๐Ÿš€ Feature Proposal

The version of this package needs to be updated to 3.0.0.

Motivation

We are going to start versioning the Athenna packages using Semver. All packages of Athenna will be updated to version 3.0.0 to start following Semver rules.

Example

No response

[Feature]: Implement HttpClient class

๐Ÿš€ Feature Proposal

The HttpClient class will be responsible to make http requests to other services. With this class, we should be able to define global settings to use in all requests that use the HttpClient class. This global settings will be based in HttpClientBuilder of Apache, and we should be able to set a global instance of this builder for all HttpClient or create another instance of HttpClient using different HttpClientBuilder instances.

Motivation

Nowadays in Athenna if the developer needs to make any Http request he will need to use the vanilla http or https of Node.js or some library like axios or node-fetch. It would be nice if Athenna has her own implementation to do that.

Example

No response

[Feature]: Add support to Path class to change the paths

๐Ÿš€ Feature Proposal

Add support to Path class to change the path of some method.

Motivation

With this behavior, we are going to remove the destination logic of make commands in .athennarc.json file. Also, it will be very good for the developer to use his own project structure.

Adding this behavior to Path class will enable us to add the directories property in our .athennarc.json, mapping the exactly directories that Path class should follow. And also

Example

import { Path } from '@athenna/common'

Path.setRoutes(Path.pwd('src/routes'))

console.log(Path.routes()) // ..../src/routes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.