@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbvision/cloud-run-service",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "fastify-firestore-service Web Framework on Cloud Run",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
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 * as utils from './utils.js'
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
- utils
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
- // start the server
87
- service = await makeService(components)
88
- service.listen({ port, host: '0.0.0.0' })
86
+ if (!isUnitTesting) {
87
+ // start the server
88
+ service = await makeService(components)
89
+ service.listen({ port, host: '0.0.0.0' })
90
+ }
89
91
  }
@@ -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, now } from './utils.js'
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: now() }
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,
package/src/utils.js CHANGED
@@ -42,5 +42,3 @@ export function getServiceHost (serviceName) {
42
42
  return serviceName + process.env.CLOUD_RUN_HOSTNAME_SUFFIX
43
43
  }
44
44
  }
45
-
46
- export const now = () => Math.floor(new Date().getTime() / 1000)