Skip to content

Commit

Permalink
Disable some services
Browse files Browse the repository at this point in the history
  • Loading branch information
duyet committed Sep 8, 2019
1 parent e2cda5e commit d48176d
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 6 deletions.
2 changes: 1 addition & 1 deletion functions/config/adayroi.com.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
color: '#189eff',
logo: 'https://i.imgur.com/e6AX9Lb.png',
time_check: 15,
active: true,
active: false,

// Get {productId} and {shopId}
// https://www.adayroi.com/vsmart-active-1-6gb-64gb-den-p-2087332
Expand Down
2 changes: 1 addition & 1 deletion functions/config/lotte.vn.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
color: '#f2655c',
logo: 'https://i.imgur.com/IKaf79s.png',
time_check: 15,
active: true,
active: false,

// Get {productId} and {shopId}
productId: u => regexProcess(u, /\/product\/([0-9]+)\//, 1),
Expand Down
2 changes: 1 addition & 1 deletion functions/config/vinabook.com.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = {
color: '#007c36',
logo: 'https://www.vinabook.com/images/thumbnails/img/252/33/vnb_logo_2x.png',
time_check: 15,
active: true,
active: false,

// Get {productId} and {shopId}
// https://www.vinabook.com/leonardo-da-vinci-1-p85106.html
Expand Down
2 changes: 1 addition & 1 deletion functions/modules/pullData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = functions
.region(asiaRegion)
.runWith({
memory: '512MB',
timeoutSeconds: 60
timeoutSeconds: 30
})
.https
.onRequest(async (req, res) => {
Expand Down
5 changes: 5 additions & 0 deletions functions/utils/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const pullProductDataFromUrl = async (u) => {
if (supportedDomain.indexOf(provider) === -1) return null

try {
let rule = parseRules[provider]
if (!rule.active) {
console.info(`${provider} is disabled!`)
return null;
}
return await parseUrlWithConfig(u, parseRules[provider])
} catch (err) {
console.error(err)
Expand Down
8 changes: 8 additions & 0 deletions hosting/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GATSBY_API_KEY=
GATSBY_AUTH_DOMAIN=duyet-price-tracker.firebaseapp.com
GATSBY_DATABASE_URL=https://duyet-price-tracker.firebaseio.com
GATSBY_PROJECT_ID=duyet-price-tracker
GATSBY_STORAGE_BUCKET=duyet-price-tracker.appspot.com
GATSBY_MESSAGING_SENDER_ID=
GATSBY_VAPID_KEY=
GATSBY_APPID=
4 changes: 2 additions & 2 deletions hosting/src/pages/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import HeadSlogan from "../components/Block/HeadSlogan";
*/

export default class IndexComponent extends Component {
about_image = '//images.unsplash.com/photo-1533727352519-7553fbcbf061?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=900&q=80'
about_image_credit = 'Photo by Alvaro Reyes on Unsplash'
about_image = '//i.imgur.com/FgA3sgu.png'
about_image_credit = ''

render() {
return (
Expand Down
61 changes: 61 additions & 0 deletions hosting/src/pages/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { PureComponent } from "react"
import axios from "axios"
import { loadProgressBar } from 'axios-progress-bar'
import 'axios-progress-bar/dist/nprogress.css'

import Layout from "../components/layout"
import { withAuthentication, AuthUserContext } from '../components/Session'

import HeadSlogan from "../components/Block/HeadSlogan";

loadProgressBar()

class Box extends PureComponent {
render() {
return JSON.stringify(this.props.location)
}
}

class QuickAddComponent extends PureComponent {
_mounted = true
constructor(props) {
super(props)
this.state = {
url: null,
loading: false,
error: false,
}
}

async componentDidMount() {
this._mounted = true
}

_setState(state) {
if (this._mounted) this.setState(state)
}

componentWillUnmount() {
this._mounted = false
}

render() {
let { location } = this.props
return (
<Layout>
<div className="d-flex align-items-center p-3 my-3 text-white-50 rounded shadow-sm" style={{background: '#03A9F4'}}>
<HeadSlogan />
</div>
<Box location={location}/>
</Layout>
)
}
}

const IndexWithContext = (props) => {
return <AuthUserContext.Consumer>
{authUser => <QuickAddComponent authUser={authUser} {...props} />}
</AuthUserContext.Consumer>
}

export default withAuthentication(IndexWithContext)

0 comments on commit d48176d

Please sign in to comment.