Skip to content

Commit

Permalink
feat: updates import resolution
Browse files Browse the repository at this point in the history
Updates import resolution to use ES6-style imports and Typescript import/export helpers.

Signed-off-by: Rifa Achrinza <[email protected]>
  • Loading branch information
achrinza committed Apr 10, 2020
1 parent d4737ff commit b10c332
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 31 deletions.
2 changes: 1 addition & 1 deletion functions/src/config.example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import FunctionConfig from "./opentrace/types/FunctionConfig";
import {FunctionConfig} from "./opentrace/types/FunctionConfig";
import Authenticator from "./opentrace/utils/Authenticator";
import PinGenerator from "./opentrace/utils/PinGenerator";

Expand Down
2 changes: 1 addition & 1 deletion functions/src/firebaseFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as functions from "firebase-functions";
import functions from "firebase-functions";

import config from "./config";

Expand Down
2 changes: 1 addition & 1 deletion functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
admin.initializeApp();

import * as firebaseFunctions from "./firebaseFunctions";
Expand Down
3 changes: 1 addition & 2 deletions functions/src/opentrace/getHandshakePin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as functions from "firebase-functions";

import functions from "firebase-functions";
import config from "../config";

/**
Expand Down
2 changes: 1 addition & 1 deletion functions/src/opentrace/getTempIDs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as moment from "moment";
import moment from "moment";

import config from "../config";
import CustomEncrypter from "./utils/CustomEncrypter";
Expand Down
4 changes: 2 additions & 2 deletions functions/src/opentrace/getUploadToken.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import functions from "firebase-functions";
import admin from "firebase-admin";

import config from "../config";
import getEncryptionKey from "./utils/getEncryptionKey";
Expand Down
2 changes: 1 addition & 1 deletion functions/src/opentrace/processUploadedData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as functions from "firebase-functions";
import functions from "firebase-functions";
import {ObjectMetadata} from "firebase-functions/lib/providers/storage";

const processUploadedData = async (object: ObjectMetadata) => {
Expand Down
4 changes: 1 addition & 3 deletions functions/src/opentrace/types/FunctionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PinGenerator from "../utils/PinGenerator";
// SUPPORTED_REGIONS from function-configuration.d.ts
declare type SUPPORTED_REGIONS = "us-central1" | "us-east1" | "us-east4" | "europe-west1" | "europe-west2" | "asia-east2" | "asia-northeast1";

interface FunctionConfig {
export interface FunctionConfig {
projectId: string // Firebase Project ID
regions: SUPPORTED_REGIONS[]
utcOffset: number | string
Expand All @@ -28,5 +28,3 @@ interface FunctionConfig {
bucketForArchive: string
}
}

export default FunctionConfig;
4 changes: 1 addition & 3 deletions functions/src/opentrace/types/HeartBeatEvent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
interface HeartBeatEvent {
export interface HeartBeatEvent {
timestamp: number,
msg?: string,
// enhanced fields:
timestampString?: string,
}

export default HeartBeatEvent;
4 changes: 1 addition & 3 deletions functions/src/opentrace/types/StreetPassRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Transmission Power txPower
* Organization org
*/
interface StreetPassRecord {
export interface StreetPassRecord {
timestamp: number,
msg?: string,
modelC: string,
Expand All @@ -24,5 +24,3 @@ interface StreetPassRecord {
contactIdValidFrom?: number,
contactIdValidTo?: number,
}

export default StreetPassRecord;
2 changes: 1 addition & 1 deletion functions/src/opentrace/utils/Authenticator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as functions from "firebase-functions";
import functions from "firebase-functions";
import {CallableContext} from "firebase-functions/lib/providers/https";

export default class Authenticator {
Expand Down
2 changes: 1 addition & 1 deletion functions/src/opentrace/utils/CustomEncrypter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as crypto from "crypto";
import crypto from "crypto";
import config from "../../config";

class CustomEncrypter {
Expand Down
4 changes: 2 additions & 2 deletions functions/src/opentrace/utils/formatTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Convert timestamp (expressed in seconds since the Epoch) to "DD-MMM-YYYY HH:mm:ss Z" format
* @param timestamp
*/
import * as moment from "moment";
import moment from "moment";

import config from "../../config";

Expand All @@ -12,4 +12,4 @@ function formatTimestamp(timestamp: number) {
return moment.unix(timestamp).utcOffset(config.utcOffset).format(TIMESTAMP_FORMAT);
}

export default formatTimestamp;
export default formatTimestamp;
2 changes: 1 addition & 1 deletion functions/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as admin from "firebase-admin";
import admin from "firebase-admin";
import config from "../src/config";

if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
Expand Down
8 changes: 4 additions & 4 deletions functions/test/opentrace/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import * as chai from "chai";
import * as crypto from "crypto";
import admin from "firebase-admin";
import functions from "firebase-functions";
import chai from "chai";
import crypto from "crypto";

import config from "../../src/config";
import {FunctionsTestWrapper} from "../index.test";
Expand Down
8 changes: 4 additions & 4 deletions functions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2017"
"target": "es2017",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"importHelpers": true
},
"compileOnSave": true,
"include": [
"src"
]
}

0 comments on commit b10c332

Please sign in to comment.