Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspector #254

Merged
merged 3 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 29 additions & 23 deletions cli/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions cli/contrib.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

/* This file handles third party contributions and libraries.*/
/*This file handles third party contributions and libraries.*/
package main

import (
Expand All @@ -12,16 +12,17 @@ import (
"github.com/gin-gonic/gin"
)

// GET /datasets
// GetAllDatasets GET /datasets
func GetAllDatasets(c *gin.Context) {
c.JSON(http.StatusOK, dataset.FetchAllDatasets())
}

// AddRegistryRequest Definition for AddRegistryRequest
type AddRegistryRequest struct {
URL string `json:"url"`
}

// POST /datasets/registry
// AddNewRegistry POST /datasets/registry
func AddNewRegistry(c *gin.Context) {
var addRegistryRequest AddRegistryRequest
c.BindJSON(&addRegistryRequest)
Expand Down
22 changes: 17 additions & 5 deletions cli/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ You can uninstall that service by using cvpm daemon uninstall */
package main

import (
"fmt"
"log"
"net/http"
"net/http/httputil"
Expand All @@ -22,7 +23,7 @@ import (
"github.com/hpcloud/tail"
)

// Default Running Port
// DaemonPort Default Running Port
const DaemonPort = "10590"

// Definition of Running Repos
Expand Down Expand Up @@ -95,29 +96,35 @@ func PostReposHandler(c *gin.Context) {
}
}

// GET /repos -> return all repositories
// GetReposHandler : GET /repos -> return all repositories
func GetReposHandler(c *gin.Context) {
config := readConfig()
c.JSON(http.StatusOK, config.Repositories)
}

// GET /repo/meta/:vendor/:name -> return repository meta info
// GetRepoMetaHandler : GET /repo/meta/:vendor/:name -> return repository meta info
func GetRepoMetaHandler(c *gin.Context) {
vendor := c.Param("vendor")
name := c.Param("name")
c.JSON(http.StatusOK, GetMetaInfo(vendor, name))
}

// GET /system -> return system info
// GetSystemHandler : GET /system -> return system info
func GetSystemHandler(c *gin.Context) {
c.JSON(http.StatusOK, getSystemInfo())
}

// Handle Socket Request
func socketHandler(c *gin.Context) {
socketServer.OnConnect("/", func(so socketio.Conn) error {
// so.J
return nil
})
/* Todo: Upgrade to v1.4 of go-socket.io
socketServer.On("connection", func(so socketio.Socket) {
so.Join("cvpm-webtail")
})
*/
socketServer.ServeHTTP(c.Writer, c.Request)
}

Expand All @@ -130,7 +137,12 @@ func writeLog(filepath string, server *socketio.Server, eventName string) {
panic(err)
}
for line := range t.Lines {
server.BroadcastTo("cvpm-webtail", eventName, line.Text)
/* Todo: Upgrade to v1.4 of go-socket.io

// server.BroadcastTo("cvpm-webtail", eventName, line.Text)
// server.
*/
fmt.Println(line)
}
}

Expand Down
8 changes: 4 additions & 4 deletions cli/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2019 The CVPM Authors. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

/*
Package CVPM (main) implements the CLI for CVPM.
To get started, use:
Expand All @@ -6,10 +10,6 @@ cvpm help

to get a detailed explanation.
*/
// Copyright 2019 The CVPM Authors. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package main

import (
Expand Down
5 changes: 5 additions & 0 deletions cli/virtual.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2019 The CVPM Authors. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.

package main
7 changes: 3 additions & 4 deletions discovery/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "The CVTron Discovery Service in Node",
"main": "index.js",
"scripts": {
"dev": "nodemon --watch 'src/**/*' -e ts,tsx --exec 'ts-node' ./src/server.ts",
"test": "cross-env PROJECT_ENV=testing jest --coverage --forceExit --config jest-config.json",
"test:watch": "cross-env PROJECT_ENV=testing jest --watch",
"build": "tslint --project . --fix && tsc",
Expand All @@ -16,6 +17,7 @@
"@aws/dynamodb-data-mapper": "^0.7.3",
"@aws/dynamodb-data-mapper-annotations": "^0.7.3",
"@koa/cors": "^2.2.2",
"@sentry/node": "4.6.4",
"@types/koa": "^2.0.47",
"@types/koa-helmet": "^3.1.2",
"@types/koa-passport": "^4.0.2",
Expand All @@ -25,7 +27,6 @@
"@types/parse": "^2.1.0",
"@types/passport": "^1.0.0",
"@types/stripe": "^6.19.7",
"@types/winston": "^2.4.4",
"aws-sdk": "^2.362.0",
"axios": "^0.18.0",
"dotenv": "^6.1.0",
Expand All @@ -40,9 +41,7 @@
"parse": "^2.1.0",
"passport": "^0.4.0",
"passport-cognito": "^0.1.13",
"stripe": "^6.25.1",
"winston": "^3.1.0",
"winston-logsene": "^2.0.2"
"stripe": "^6.25.1"
},
"devDependencies": {
"@types/dotenv": "6.1.0",
Expand Down
4 changes: 3 additions & 1 deletion discovery/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IConfig {
cognitoClientId: string;
cognitoRegion: string;
stripe: string;
sentryDSN: string;
}

const config: IConfig = {
Expand All @@ -23,7 +24,8 @@ const config: IConfig = {
cognitoPoolId: process.env.COGNITO_POOL_ID || '',
cognitoClientId: process.env.COGNITO_CLIENT_ID || '',
cognitoRegion: process.env.COGNITO_REGION || '',
stripe: process.env.stripeID || '',
stripe: process.env.STRIPEID || '',
sentryDSN: process.env.SENTRYDSN || '',
};

export { config };
3 changes: 2 additions & 1 deletion discovery/src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export { default as pretrained } from './pretrained';
export { default as registry } from './registry';
export { default as news } from './news';
export { default as user } from './user';
export { default as ticket } from './ticket'
export { default as ticket } from './ticket';
export { default as paywall } from './paywall';
14 changes: 13 additions & 1 deletion discovery/src/controller/paywall.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
import { BaseContext } from 'koa';
import { config } from '../config';
import paymentService from '../service/payment'

export default class PaywallController {
public static async createCustomer (ctx: BaseContext) {
const requestbody = ctx.request.body
const customer = await paymentService.createCustomer(requestbody.email)
ctx.status = 200;
ctx.body = {
'code': 200,
'results': 'success',
'customer': customer
};
}
}