Просмотр исходного кода

Merge pull request #28 from porter-dev/login-integration

delete node server
abelanger5 5 лет назад
Родитель
Сommit
82c536ebdc
3 измененных файлов с 4 добавлено и 34 удалено
  1. 0 1
      dashboard/package.json
  2. 0 25
      dashboard/server.js
  3. 4 8
      dashboard/src/shared/baseApi.tsx

+ 0 - 1
dashboard/package.json

@@ -2,7 +2,6 @@
   "name": "dashboard",
   "version": "0.1.0",
   "private": true,
-  "proxy": "http://localhost:5000",
   "dependencies": {
     "@testing-library/jest-dom": "^4.2.4",
     "@testing-library/react": "^9.3.2",

+ 0 - 25
dashboard/server.js

@@ -1,25 +0,0 @@
-var express = require('express')
-var path = require('path');
-var bodyParser = require('body-parser')
-
-const app = express();
-
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: true }));
-app.use(express.static(path.join(__dirname, 'build')))
-
-// app.get('/auth/check', (req, res) => {
-//     if (req.cookie) {
-//         return true
-//     } else {
-//         return false
-//     }
-// })
-
-app.get('/*', (req, res) => {
-    res.sendFile(path.join(__dirname, 'build', 'index.html'))
-})
-
-app.listen(5000, () => {
-    console.log('ok')
-})

+ 4 - 8
dashboard/src/shared/baseApi.tsx

@@ -1,12 +1,8 @@
 import axios from 'axios';
 
 // Partial function that accepts a generic params type and returns an api method
-export const baseApi = <T extends {}, S = {}>(requestType: string, endpoint: ((pathParams: S) => string) | string, baseUrlOverride?: string) => {
+export const baseApi = <T extends {}, S = {}>(requestType: string, endpoint: ((pathParams: S) => string) | string) => {
   return (token: string, params: T, pathParams: S, callback?: (err: any, res: any) => void) => {
-    let baseUrl = (process as any).env.API_SERVER;
-    if (baseUrlOverride) {
-      baseUrl = baseUrlOverride;
-    }
 
     // Generate endpoint literal
     let endpointString: ((pathParams: S) => string) | string;
@@ -18,7 +14,7 @@ export const baseApi = <T extends {}, S = {}>(requestType: string, endpoint: ((p
 
     // Handle request type (can refactor)
     if (requestType === 'POST') {
-      axios.post(`http://${baseUrl + endpointString}`, params, {
+      axios.post(endpointString, params, {
       headers: {
           Authorization: `Bearer ${token}`
         }
@@ -30,7 +26,7 @@ export const baseApi = <T extends {}, S = {}>(requestType: string, endpoint: ((p
         callback && callback(err, null);
       });
     } else if (requestType === 'PUT') {
-      axios.put(`http://${baseUrl + endpointString}`, params, {
+      axios.put(endpointString, params, {
         headers: {
           Authorization: `Bearer ${token}`
         }
@@ -42,7 +38,7 @@ export const baseApi = <T extends {}, S = {}>(requestType: string, endpoint: ((p
         callback && callback(err, null);
       });
     } else {
-      axios.get(`http://${baseUrl + endpointString}`, {
+      axios.get(endpointString, {
         withCredentials: true,
         params
       })