Skip to content

Commit fc37911

Browse files
committed
chore(ci): migrate datastore/functions to new ci
1 parent 898ac9a commit fc37911

5 files changed

Lines changed: 17 additions & 16 deletions

File tree

.github/config/nodejs-dev.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"datacatalog/quickstart",
118118
"datacatalog/snippets",
119119
"datalabeling",
120+
"datastore/functions",
120121
"dialogflow",
121122
"discoveryengine",
122123
"document-warehouse",

.github/config/nodejs.jsonc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string.
8181
"compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found
8282
"dataproc", // GoogleError: Error submitting create cluster request: Multiple validation errors
83-
"datastore/functions", // [ERR_REQUIRE_ESM]: require() of ES Module
8483
"dialogflow-cx", // NOT_FOUND: com.google.apps.framework.request.NotFoundException: Agent 'undefined' does not exist
8584
"dlp", // [ERR_REQUIRE_ESM]: require() of ES Module
8685
"document-ai", // [ERR_REQUIRE_ESM]: require() of ES Module

datastore/functions/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
'use strict';
1616

17-
const {Datastore} = require('@google-cloud/datastore');
17+
import {Datastore} from '@google-cloud/datastore';
1818

1919
// Instantiates a client
2020
const datastore = new Datastore();
@@ -58,7 +58,7 @@ const getKeyFromRequestData = requestData => {
5858
* @param {object} req.body.value Value to save to Cloud Datastore, e.g. {"description":"Buy milk"}
5959
* @param {object} res Cloud Function response context.
6060
*/
61-
exports.set = async (req, res) => {
61+
export async function set(req, res) {
6262
// The value contains a JSON document representing the entity we want to save
6363
if (!req.body.value) {
6464
const err = makeErrorObj('Value');
@@ -80,7 +80,7 @@ exports.set = async (req, res) => {
8080
console.error(new Error(err.message)); // Add to Stackdriver Error Reporting
8181
res.status(500).send(err.message);
8282
}
83-
};
83+
}
8484

8585
/**
8686
* Retrieves a record.
@@ -94,7 +94,7 @@ exports.set = async (req, res) => {
9494
* @param {string} req.body.key Key at which to retrieve the data, e.g. "sampletask1".
9595
* @param {object} res Cloud Function response context.
9696
*/
97-
exports.get = async (req, res) => {
97+
export async function get(req, res) {
9898
try {
9999
const key = await getKeyFromRequestData(req.body);
100100
const [entity] = await datastore.get(key);
@@ -110,7 +110,7 @@ exports.get = async (req, res) => {
110110
console.error(new Error(err.message)); // Add to Stackdriver Error Reporting
111111
res.status(500).send(err.message);
112112
}
113-
};
113+
}
114114

115115
/**
116116
* Deletes a record.
@@ -124,7 +124,7 @@ exports.get = async (req, res) => {
124124
* @param {string} req.body.key Key at which to delete data, e.g. "sampletask1".
125125
* @param {object} res Cloud Function response context.
126126
*/
127-
exports.del = async (req, res) => {
127+
export async function del(req, res) {
128128
// Deletes the entity
129129
// The delete operation will not fail for a non-existent entity, it just
130130
// doesn't delete anything
@@ -136,4 +136,4 @@ exports.del = async (req, res) => {
136136
console.error(new Error(err.message)); // Add to Stackdriver Error Reporting
137137
res.status(500).send(err.message);
138138
}
139-
};
139+
}

datastore/functions/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"engines": {
1111
"node": ">=16.0.0"
1212
},
13+
"type": "module",
1314
"scripts": {
1415
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=5000"
1516
},

datastore/functions/test/index.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
'use strict';
1616

17-
const assert = require('assert');
18-
const execPromise = require('child-process-promise').exec;
19-
const path = require('path');
20-
const uuid = require('uuid');
21-
const sinon = require('sinon');
22-
const fetch = require('node-fetch');
23-
const waitPort = require('wait-port');
24-
const {Datastore} = require('@google-cloud/datastore');
17+
import assert from 'assert';
18+
import {exec as execPromise} from 'child-process-promise';
19+
import path from 'path';
20+
import uuid from 'uuid';
21+
import sinon from 'sinon';
22+
import fetch from 'node-fetch';
23+
import waitPort from 'wait-port';
24+
import {Datastore} from '@google-cloud/datastore';
2525

2626
const datastore = new Datastore();
2727
const program = require('../');

0 commit comments

Comments
 (0)