mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
Merge pull request #14 from srgooglo/apiv3-model-nodecore
Apiv3 model nodecore
This commit is contained in:
commit
94fe497d69
96
.umirc.js
96
.umirc.js
@ -21,7 +21,7 @@ export default defineConfig({
|
||||
// },
|
||||
alias: {
|
||||
antd: resolve(__dirname, './node_modules/antd'),
|
||||
api: resolve(__dirname, './node_modules/@ragestudio/ycorejs-lib'), // ./api
|
||||
api: resolve(__dirname, './node_modules/@ragestudio/nodecore-api-lib/src'),
|
||||
plugins: resolve(__dirname, './plugins'),
|
||||
globals: resolve(__dirname, './globals'),
|
||||
core: resolve(__dirname, './src/core'),
|
||||
@ -42,72 +42,48 @@ export default defineConfig({
|
||||
'lodash',
|
||||
],
|
||||
],
|
||||
// externals(context, request, callback) {
|
||||
// const isDev = process.env.NODE_ENV === 'development';
|
||||
// let isExternal = false;
|
||||
// const load = [
|
||||
// 'electron',
|
||||
// 'fs',
|
||||
// 'path',
|
||||
// 'os',
|
||||
// 'child_process'
|
||||
// ];
|
||||
// if (load.includes(request)) {
|
||||
// isExternal = `require("${request}")`;
|
||||
// }
|
||||
// const appDeps = Object.keys(require('./package.json').dependencies);
|
||||
// if (appDeps.includes(request)) {
|
||||
// const orininalPath = slash(join(__dirname, 'node_modules', request));
|
||||
// const requireAbsolute = `require('${orininalPath}')`;
|
||||
// console.log(isDev)
|
||||
// isExternal = isDev ? requireAbsolute : `require('${request}')`;
|
||||
// }
|
||||
// callback(null, isExternal);
|
||||
// },
|
||||
// plugins: [themePlugin],
|
||||
|
||||
// chainWebpack: function(config, { webpack }) {
|
||||
// config.module
|
||||
// .rule('js-in-node_modules')
|
||||
// .exclude.add(/node_modules/)
|
||||
// .end()
|
||||
|
||||
// config.module
|
||||
// .rule('ts-in-node_modules')
|
||||
// .exclude.add(/node_modules/)
|
||||
// .end()
|
||||
|
||||
// config.merge({
|
||||
// optimization: {
|
||||
// minimize: true,
|
||||
// splitChunks: {
|
||||
// chunks: 'all',
|
||||
// minSize: 30000,
|
||||
// minChunks: 3,
|
||||
// automaticNameDelimiter: '.',
|
||||
// cacheGroups: {
|
||||
// react: {
|
||||
// name: 'react',
|
||||
// priority: 20,
|
||||
// test: /[\\/]node_modules[\\/](react|react-dom|react-dom-router)[\\/]/,
|
||||
// },
|
||||
// antd: {
|
||||
// name: 'antd',
|
||||
// priority: 20,
|
||||
// test: /[\\/]node_modules[\\/](antd|@ant-design\/icons)[\\/]/,
|
||||
// },
|
||||
// async: {
|
||||
// chunks: 'async',
|
||||
// minChunks: 2,
|
||||
// name: 'async',
|
||||
// maxInitialRequests: 1,
|
||||
// minSize: 0,
|
||||
// priority: 5,
|
||||
// reuseExistingChunk: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// config.merge({
|
||||
// optimization: {
|
||||
// minimize: true,
|
||||
// splitChunks: {
|
||||
// chunks: 'all',
|
||||
// minSize: 30000,
|
||||
// minChunks: 3,
|
||||
// automaticNameDelimiter: '.',
|
||||
// cacheGroups: {
|
||||
// react: {
|
||||
// name: 'react',
|
||||
// priority: 20,>
|
||||
// test: /[\\/]node_modules[\\/](react|react-dom|react-dom-router)[\\/]/,
|
||||
// },
|
||||
// antd: {
|
||||
// name: 'antd',
|
||||
// priority: 20,
|
||||
// test: /[\\/]node_modules[\\/](antd|@ant-design\/icons)[\\/]/,
|
||||
// },
|
||||
// async: {
|
||||
// chunks: 'async',
|
||||
// minChunks: 2,
|
||||
// name: 'async',
|
||||
// maxInitialRequests: 1,
|
||||
// minSize: 0,
|
||||
// priority: 5,
|
||||
// reuseExistingChunk: true,
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// },
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
16
package.json
16
package.json
@ -3,11 +3,11 @@
|
||||
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
||||
"title": "Comty™",
|
||||
"DevBuild": true,
|
||||
"version": "0.10.6",
|
||||
"version": "0.10.9",
|
||||
"stage": "dev",
|
||||
"description": "",
|
||||
"author": "RageStudio",
|
||||
"license": "ISC",
|
||||
"license": "LGPL-2.1",
|
||||
"private": true,
|
||||
"main": "main/index.js",
|
||||
"build": {
|
||||
@ -34,9 +34,7 @@
|
||||
"dependencies": {
|
||||
"@icons-pack/react-simple-icons": "^3.8.0",
|
||||
"@lingui/react": "^2.9.2",
|
||||
"@material-ui/core": "^4.9.9",
|
||||
"@material-ui/icons": "^4.9.1",
|
||||
"@ragestudio/ycorejs-lib": "^0.1.22",
|
||||
"@ragestudio/nodecore-api-lib": "^0.2.1",
|
||||
"antd": "^4.6.6",
|
||||
"axios": "^0.20.0",
|
||||
"babel-core": "^6.26.3",
|
||||
@ -47,7 +45,6 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"dva-model-enhance": "^1.2.13",
|
||||
"electron-config": "^2.0.0",
|
||||
"electron-context-menu": "^2.3.0",
|
||||
"electron-is": "^3.0.0",
|
||||
"electron-log": "^4.2.4",
|
||||
"electron-notification-state": "^1.0.4",
|
||||
@ -62,11 +59,9 @@
|
||||
"localforage": "^1.7.4",
|
||||
"lodash": "^4.17.19",
|
||||
"moment": "^2.28.0",
|
||||
"node-sass": "^4.14.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"path-to-regexp": "^6.1.0",
|
||||
"platform": "^1.3.6",
|
||||
"radium": "^0.26.0",
|
||||
"react": "^16.13.1",
|
||||
"react-animations": "^1.0.0",
|
||||
"react-color": "^2.18.1",
|
||||
@ -84,14 +79,11 @@
|
||||
"redux-socket.io": "^1.4.0",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"request": "^2.88.2",
|
||||
"requirejs": "^2.3.6",
|
||||
"simple-icons": "^3.8.0",
|
||||
"socket.io-client": "^2.3.0",
|
||||
"stack-trace": "0.0.10",
|
||||
"store": "^2.0.12",
|
||||
"styled-components": "^5.2.0",
|
||||
"timeago.js": "^4.0.2",
|
||||
"vm": "^0.1.0",
|
||||
"wait-on": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -119,6 +111,6 @@
|
||||
"less-loader": "^7.0.1",
|
||||
"style-loader": "^1.2.1",
|
||||
"typescript": "^3.8.3",
|
||||
"umi": "^3.2.22"
|
||||
"umi": "^3.2.23"
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import verbosity from 'core/libs/verbosity'
|
||||
import { connect } from 'umi'
|
||||
import classnames from 'classnames'
|
||||
import styles from './index.less'
|
||||
import * as errorhandler from 'core/libs/errorhandler'
|
||||
import ErrorHandler from 'core/libs/errorhandler'
|
||||
import * as antd from 'antd'
|
||||
import { router } from 'core/libs'
|
||||
import {
|
||||
@ -117,8 +117,7 @@ export default class Overlay extends React.PureComponent {
|
||||
return <Secondary {...renderProps} />
|
||||
}
|
||||
default:{
|
||||
verbosity(errorhandler.OVERLAY_BADPOSITION)
|
||||
return null
|
||||
return ErrorHandler({ code: 210 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import { cloneDeep } from 'lodash';
|
||||
import store from 'store';
|
||||
import { i18n, app_config } from 'config';
|
||||
import handle from 'core/libs/errorhandler'
|
||||
import platform from 'platform'
|
||||
import request from 'request'
|
||||
import html2canvas from 'html2canvas'
|
||||
import platform from 'platform'
|
||||
|
||||
const { pathToRegexp } = require('path-to-regexp');
|
||||
|
||||
|
@ -1,59 +1,25 @@
|
||||
import { lib, v3_request } from 'api';
|
||||
import endpoints_list from 'config/endpoints';
|
||||
import { app_config } from 'config';
|
||||
import v3_request from 'api/lib/v3_request'
|
||||
import endpointList from 'config/endpoints'
|
||||
import { app_config } from 'config'
|
||||
|
||||
const { api_prefix } = app_config;
|
||||
const { uri_resolver } = lib;
|
||||
|
||||
async function compileURI(e, callback) {
|
||||
const resolvers = await uri_resolver();
|
||||
const prefix = resolvers[api_prefix];
|
||||
|
||||
let final = null;
|
||||
let url;
|
||||
let method;
|
||||
const endpointSplit = e.split(' ');
|
||||
if (endpointSplit.length === 2) {
|
||||
method = endpointSplit[0];
|
||||
url = endpointSplit[1];
|
||||
url = prefix + url;
|
||||
return callback({ url, method });
|
||||
export async function api_request(payload, callback) {
|
||||
if (!payload) return false;
|
||||
const { endpoint, body, serverKey, userToken } = payload;
|
||||
|
||||
let petition = {
|
||||
prefix: api_prefix,
|
||||
endpointList,
|
||||
endpoint
|
||||
}
|
||||
|
||||
body ? (petition.body = body) : null;
|
||||
serverKey ? (petition.server_key = serverKey) : null;
|
||||
userToken ? (petition.access_token = userToken) : null;
|
||||
|
||||
Object.values(endpoints_list).find(item => {
|
||||
url = item;
|
||||
method = 'GET';
|
||||
const paramsArray = item.split(' ');
|
||||
if (paramsArray.length === 2) {
|
||||
method = paramsArray[0];
|
||||
url = paramsArray[1];
|
||||
}
|
||||
if (e === url) {
|
||||
url = prefix + url;
|
||||
return (final = { url, method });
|
||||
}
|
||||
});
|
||||
return callback(final);
|
||||
v3_request(petition, (...res) => {
|
||||
return callback(...res);
|
||||
})
|
||||
}
|
||||
|
||||
async function api_request(e, callback) {
|
||||
if (!e) return false;
|
||||
const { endpoint, body, serverKey, userToken, verbose } = e;
|
||||
|
||||
compileURI(endpoint, res => {
|
||||
let petition = {
|
||||
method: res.method,
|
||||
url: res.url,
|
||||
};
|
||||
body ? (petition.body = body) : null;
|
||||
serverKey ? (petition.server_key = serverKey) : null;
|
||||
userToken ? (petition.access_token = userToken) : null;
|
||||
|
||||
verbose ? console.log(`Requesting V3 =>`, petition) : null;
|
||||
v3_request(petition, (...res) => {
|
||||
return callback(...res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export { compileURI, api_request };
|
||||
|
@ -11,8 +11,7 @@ function auth(payload, callback) {
|
||||
{
|
||||
body: frame,
|
||||
endpoint: endpoints.auth,
|
||||
serverKey: server_key,
|
||||
verbose: true,
|
||||
serverKey: server_key
|
||||
},
|
||||
(err, res) => {
|
||||
return callback(err, res);
|
||||
@ -32,8 +31,7 @@ function deauth(payload, callback) {
|
||||
body: frame,
|
||||
endpoint: endpoints.sessions,
|
||||
serverKey: payload.server_key,
|
||||
userToken: payload.userToken,
|
||||
verbose: true,
|
||||
userToken: payload.userToken
|
||||
},
|
||||
(err, res) => {
|
||||
return callback(err, res);
|
||||
|
@ -24,8 +24,7 @@ export const get = {
|
||||
body: {user_id: id, fetch: req.fetch},
|
||||
serverKey: serverKey,
|
||||
userToken: access_token,
|
||||
endpoint: endpoints.get_data,
|
||||
verbose: true,
|
||||
endpoint: endpoints.get_data
|
||||
},
|
||||
(err, res) => {
|
||||
return callback(err, res)
|
||||
@ -49,8 +48,7 @@ export const get = {
|
||||
v3_model.api_request(
|
||||
{
|
||||
body: { username },
|
||||
endpoint: endpoints.basicData,
|
||||
verbose: true,
|
||||
endpoint: endpoints.basicData
|
||||
},
|
||||
(err, res) => {
|
||||
err? console.error(err) : null
|
||||
@ -74,7 +72,6 @@ export const get = {
|
||||
body: { username, fetch: "user_data" },
|
||||
endpoint: endpoints.profileData,
|
||||
userToken: access_token,
|
||||
verbose: true,
|
||||
serverKey: server_key
|
||||
},
|
||||
(err, res) => {
|
||||
|
@ -4,7 +4,7 @@ import keys from 'config/app_keys'
|
||||
import { user, session } from 'core/models'
|
||||
import { router, verbosity, appInterface } from 'core/libs'
|
||||
import settings from 'core/libs/settings'
|
||||
import { uri_resolver } from 'api/lib'
|
||||
import uri_resolver from 'api/lib/uri_resolver'
|
||||
import { queryIndexer } from 'core'
|
||||
|
||||
import jwt from 'jsonwebtoken'
|
||||
@ -161,6 +161,7 @@ export default {
|
||||
session.deauth({ id: uuid, userToken: token, server_key: sk }, (err, res) =>{
|
||||
verbosity(res)
|
||||
})
|
||||
|
||||
yield put({ type: 'sessionErase' })
|
||||
},
|
||||
*login({ payload }, { call, put, select }) {
|
||||
@ -404,7 +405,7 @@ export default {
|
||||
}
|
||||
if (res) {
|
||||
try {
|
||||
const session_data = JSON.stringify(JSON.parse(res)["user_data"])
|
||||
const session_data = JSON.stringify(res.user_data)
|
||||
sessionStorage.setItem(app_config.session_data_storage, btoa(session_data))
|
||||
location.reload()
|
||||
} catch (error) {
|
||||
|
@ -1,16 +1,8 @@
|
||||
import store from 'store'
|
||||
import { app_config } from 'config'
|
||||
import keys from 'config/app_keys'
|
||||
import { user, session } from 'core/models'
|
||||
import { router, verbosity, appInterface } from 'core/libs'
|
||||
import settings from 'core/libs/settings'
|
||||
import { uri_resolver } from 'api/lib'
|
||||
import { DynamicSDCP } from 'core/libs/extension'
|
||||
import { DynamicSDCP } from 'core/libs/dynamicsdcp'
|
||||
import * as core from 'core'
|
||||
|
||||
import jwt from 'jsonwebtoken'
|
||||
import cookie from 'cookie_js'
|
||||
|
||||
|
||||
export default {
|
||||
namespace: 'extended',
|
||||
|
@ -5,7 +5,7 @@ import keys from 'config/app_keys'
|
||||
import { user, session } from 'core/models'
|
||||
import { router, verbosity, appInterface } from 'core/libs'
|
||||
import settings from 'core/libs/settings'
|
||||
import { DynamicSDCP } from 'core/libs/extension'
|
||||
import { DynamicSDCP } from 'core/libs/dynamicsdcp'
|
||||
import * as core from 'core'
|
||||
|
||||
import jwt from 'jsonwebtoken'
|
||||
@ -39,7 +39,7 @@ export default {
|
||||
if (err) {
|
||||
return console.log(err)
|
||||
}
|
||||
const data = JSON.parse(res)["user_data"]
|
||||
const data = res.user_data
|
||||
const frame = {
|
||||
avatar: data.avatar,
|
||||
can_follow: data.can_follow,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from 'react'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { uri_resolver } from 'api/lib'
|
||||
import io from 'socket.io-client'
|
||||
import { connect } from 'umi'
|
||||
import * as antd from 'antd'
|
||||
|
@ -21,12 +21,11 @@ export default class Explore extends React.Component {
|
||||
body: {limit: settings("post_catchlimit"), type: "get_news_feed"},
|
||||
serverKey: this.props.app.server_key,
|
||||
userToken: this.props.app.session_token,
|
||||
endpoint: endpoints.posts,
|
||||
verbose: true,
|
||||
endpoint: endpoints.posts
|
||||
},
|
||||
(err, res) => {
|
||||
try {
|
||||
this.setState({ feed: JSON.parse(res)['data'] })
|
||||
this.setState({ feed: res.data })
|
||||
} catch (error) {
|
||||
// terrible (⓿_⓿)
|
||||
}
|
||||
|
@ -40,19 +40,17 @@ export class NormalLoginForm extends React.PureComponent {
|
||||
user.get.basicData(payload, (err, res) => {
|
||||
if (err || !res) return false
|
||||
try {
|
||||
const res_data = JSON.parse(res)
|
||||
|
||||
if (res_data.api_status == 200) {
|
||||
if (res.api_status == 200) {
|
||||
a++
|
||||
this.anim_transition(300)
|
||||
this.setState({
|
||||
step_error: false,
|
||||
early_data: res_data.data,
|
||||
early_data: res.data,
|
||||
form_rawd_1: b,
|
||||
step: a,
|
||||
})
|
||||
}
|
||||
if (res_data.api_status == 400) {
|
||||
if (res.api_status == 400) {
|
||||
this.anim_error()
|
||||
}
|
||||
} catch (error) {
|
||||
@ -103,12 +101,7 @@ export class NormalLoginForm extends React.PureComponent {
|
||||
|
||||
}
|
||||
if (res) {
|
||||
try {
|
||||
res = JSON.parse(res)
|
||||
verbosity(res)
|
||||
} catch (error) {
|
||||
console.log('Invalid response!')
|
||||
}
|
||||
verbosity(res)
|
||||
|
||||
switch (res.api_status.toString()) {
|
||||
case "200": {
|
||||
@ -149,7 +142,7 @@ export class NormalLoginForm extends React.PureComponent {
|
||||
}
|
||||
if (res) {
|
||||
try {
|
||||
return resolve(JSON.stringify(JSON.parse(res)['user_data']))
|
||||
return resolve(JSON.stringify(res.user_data))
|
||||
} catch (error) {
|
||||
verbosity(error)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user