Coder Social home page Coder Social logo

jaspermayone-archive / api Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 8.0 1.8 MB

Basic API, designed and coded for the @Heptagram-Bot-Project

Home Page: http://api.heptagrambotproject.com

License: Eclipse Public License 2.0

Shell 2.16% TypeScript 97.84%
api encouragement-api express express-js expressjs hacktoberfest jokes-api projectheptagram quotes-api

api's People

Contributors

90r1ll4 avatar ank1traj avatar codefactor-io[bot] avatar datreeio[bot] avatar dependabot[bot] avatar eroxl avatar jaspermayone avatar renovate-bot avatar renovate[bot] avatar satyap54 avatar sukriti-m avatar vyvy-vi avatar

Stargazers

 avatar  avatar

Watchers

 avatar

api's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/datree-validation.yml
  • actions/checkout v3
  • tj-actions/changed-files v34
.github/workflows/first-interaction.yml
  • actions/first-interaction v1
.github/workflows/labels.yaml
  • actions/setup-node v3
.github/workflows/pull-request-automation.yml
  • andrewmusgrave/automatic-pull-request-review 0.0.5
.github/workflows/take.yml
.github/workflows/todo.yml
  • alstr/todo-to-issue-action v4.8.1
npm
package.json
  • @types/mongoose ^5.11.97
  • @types/swagger-jsdoc ^6.0.1
  • @types/uuid ^8.3.4
  • axios ^1.1.2
  • bcryptjs ^2.4.3
  • body-parser ^1.20.0
  • bun-types ^0.2.0
  • chalk ^5.0.1
  • colors ^1.4.0
  • cors ^2.8.5
  • dotenv ^16.0.3
  • express ^4.18.2
  • express-ping ^1.4.0
  • express-public-ip ^1.0.1
  • express-rate-limit ^6.6.0
  • express-validator ^6.14.0
  • helmet ^6.0.0
  • ipinfo-express ^1.1.0
  • jsonwebtoken ^8.5.1
  • mathjs ^11.0.0
  • mongoose ^6.7.2
  • openapi-types ^12.0.2
  • redis ^4.4.0
  • source-map-support ^0.5.21
  • swagger-jsdoc ^6.2.5
  • swagger-ui-express ^4.3.0
  • ts-node ^10.7.0
  • typescript ^4.8.2
  • uuid ^9.0.0
  • @types/body-parser 1.19.2
  • @types/compression 1.7.2
  • @types/cors 2.8.12
  • @types/node 18.11.9
  • @types/swagger-ui-express 4.1.3
  • @typescript-eslint/eslint-plugin 5.43.0
  • @typescript-eslint/parser 5.43.0
  • all-contributors-cli 6.24.0
  • eslint 8.27.0
  • eslint-config-prettier 8.5.0
  • eslint-plugin-import 2.26.0
  • eslint-plugin-jsdoc 39.6.2
  • eslint-plugin-prettier 4.2.1
  • husky 8.0.2
  • lint-staged 13.0.3
  • nodemon 2.0.20
  • prettier 2.7.1
  • yarn 3.3.0

  • Check this box to trigger a request for Renovate to run again on this repository

Admin Restricted Endpoints

System that allows only a specified group of people to access any /admin endpoints, and any other endpoints specified such as /auth

[FEAT] - Swagger Docs

What feature would you like to see?

No response

Additional information

No response

