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

Code quality review edit #80

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ $ yarn start <command>

_clocal-gcp_ spins up the following core Cloud APIs on your local machine:

* **Cloud Functions** at http://localhost:7574
* **Cloud Data Store** at http://localhost:7569
* **Cloud CDN** at http://localhost:7581
* **Cloud ENDPOINTS** at http://localhost:7567
* **Cloud Storage** at http://localhost:7572
* **Cloud Functions** at [http://localhost:7574](https://)
* **Cloud Data Store** at [http://localhost:7569](https://)
* **Cloud CDN** at [http://localhost:7581](https://)
* **Cloud ENDPOINTS** at [http://localhost:7567](https://)
* **Cloud Storage** at [http://localhost:7572](https://)
12 changes: 6 additions & 6 deletions examples/cloud-data-storage-client-poc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
* Before running this file make sure GOOGLE_APPLICATION_CREDENTIALS variable is set
*/

const Storage = require('@google-cloud/storage');
const Storage = require("@google-cloud/storage");
const gcs = new Storage();

gcs.interceptors.push({
request: reqOpts => {
request: (reqOpts) => {
reqOpts.uri = reqOpts.uri.replace(
'https://www.googleapis.com',
'http://localhost:8080'
"https://www.googleapis.com",
"http://localhost:8080"
);
// console.log(JSON.stringify(reqOpts));
return reqOpts;
},
});

gcs
.createBucket('test-bucket')
.createBucket("test-bucket")
.then(async res => {
try {
const bucketList = await gcs.getBuckets();

const bucket = await gcs.bucket('test-bucket').get();
const bucket = await gcs.bucket("test-bucket").get();

// this endpoint doesn't work correctly
// const uploadRes = await gcs.bucket('test-bucket').upload('./test.txt');
Expand Down
26 changes: 14 additions & 12 deletions examples/cloud-memory-store/create.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
var request = require('request');
var request = require("request");

var options = {
method: 'POST',
url: 'http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1',
qs: { instanceId: 'redisTest123' },
method: "POST",
url: "http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1",
qs: { instanceId: "redisTest123" },
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
"Cache-Control": "no-cache",
"Content-Type": "application/json",
},
body: {
name: 'redisTest',
displayName: 'Redis Test',
locationId: 'us-east-1',
redisConfigs: { test: 'test' },
tier: 'free',
name: "redisTest",
displayName: "Redis Test",
locationId: "us-east-1",
redisConfigs: { test: "test" },
tier: "free",
},
json: true,
};

request(options, function(error, response, body) {
if (error) throw new Error(error);
if (error){
throw new Error(error);
}

console.log(body);
});
12 changes: 7 additions & 5 deletions examples/cloud-memory-store/get.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
var request = require('request');
var request = require("request");

var options = {
method: 'GET',
method: "GET",
url:
'http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1/instances/redisTest123',
"http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1/instances/redisTest123",
headers: {
'Cache-Control': 'no-cache',
"Cache-Control": "no-cache",
},
};

request(options, function(error, response, body) {
if (error) throw new Error(error);
if (error){
throw new Error(error);
}

console.log(body);
});
12 changes: 7 additions & 5 deletions examples/cloud-memory-store/list.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
var request = require('request');
var request = require("request");

var options = {
method: 'GET',
url: 'http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1',
method: "GET",
url: "http://localhost:7070/v1beta1/projects/testProject/locations/us-east-1",
headers: {
'Cache-Control': 'no-cache',
"Cache-Control": "no-cache",
},
};

request(options, function(error, response, body) {
if (error) throw new Error(error);
if (error){
throw new Error(error);
}

console.log(body);
});
6 changes: 3 additions & 3 deletions src/services/cloud-memory-store/cloud-local.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
"use strict";

const express = require('express');
const express = require("express");

class CloudLocal {
constructor() {
Expand All @@ -10,7 +10,7 @@ class CloudLocal {

start() {
if (!this.port) {
throw new Error('Port is not assigned');
throw new Error("Port is not assigned");
}

return (this.server = this.app.listen(this.port));
Expand Down
12 changes: 6 additions & 6 deletions src/services/cloud-memory-store/cloud-memory-store.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
"use strict";

const CloudLocal = require('./cloud-local');
const bodyParser = require('body-parser');
const MemoryStore = require('./memory-store');
const CloudLocal = require("./cloud-local");
const bodyParser = require("body-parser");
const MemoryStore = require("./memory-store");

class CloudMemoryStore extends CloudLocal {
init() {
Expand Down Expand Up @@ -33,9 +33,9 @@ class CloudMemoryStore extends CloudLocal {
this._listInstances
)

.all('*', (req, res) => {
.all("*", (req, res) => {
console.log(req.url);
res.send('Endpoint not found');
res.send("Endpoint not found");
});
}

Expand Down
Loading