Giter Club home page Giter Club logo

api's People

Contributors

afuu21 avatar cahllagerfeld avatar dalpatrathore avatar detexter-develop avatar eddiejaoude avatar fayasnoushad avatar khattakdev avatar luffysama-dev avatar lukeecart avatar panquesito7 avatar pradumnasaraf avatar prathamesh-shanbhag avatar rahma-alwadhahi avatar rohan-kulkarni-25 avatar sanjay-sathyanarayanan avatar sarajaoude avatar schmelto avatar shaileshkumar007 avatar tbhaxor avatar ujjwal-kr avatar vardaanaggarwal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api's Issues

Automated Testing

Automated testing end-to-end with what NestJS recommend (remove unit testing)

Subtask of #12

Check for Exception not working as expected

When removing a Discorduser the Check for Not-Found-Exception isnt working as intended

  remove(id: number) {
    const updatedDiscord = this.discord.filter((user) => user.id !== id);

    //this checks if an Array is undefined, not if the Element to delete is present
    if (!updatedDiscord) { 
      throw new HttpException('User Not Found', HttpStatus.NOT_FOUND);
    }
    this.discord = [...updatedDiscord];
    return 'User deleted successfully!';
  }

Add github actions

We should add github actions here.
It could be similar to EddieBot.
I would like to do this but it would be my first time and I have to learn it first and practice on one of my repos.

If you wouldn't mind I could do it in 2 or 3 days.

Use Helmet

We should use helmet to improve security for our api.
Its like a default-package when building an api with express.
Helmet

Discord data collection

Discord

interface Discord {
   uid: string;
   location: {
       text: string;
       lat: number;
       lng: number;
   };
   socials: {
       [key: string]: string; // GitHub, linkedin, instagram, twitter
   }
}

Use Validatonpipe for DTOs

Nest provides the opportunity to use Validationpipe using class-validator and class-transformer.
Maybe we should think about using this pipe fot Data-Transfer-Objects.
Feel free to discuss on this topic.

Documentation for setting up MongoDB

We should add some documentation for setting up mongo for running this locally, related to the project, of course.
We should also add a link to the MongoDB official page for more instructions.

Share your opinion about this.

Unittesting

The Unittests which are currently available are the predefined ones. Should we invest time in Unittests in addition to e2e-tests?

GitHub events log with dates

Event totals are already saved, but would also be good to store the event with the date in another collection (could have a ttl)

Step def functionality for testing

Discussed here #76 (comment)

I think we need to create another step def similar to this one that would make it easier to read - I can do it in another PR after this one is merged.

@then(/the response in item "([^"]*)" should contains:/)
public dataResponseItemTable(item: number, table: { rawTable: [] }) {
    const data = this.context.tableToObject(table);
    expect(JSON.parse(this.context.response.text)[item]).to.to.eql(data);
}

https://github.com/EddieHubCommunity/api/blob/main/test/step-definitions/responses.ts#L31

The new step def would be something like this