Check against Google Safe Browsing API (https://developers.google.com/safe-brows...

For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.

See Lines 46-77 for the implementation I have so far.

https://github.com/Heptagram-Project/api/blob/de0b75a53da0f79f0fe0eae39a54bbb823c49028/src/utils/checkExternal.ts#L40

        source: "WalshyAPI",
      };
    }

    /* TODO: Check against Google Safe Browsing API (https://developers.google.com/safe-browsing/v4/lookup)
     For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.
     See Lines 46-77 for the implementation I have so far.
    */

    /*
    const GOOGLE_SAFE_BROWSING_API_KEY = process.env.GOOGLE_SAFE_BROWSING_API_KEY;
    const checkGoogleSafeBrowsing = await axios.post(`https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${GOOGLE_SAFE_BROWSING_API_KEY}`,
      {
        headers: {
          Accept: "application/json",
          ContentType: "application/json",
        },
        body: {
          "client": {
            "clientId": "yourcompanyname",
            "clientVersion": "1.5.2"
          },
          "threatInfo": {
            "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
            "platformTypes": ["WINDOWS"],
            "threatEntryTypes": ["URL"],
            "threatEntries": [
              { "url": "http://www.urltocheck1.org/" },
              { "url": "http://www.urltocheck2.org/" },
              { "url": "http://www.urltocheck3.com/" }
            ]
          }
        }
      }
    );

    if (checkGoogleSafeBrowsing.data.matches.length > 0) {
      return {
        scamDetected: true,
        source: "GoogleSafeBrowsing",
      };
    }
    */

    return {
      scamDetected: false,
      source: "",

Database Migration

I would like to migrate, to host a database locally.

Preferably, I would like to use

I will need help with getting this integrated with the API, and getting this hosted on the Heptagram Server. Let me know if anybody is interested in taking this!

Check against Google Safe Browsing API (https://developers.google.com/safe-brows...

For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.

See Lines 46-77 for the implementation I have so far.

https://github.com/Heptagram-Project/api/blob/293743f53aa0d07af2b43da4b5c897221486d14e/src/utils/checkExternal.ts#L40

        source: "WalshyAPI",
      };
    }

    /* TODO: Check against Google Safe Browsing API (https://developers.google.com/safe-browsing/v4/lookup)
     For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.
     See Lines 46-77 for the implementation I have so far.
    */

    /*
    const GOOGLE_SAFE_BROWSING_API_KEY = process.env.GOOGLE_SAFE_BROWSING_API_KEY;
    const checkGoogleSafeBrowsing = await axios.post(`https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${GOOGLE_SAFE_BROWSING_API_KEY}`,
      {
        headers: {
          Accept: "application/json",
          ContentType: "application/json",
        },
        body: {
          "client": {
            "clientId": "yourcompanyname",
            "clientVersion": "1.5.2"
          },
          "threatInfo": {
            "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
            "platformTypes": ["WINDOWS"],
            "threatEntryTypes": ["URL"],
            "threatEntries": [
              { "url": "http://www.urltocheck1.org/" },
              { "url": "http://www.urltocheck2.org/" },
              { "url": "http://www.urltocheck3.com/" }
            ]
          }
        }
      }
    );

    if (checkGoogleSafeBrowsing.data.matches.length > 0) {
      return {
        scamDetected: true,
        source: "GoogleSafeBrowsing",
      };
    }
    */

    return {
      scamDetected: false,
      source: "",

more examples

https://github.com/Heptagram-Bot-Project/api/blob/f9f9f8240d536284991cecdecc35e233bf327d13/src/index.ts#L24

console.log('Try npm run lint/fix!');

const longString =
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ut aliquet diam.';

const trailing = 'Semicolon';

const why = 'am I tabbed?';

export function doSomeStuff(
  withThis: string,
  andThat: string,
  andThose: string[]
) {
  //function on one line
  if (!andThose.length) {
    return false;
  }
  console.log(withThis);
  console.log(andThat);
  console.dir(andThose);
  return;
}
// TODO: more examples

Add result logging to database

When we check if a link is scam, we get a bunch of raw results. We use only relevant info to determine if it is a scam or not... I would like to be able to store all of the raw results in database collections. This should be pretty easy, just don't have the time for it rn. Let me know if whoever takes this has any questions.

Handle exception

https://github.com/Heptagram-Project/api/blob/c1d9a43352412b377031c8a746132c0da2476605/src/middleware/saveUserMetric.ts#L27

import errorLogger from "../logger";
import { MetricsModel } from "../models/Metrics";
import { getLatitudeAndLongidute } from "../utils/getLatitudeAndLongitude";
import { v4 as uuidv4 } from "uuid";

export async function saveUserMetrics(req, res, next) {
  if (req.ipinfo.bogon) {
    const errorMessage = `Error: Bogon IP!`;
    console.log(req.ipinfo.IP);
    errorLogger({ message: errorMessage }, uuidv4(), req);
    return next();
  }

  const { ip, city, region, country, timezone, loc } = req.ipinfo;
  const metric = new MetricsModel({
    id: req.user.userId,
    ip: ip,
    city: city,
    region: region,
    country: country,
    timezone: timezone,
    longitude: getLatitudeAndLongidute(loc).longitude,
    latitude: getLatitudeAndLongidute(loc).latitude,
    urlAccessed: req.originalUrl,
  });

  await metric.save(); // TODO: Handle exception
  next();
}

Check against Google Safe Browsing API (https://developers.google.com/safe-brows...

For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.

See Lines 46-77 for the implementation I have so far.

https://github.com/Heptagram-Project/api/blob/24ce8643a5fefe058ff3445907a06d5df36f7a44/src/utils/checkExternal.ts#L40

        source: "WalshyAPI",
      };
    }

    /* TODO: Check against Google Safe Browsing API (https://developers.google.com/safe-browsing/v4/lookup)
     For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.
     See Lines 46-77 for the implementation I have so far.
    */

    /*
    const GOOGLE_SAFE_BROWSING_API_KEY = process.env.GOOGLE_SAFE_BROWSING_API_KEY;
    const checkGoogleSafeBrowsing = await axios.post(`https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${GOOGLE_SAFE_BROWSING_API_KEY}`,
      {
        headers: {
          Accept: "application/json",
          ContentType: "application/json",
        },
        body: {
          "client": {
            "clientId": "yourcompanyname",
            "clientVersion": "1.5.2"
          },
          "threatInfo": {
            "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
            "platformTypes": ["WINDOWS"],
            "threatEntryTypes": ["URL"],
            "threatEntries": [
              { "url": "http://www.urltocheck1.org/" },
              { "url": "http://www.urltocheck2.org/" },
              { "url": "http://www.urltocheck3.com/" }
            ]
          }
        }
      }
    );

    if (checkGoogleSafeBrowsing.data.matches.length > 0) {
      return {
        scamDetected: true,
        source: "GoogleSafeBrowsing",
      };
    }
    */

    return {
      scamDetected: false,
      source: "",

Check against Google Safe Browsing API (https://developers.google.com/safe-brows...

For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.

See Lines 46-77 for the implementation I have so far.

https://github.com/Heptagram-Project/api/blob/3c798162204c9be611f15d6ab457568e8b9af06f/src/utils/checkExternal.ts#L40

        source: "WalshyAPI",
      };
    }

    /* TODO: Check against Google Safe Browsing API (https://developers.google.com/safe-browsing/v4/lookup)
     For implementation, Heptagram already as a key to the api. I am having trouble getting it to work, so am looking for some help.
     See Lines 46-77 for the implementation I have so far.
    */

    /*
    const GOOGLE_SAFE_BROWSING_API_KEY = process.env.GOOGLE_SAFE_BROWSING_API_KEY;
    const checkGoogleSafeBrowsing = await axios.post(`https://safebrowsing.googleapis.com/v4/threatMatches:find?key=${GOOGLE_SAFE_BROWSING_API_KEY}`,
      {
        headers: {
          Accept: "application/json",
          ContentType: "application/json",
        },
        body: {
          "client": {
            "clientId": "yourcompanyname",
            "clientVersion": "1.5.2"
          },
          "threatInfo": {
            "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"],
            "platformTypes": ["WINDOWS"],
            "threatEntryTypes": ["URL"],
            "threatEntries": [
              { "url": "http://www.urltocheck1.org/" },
              { "url": "http://www.urltocheck2.org/" },
              { "url": "http://www.urltocheck3.com/" }
            ]
          }
        }
      }
    );

    if (checkGoogleSafeBrowsing.data.matches.length > 0) {
      return {
        scamDetected: true,
        source: "GoogleSafeBrowsing",
      };
    }
    */

    return {
      scamDetected: false,
      source: "",

Testing

I started implementing testing following this guide:
https://japa.dev
I would love for someone to finish it off.

API Metrics

Track things like

  • Users usage (by endpoint, overall, etc)
  • User approximate geolocation/region
  • Anything else is a bonus

ALL METRICS SHOULD ONLY BE ACCESSED BY ADMIN OR THE USER THAT THE DATA CORRESPONDS TO

Open Source Quotes

When a quote doesn't have author data, the response includes a request to email you if someone knows the author. Rather than an email based approach, why not open source the quotes?

The structure of the data is simple enough to be effective in a JSON object, can be hosted directly in the API files, and then you'd be able to accept contributions.

Could also consider this for your jokes data as well.

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.