質問編集履歴
5
タイトルの変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Typescript react firebase 環境でのエラー
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
firebase functionsでチャットの構造体(json)をfirestoreにデプロイしたいです。
|
8
8
|
|
9
|
-
|
9
|
+
ソースコード
|
10
10
|
|
11
11
|
```
|
12
12
|
|
4
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,64 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
```
|
12
|
+
|
13
|
+
import * as functions from 'firebase-functions'; ←ここでエラー発生 外部からインポートできませんみたいなことを言われています。
|
14
|
+
|
15
|
+
import * as admin from "firebase-admin";
|
16
|
+
|
17
|
+
admin.initializeApp();
|
18
|
+
|
19
|
+
const db = admin.firestore();
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
const sendResponse = (response: functions.Response, statusCode: number, body: any) => {
|
24
|
+
|
25
|
+
response.send({
|
26
|
+
|
27
|
+
statusCode,
|
28
|
+
|
29
|
+
body: JSON.stringify(body)
|
30
|
+
|
31
|
+
});
|
32
|
+
|
33
|
+
};
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
export const addDataset = functions.https.onRequest(async (req: any, res: any) => {
|
40
|
+
|
41
|
+
if (req.method !== 'POST') {
|
42
|
+
|
43
|
+
sendResponse(res, 405, {error: "Invalid Request"})
|
44
|
+
|
45
|
+
} else {
|
46
|
+
|
47
|
+
const dataset = req.body;
|
48
|
+
|
49
|
+
for (const key of Object.keys(dataset)) {
|
50
|
+
|
51
|
+
const data = dataset[key];
|
52
|
+
|
53
|
+
await db.collection('questions').doc(key).set(data)
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
sendResponse(res, 200, {message: 'Successfully added dataset! WooHoo!'});
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
});
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
11
69
|
### 発生している問題・エラーメッセージ
|
12
70
|
|
13
71
|
デプロイコマンドで途中までうまく行きますが、functions preparing functions directory for uploadingのとこでError発生します。
|
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,11 @@
|
|
12
12
|
|
13
13
|
デプロイコマンドで途中までうまく行きますが、functions preparing functions directory for uploadingのとこでError発生します。
|
14
14
|
|
15
|
-
firebase deploy
|
15
|
+
¥firebase deploy 以下エラーコード
|
16
16
|
|
17
|
+
|
18
|
+
|
17
|
-
|
19
|
+
```
|
18
20
|
|
19
21
|
i deploying firestore, functions, hosting
|
20
22
|
|
@@ -74,6 +76,10 @@
|
|
74
76
|
|
75
77
|
at Module._compile (internal/modules/cjs/loader.js:1063:30)
|
76
78
|
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
|
77
83
|
|
78
84
|
|
79
85
|
|
@@ -89,6 +95,10 @@
|
|
89
95
|
|
90
96
|
|
91
97
|
package.json
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
|
92
102
|
|
93
103
|
{
|
94
104
|
|
@@ -144,9 +154,13 @@
|
|
144
154
|
|
145
155
|
}
|
146
156
|
|
157
|
+
```
|
158
|
+
|
147
159
|
|
148
160
|
|
149
161
|
tsconfig.json
|
162
|
+
|
163
|
+
```
|
150
164
|
|
151
165
|
{
|
152
166
|
|
@@ -177,3 +191,5 @@
|
|
177
191
|
]
|
178
192
|
|
179
193
|
}
|
194
|
+
|
195
|
+
```
|
2
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
3
|
|
4
|
-
|
5
|
-
ここに質問の内容を詳しく書いてください。
|
6
4
|
|
7
5
|
Typescript react firebase でチャットボット を作成中
|
8
6
|
|
@@ -12,7 +10,9 @@
|
|
12
10
|
|
13
11
|
### 発生している問題・エラーメッセージ
|
14
12
|
|
13
|
+
デプロイコマンドで途中までうまく行きますが、functions preparing functions directory for uploadingのとこでError発生します。
|
14
|
+
|
15
|
-
firebase deploy
|
15
|
+
firebase deploy
|
16
16
|
|
17
17
|
→
|
18
18
|
|
1
package.json tsconfig.jsonを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,3 +81,99 @@
|
|
81
81
|
### 試したこと
|
82
82
|
|
83
83
|
スタックオーバーフローに載っているものは全て試しました。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
■追記 package.json tsconfig.jsonを追記しました
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
package.json
|
92
|
+
|
93
|
+
{
|
94
|
+
|
95
|
+
"name": "functions",
|
96
|
+
|
97
|
+
"type":"module",
|
98
|
+
|
99
|
+
"scripts": {
|
100
|
+
|
101
|
+
"lint": "tslint --project tsconfig.json",
|
102
|
+
|
103
|
+
"build": "tsc",
|
104
|
+
|
105
|
+
"serve": "npm run build && firebase emulators:start --only functions",
|
106
|
+
|
107
|
+
"shell": "npm run build && firebase functions:shell",
|
108
|
+
|
109
|
+
"start": "npm run shell",
|
110
|
+
|
111
|
+
"deploy": "firebase deploy --only functions",
|
112
|
+
|
113
|
+
"logs": "firebase functions:log"
|
114
|
+
|
115
|
+
},
|
116
|
+
|
117
|
+
"engines": {
|
118
|
+
|
119
|
+
"node": "12"
|
120
|
+
|
121
|
+
},
|
122
|
+
|
123
|
+
"main": "src/index.ts",
|
124
|
+
|
125
|
+
"dependencies": {
|
126
|
+
|
127
|
+
"firebase-admin": "^9.2.0",
|
128
|
+
|
129
|
+
"firebase-functions": "^3.11.0"
|
130
|
+
|
131
|
+
},
|
132
|
+
|
133
|
+
"devDependencies": {
|
134
|
+
|
135
|
+
"typescript": "^3.8.0",
|
136
|
+
|
137
|
+
"firebase-functions-test": "^0.2.0"
|
138
|
+
|
139
|
+
},
|
140
|
+
|
141
|
+
"private": true
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
tsconfig.json
|
150
|
+
|
151
|
+
{
|
152
|
+
|
153
|
+
"compilerOptions": {
|
154
|
+
|
155
|
+
"module": "commonjs",
|
156
|
+
|
157
|
+
"noImplicitReturns": true,
|
158
|
+
|
159
|
+
"noUnusedLocals": true,
|
160
|
+
|
161
|
+
"outDir": "lib",
|
162
|
+
|
163
|
+
"sourceMap": true,
|
164
|
+
|
165
|
+
"strict": true,
|
166
|
+
|
167
|
+
"target": "es2017"
|
168
|
+
|
169
|
+
},
|
170
|
+
|
171
|
+
"compileOnSave": true,
|
172
|
+
|
173
|
+
"include": [
|
174
|
+
|
175
|
+
"src"
|
176
|
+
|
177
|
+
]
|
178
|
+
|
179
|
+
}
|