@then(/the response property "([^"]*)" in field "([^"]*)" should contains:/)
public dataResponseItemTable(property: string, item: number, table: { rawTable: [] }) {
    const data = this.context.tableToObject(table);
    expect(JSON.parse(this.context.response.text)[property][item]).to.eql(data);
}

The tests would be something like

And  the response property "future" in item "0" should contains:
            | id   | 123                |
            | name | "Livestream XY"    |
And  the response property "ongoing" in item "0" should contains:
            | id   | 123                |
            | name | "Livestream YZ"    |

Note: I think contains should be singular ๐Ÿค” - this can be changed later

GitHub data collection

GitHub

interface GitHub {
   username: string;
   bio: string; // do we need Discord bio?
   avatarUrl: string
   followers: number;
   repos: number;
   // ... any other useful info public info https://docs.github.com/en/rest/reference/users
   communityStats: {
      [key: string]: number
   };
}

Also playing with #61

Setup the project

There has been some discussion about the technology choices for this project here: #1. So I was thinking we could get the project started and continue from there ๐Ÿ˜ƒ.

The goal of this issue would be to bootstrap the project and get most stuff setup. So here are the tasks I purpose we complete:

  • Setup a linter (e.g. ESLint)
  • Setup Node.js w/TypeScript and Express
  • Setup cucumber
  • Setup MongoDB

Update Discorduser not working properly

In discord-service after changing the values in existing Userobject coming from the DTO arent updated in discord-Array.

  update(id: number, updateDiscordDto: UpdateDiscordDto) {
    const { username, bio, socials } = updateDiscordDto;

    const discordUser = this.discord.find((user) => user.id === id);
    if (!discordUser) {
      throw new HttpException('User Not Found', HttpStatus.NOT_FOUND);
    }
    const updatedDiscord = { ...discordUser };
    if (username) {
      updatedDiscord.username = username;
    }
    if (bio) {
      updatedDiscord.bio = bio;
    }

    if (socials && socials.discord) {
      updatedDiscord.socials.discord = socials.discord;
    }
    if (socials && socials.twitter) {
      updatedDiscord.socials.twitter = socials.twitter;
    }
    if (socials && socials.linkedin) {
      updatedDiscord.socials.linkedin = socials.linkedin;
    }
    if (socials && socials.github) {
      updatedDiscord.socials.github = socials.github;
    }

   //existing discordUser needs to be updated here before returning string

    return 'User updated successfully!'; 
  }

Update Discord Resource

Make some changes in the discord resource.

  • Update the interface with following keys
interface Member {
   username: string;
   bio: string,
   socials: {
      discord: string
      twitter: string;
      linkedin: string;
      github: string;
   };
   updatedOn: Date;
   createdOn: Date;
}

Centralized Logging

When growing the Application we might need some Monitoring about Performance, Failures or Errors. We could potentially implement centralized logging to Azure App Insights or Sentry.
If we do so, we could also implement this to the different Frontends like EddieBot or a Website

Create CRUD for member without DB

This is a subtask (#12)

interface Member {
   username: string;
   bio: {
      description: string;
      twitter: string;
      linkedin: string;
      github: string;
   };
   updatedOn: Date;
   createdOn: Date;
}

Idea: Rate Limiting

Do we need rate-limiting for the api, that we cant get ddosed?
We could set how many requests in a specific interval are served directly, while the additional ones are delayed automatically.

Document the testing and step defs with simple examples

Document how to write the automated tests and the different styles, here is an example

Scenario: get list of events
         Given make a GET request to "/calendar"
         Then the response status code should be 200
         And the response should contain:
             | future  | [] |
             | ongoing | [] |

Idea: Calendar Module

In case of having a "Community Calendar" we could integrate this to the Api, to access Data from that Calendar in other projects as well.
Before realizing that we should definitly specify some more Details - Feel free to Add Ideas in the Comments!

NestJS

  • Create NestJS api project from CLI
  • Add GitHub Action for lint, prettier, build
  • Use NestJS CLI to create a new CRUD resource called discord with the generate command resource docs
  • Automated testing end-to-end with what NestJS recommend (remove unit testing)
  • Wrap automated testing in Cucumber
  • GitHub Action for automated testing
  • Create CRUD for member without DB
interface Member {
   username: string;
   bio: string;
   socials: {
      discord: string;
      twitter: string;
      linkedin: string;
      github: string;
   };
   updatedOn: Date;
   createdOn: Date;
}
  • Add Mongo DB for CRUD with typeorm docs
  • Add Swagger docs (there is a NestJS plugin)
  • Dockerise
  • Deploy to Digital Ocean

Notes for the future

  • Discord (username, total messages, total reactions, bio, social links)
  • GitHub (username, total commits, total replies, total issues, total PRs, total reactions)

Standup endpoint

It would be great to encourage more daily standup information.

  • Save (from bot or UI) daily standup information
  • Read daily standup information in daily order desc

Update after discussion with @mstanciu552 below

send the information from EddieBot to the API using axios or fetch and then save them in a users collection in our db

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.