Aruppi start to powers!

pull/1/head
Jéluchu 5 years ago
parent a0c18737d3
commit 32b46fe7a6

@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

@ -0,0 +1,24 @@
name: Node.js CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build --if-present
- run: npm test
env:
CI: true

193
.gitignore vendored

@ -0,0 +1,193 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# exclude apidocs
animeflv-docs/
.idea/

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Jéluchu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,4 @@
#! /bin/bash
git log --oneline --all --graph --decorate $(git reflog | awk '{print $1}')

@ -0,0 +1,13 @@
{
"name": "aruppi",
"version": 2,
"builds": [
{
"src": "./src/index.js",
"use": "@now/node-server"
}
],
"routes": [
{ "src": "/(.*)", "dest": "/src/index.js" }
]
}

4281
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,58 @@
{
"name": "aruppi",
"version": "1.0.0",
"description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app",
"main": "./src/api/api.js",
"scripts": {
"start": "node src/index.js"
},
"keywords": [
"aruppi",
"aruppi api",
"aruppi app",
"aruppi android"
],
"author": {
"name": "Jéluchu",
"email": "infoaruppi@gmail.com",
"reason": "Android Developer and Others",
"url": "https://jeluchu.github.io/",
"social": {
"github": "https://github.com/Jeluchu",
"twitter": "https://twitter.com/Jeluchu"
}
},
"contributors": [
{
"name": "Darkangeel",
"url": "https://github.com/Darkangeel-hd",
"reason": "System administration authority (SYSADM)"
}
],
"engines": {
"node": ">= 10.16.x",
"npm": ">= 6.9.x"
},
"bugs": {
"url": "https://github.com/aruppi/aruppi-api/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/aruppi/aruppi-api.git"
},
"dependencies": {
"body-parser": "^1.19.0",
"cheerio": "^1.0.0-rc.3",
"cheerio-tableparser": "^1.0.1",
"cloudscraper": "^4.6.0",
"compose-middleware": "^5.0.1",
"cors": "^2.8.5",
"express": "^4.16.4",
"helmet": "^3.22.0",
"image-to-base64": "^2.1.0",
"morgan": "^1.10.0",
"node-fetch": "^2.6.0",
"npm": "^6.14.5",
"request": "^2.88.0"
}
}

@ -0,0 +1,65 @@
const cheerio = require('cheerio');
const cheerioTableparser = require('cheerio-tableparser');
const cloudscraper = require('cloudscraper');
const {
BASE_ANIMEFLV , BASE_JIKAN
} = require('./urls');
const schedule = async (day) =>{
const data = await cloudscraper.get(`${BASE_JIKAN}schedule/${day}`);
let body = "";
switch (day) {
case "monday":
body = JSON.parse(data).monday;
break;
case "tuesday":
body = JSON.parse(data).tuesday;
break;
case "wednesday":
body = JSON.parse(data).wednesday;
break;
case "thursday":
body = JSON.parse(data).thursday;
break;
case "friday":
body = JSON.parse(data).friday;
break;
case "saturday":
body = JSON.parse(data).saturday;
break;
case "sunday":
body = JSON.parse(data).sunday;
break;
default:
body = JSON.parse(data).monday;
}
return Promise.all(body);
};
const top = async (type, subtype, page) =>{
const data = await cloudscraper.get(`${BASE_JIKAN}top/${type}/${page}/${subtype}`);
let body = JSON.parse(data).top;
return Promise.all(body);
};
const getAllAnimes = async () =>{
const data = await cloudscraper.get(`${BASE_ANIMEFLV}api/animes/list`);
let body = JSON.parse(data);
return Promise.all(body);
};
module.exports = {
schedule,
top,
getAllAnimes
};

@ -0,0 +1,24 @@
const express = require('express');
const routes = require('./routes/index');
const router = express.Router();
router.get('/', (req, res) => {
res.json({
message: 'Aruppi API - 🎏',
author: 'Jéluchu',
version: '1.0.0',
credits: 'The bitch loves APIs that offers data to Aruppi App',
entries: [
{
'Schedule': '/api/v1/schedule/:id',
'Top': '/top/:type/:subtype/:page',
'GetAllAnimes': '/getAllAnimes'
}
]
});
});
router.use('/', routes);
module.exports = router;

