-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dde6256
commit 4d27c3a
Showing
15 changed files
with
173 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare namespace NodeJS { | ||
export interface ProcessEnv { | ||
PROJECT_ID: string; | ||
DATASTORE_EMULATOR_HOST: string; | ||
DATASTORE_BACKUP_BUCKET: string; | ||
DATASTORE_BACKUP_DIR: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
declare type Env = { | ||
export declare type Env = { | ||
DATASTORE_EMULATOR_HOST: string; | ||
DATASTORE_BACKUP_BUCKET: string; | ||
DATASTORE_BACKUP_DIR: string; | ||
PROJECT_ID: string; | ||
DATASTORE_EMULATOR_PORT: number; | ||
DATASTORE_PROJECT_URL: string; | ||
}; | ||
declare const env: Env; | ||
export default env; | ||
declare function getEnv(): Env; | ||
export default getEnv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("dotenv").config(); | ||
const { DATASTORE_EMULATOR_HOST, DATASTORE_BACKUP_BUCKET, PROJECT_ID, DATASTORE_BACKUP_DIR, } = process.env; | ||
const DATASTORE_EMULATOR_PORT = Number(DATASTORE_EMULATOR_HOST.match(/\d+/)[0]); | ||
const DATASTORE_PROJECT_URL = `${DATASTORE_EMULATOR_HOST}/v1/projects/${PROJECT_ID}`; | ||
const env = { | ||
DATASTORE_EMULATOR_HOST: DATASTORE_EMULATOR_HOST, | ||
DATASTORE_BACKUP_BUCKET: DATASTORE_BACKUP_BUCKET, | ||
DATASTORE_BACKUP_DIR: DATASTORE_BACKUP_DIR, | ||
PROJECT_ID: PROJECT_ID, | ||
DATASTORE_EMULATOR_PORT: DATASTORE_EMULATOR_PORT, | ||
DATASTORE_PROJECT_URL: DATASTORE_PROJECT_URL, | ||
}; | ||
for (const key in env) { | ||
const typedKey = key; | ||
const element = env[typedKey]; | ||
if (element) { | ||
console.log("✅", key, element); | ||
} | ||
else { | ||
console.log("❌", key, element); | ||
function getEnv() { | ||
const { DATASTORE_EMULATOR_HOST = '', DATASTORE_BACKUP_BUCKET = '', PROJECT_ID = '', DATASTORE_BACKUP_DIR = '', } = process.env; | ||
const DATASTORE_EMULATOR_HOST_MATCHES = DATASTORE_EMULATOR_HOST.match(/\d+/); | ||
const DATASTORE_EMULATOR_PORT = Number(DATASTORE_EMULATOR_HOST_MATCHES ? DATASTORE_EMULATOR_HOST_MATCHES[0] : 0); | ||
const DATASTORE_PROJECT_URL = `${DATASTORE_EMULATOR_HOST}/v1/projects/${PROJECT_ID}`; | ||
const env = { | ||
DATASTORE_EMULATOR_HOST: DATASTORE_EMULATOR_HOST, | ||
DATASTORE_BACKUP_BUCKET: DATASTORE_BACKUP_BUCKET, | ||
DATASTORE_BACKUP_DIR: DATASTORE_BACKUP_DIR, | ||
PROJECT_ID: PROJECT_ID, | ||
DATASTORE_EMULATOR_PORT: DATASTORE_EMULATOR_PORT, | ||
DATASTORE_PROJECT_URL: DATASTORE_PROJECT_URL, | ||
}; | ||
for (const key in env) { | ||
const typedKey = key; | ||
const element = env[typedKey]; | ||
if (element) { | ||
console.log("✅", key, element); | ||
} | ||
else { | ||
console.log("❌", key, element); | ||
} | ||
} | ||
return env; | ||
} | ||
exports.default = env; | ||
exports.default = getEnv; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { DatastoreBackup } from "./types"; | ||
import { Context } from "../../types"; | ||
declare class GsUtilResolver { | ||
getProjectId(): Promise<string>; | ||
getBackups(): Promise<DatastoreBackup[]>; | ||
startBackup(): Promise<string>; | ||
downloadBackup(name: string): Promise<string>; | ||
importBackup(name: string): Promise<string>; | ||
getProjectId({ env }: Context): Promise<string>; | ||
getBackups({ env }: Context): Promise<DatastoreBackup[]>; | ||
startBackup({ env }: Context): Promise<string>; | ||
downloadBackup(name: string, { env }: Context): Promise<string>; | ||
importBackup(name: string, { env }: Context): Promise<string>; | ||
} | ||
export default GsUtilResolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { Datastore } from "@google-cloud/datastore"; | ||
import type { Datastore } from "@google-cloud/datastore"; | ||
import type { Env } from "../env"; | ||
export declare type Context = { | ||
datastore: Datastore; | ||
env: Env; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.