@pbvision/cloud-run-service 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +3 -2
- package/src/main.js +6 -4
- package/src/placeholder.js +2 -2
- package/src/tasks.js +1 -0
- package/src/utils.js +0 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { makeService, runService } from './main.js'
|
|
2
2
|
import { enqueueCloudTask } from './tasks.js'
|
|
3
|
-
import
|
|
3
|
+
import { isCloud, isDev, isProd, isLocalhost, isUnitTesting } from './utils.js'
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
enqueueCloudTask,
|
|
7
7
|
makeService, // for use with unit testing
|
|
8
8
|
runService,
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
isCloud, isDev, isProd, isLocalhost, isUnitTesting
|
|
10
11
|
}
|
package/src/main.js
CHANGED
|
@@ -5,7 +5,7 @@ import { API } from '@pbvision/fastify-firestore-service'
|
|
|
5
5
|
import { makePBVService } from './app.js'
|
|
6
6
|
import { callServiceAPI } from './call-service-api.js'
|
|
7
7
|
import { port } from './port.js'
|
|
8
|
-
import { isCloud, isLocalhost } from './utils.js'
|
|
8
|
+
import { isCloud, isLocalhost, isUnitTesting } from './utils.js'
|
|
9
9
|
|
|
10
10
|
API.prototype.callServiceAPI = callServiceAPI
|
|
11
11
|
|
|
@@ -83,7 +83,9 @@ export async function runService (components) {
|
|
|
83
83
|
}), 7000)
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (!isUnitTesting) {
|
|
87
|
+
// start the server
|
|
88
|
+
service = await makeService(components)
|
|
89
|
+
service.listen({ port, host: '0.0.0.0' })
|
|
90
|
+
}
|
|
89
91
|
}
|
package/src/placeholder.js
CHANGED
|
@@ -6,7 +6,7 @@ import { API, DatabaseAPI } from '@pbvision/fastify-firestore-service'
|
|
|
6
6
|
import db from '@pbvision/firestore-orm'
|
|
7
7
|
import S from '@pbvision/schema'
|
|
8
8
|
|
|
9
|
-
import { isUnitTesting
|
|
9
|
+
import { isUnitTesting } from './utils.js'
|
|
10
10
|
|
|
11
11
|
class Test extends db.Model {
|
|
12
12
|
static KEY = { id: S.str }
|
|
@@ -24,7 +24,7 @@ export class TestAPI extends DatabaseAPI {
|
|
|
24
24
|
async computeResponse () {
|
|
25
25
|
const doesNotExist = await this.tx.get(Test, 'abc')
|
|
26
26
|
assert(doesNotExist === undefined)
|
|
27
|
-
return { epoch:
|
|
27
|
+
return { epoch: Math.floor(new Date().getTime() / 1000) }
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
package/src/tasks.js
CHANGED
|
@@ -4,6 +4,7 @@ import { credentials } from '@grpc/grpc-js'
|
|
|
4
4
|
import { getServiceProtocolAndHost, usingEmulator } from './utils.js'
|
|
5
5
|
|
|
6
6
|
const tasksClient = (() => {
|
|
7
|
+
// istanbul ignore else
|
|
7
8
|
if (usingEmulator) {
|
|
8
9
|
return new CloudTasksClient({
|
|
9
10
|
port: process.env.CLOUD_TASKS_EMULATOR_PORT,
|