@ -0,0 +1,50 @@
const express = require('express');
const router = express.Router();
const api = require('../api');
router.get('/schedule/:day' , (req, res) =>{
let day = req.params.day;
api.schedule(day)
.then(day =>{
res.status(200).json({
day
});
}).catch((err) =>{
console.error(err);
});
});
router.get('/top/:type/:subtype/:page' , (req, res) =>{
let type = req.params.type;
let subtype = req.params.subtype;
let page = req.params.page;
api.top(type, subtype, page)
.then(top =>{
res.status(200).json({
top
});
}).catch((err) =>{
console.error(err);
});
});
router.get('/getAllAnimes' , (req, res) =>{
api.getAllAnimes()
.then(animes =>{
res.status(200).json({
animes
});
}).catch((err) =>{
console.error(err);
});
});
module.exports = router;

@ -0,0 +1,10 @@
module.exports = {
BASE_ANIMEFLV: 'https://animeflv.net/',
BASE_JIKAN: 'https://dev.aruppi.jeluchu.xyz/apis/jikan/v3/',
BROWSE_URL: 'https://animeflv.net/browse?',
SEARCH_URL: 'https://animeflv.net/browse?q=',
ANIME_VIDEO_URL: 'https://animeflv.net/ver/',
BASE_EPISODE_IMG_URL: 'https://cdn.animeflv.net/screenshots/',
BASE_JIKA_URL: 'http://devel.jeluchu.xyz/apis/jikan/v3/search/anime?q=',
BASE_MYANIME_LIST_URL : 'https://myanimelist.net/character/'
};

@ -0,0 +1,29 @@
const express = require('express');
const morgan = require('morgan');
const helmet = require('helmet');
const cors = require('cors');
const bodyParser = require('body-parser');
const middlewares = require('./middlewares/index').middleware;
const api = require('./api');
const app = express();
app.use(morgan('dev'));
app.use(helmet());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.get('/', (req, res) => {
res.json({
message: '🦄🌈✨👋🌎🌍🌏✨🌈🦄'
});
});
app.use('/api/v2', api);
app.use(middlewares);
module.exports = app;

@ -0,0 +1,8 @@
const app = require('./app');
const port = process.env.PORT || 5000;
app.listen(port, () => {
/* eslint-disable no-console */
console.log(`\n🚀 ... Listening: http://localhost:${port}`);
/* eslint-enable no-console */
});

@ -0,0 +1,12 @@
const compose = require('compose-middleware').compose;
const {errorHandler , notFound , requestLoggerMiddleware} = require('./middlewares');
const middleware = compose([
notFound,
errorHandler,
requestLoggerMiddleware
]);
module.exports = {
middleware
};

@ -0,0 +1,32 @@
const notFound = (req, res, next) => {
res.status(404);
const error = new Error(`🔍 - Not Found - ${req.originalUrl}`);
next(error);
};
/* eslint-disable no-unused-vars */
const errorHandler = (err, req, res, next) => {
/* eslint-enable no-unused-vars */
const statusCode = res.statusCode !== 200 ? res.statusCode : 500;
res.status(statusCode);
res.json({
message: err.message,
stack: process.env.NODE_ENV === 'production' ? '🥞' : err.stack
});
};
const requestLoggerMiddleware = (req, res, next) => {
console.log(`${req.method} ${req.originalUrl}`);
const start = new Date().getTime();
res.on('finish', () => {
const elapsed = new Date().getTime() - start;
console.info(`${req.method} ${req.originalUrl} ${req.statusCode} ${elapsed}ms`);
});
next();
};
module.exports = {
notFound,
errorHandler,
requestLoggerMiddleware
};

@ -0,0 +1,46 @@
const cloudscraper = require('cloudscraper')
const imageToBase64 = require("image-to-base64");
const MergeRecursive = (obj1 , obj2) => {
for(var p in obj2) {
try{
// Property in destination object set; update its value.
if(obj2[p].constructor == Object){
obj1[p] = MergeRecursive(obj1[p], obj2[p]);
}else{
obj1[p] = obj2[p];
}
}catch(e){
// Property in destination object not set; create it and set its value.
obj1[p] = obj2[p];
}
}
return obj1;
}
const imageUrlToBase64 = async(url) => {
let res = await cloudscraper({
url,
method: "GET",
encoding: null
});
return Buffer.from(res).toString("base64");
};
const urlify = async(text) =>{
const urls = [];
const urlRegex = /(https?:\/\/[^\s]+)/g;
text.replace(urlRegex , (url) =>{
urls.push(url)
});
return Promise.all(urls);
};
module.exports = {
MergeRecursive,
imageUrlToBase64,
urlify,
decodeZippyURL
}
Loading…
Cancel
Save