Skip to content

Commit 7feee08

Browse files
authored
Merge pull request #3 from FirebaseExtended/remove-functions
Remove unused functions code
2 parents 52ba6c1 + 545dae1 commit 7feee08

2 files changed

Lines changed: 4 additions & 46 deletions

File tree

final-state/functions/index.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
const admin = require('firebase-admin');
1615
const functions = require('firebase-functions');
17-
const firestore = admin.initializeApp().firestore();
1816

19-
// Publishes draft posts. Triggered via a button click by admin user.
17+
// Placeholder function
2018
exports.publishPost = functions.https.onRequest((req, res) => {
21-
// Fetch post from `drafts`
22-
const body = JSON.parse(req.body);
23-
let post = firestore.document(`drafts/${body.draftID}`);
24-
25-
// Modify post's fields
26-
post.publishedAt = firestore.Timestamp.fromDate(new Date());
27-
delete post.createdAt;
28-
post.visible = true;
29-
30-
// Create new updated post
31-
firestore.document(`published/${body.draftID}`).create(post)
32-
.then(() => res.json({status: 200}));
33-
});
34-
35-
// Marks published drafts as hidden.
36-
exports.softDelete = functions.https.onRequest((req, res) => {
37-
const body = JSON.parse(req.body);
38-
// Flip `visible` field to false;
39-
firestore.document(`published/${body.postID}`).update({visible: false})
40-
.then(() => res.json({status: 200}));
19+
res.json({status: 200});
4120
});

initial-state/functions/index.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
const admin = require('firebase-admin');
1615
const functions = require('firebase-functions');
17-
const firestore = admin.initializeApp().firestore();
1816

19-
// Publishes draft posts. Triggered via a button click by admin user.
17+
// Placeholder function
2018
exports.publishPost = functions.https.onRequest((req, res) => {
21-
// Fetch post from `drafts`
22-
const body = JSON.parse(req.body);
23-
let post = firestore.document(`drafts/${body.draftID}`);
24-
25-
// Modify post's fields
26-
post.publishedAt = firestore.Timestamp.fromDate(new Date());
27-
delete post.createdAt;
28-
post.visible = true;
29-
30-
// Create new updated post
31-
firestore.document(`published/${body.draftID}`).create(post)
32-
.then(() => res.json({status: 200}));
33-
});
34-
35-
// Marks published drafts as hidden.
36-
exports.softDelete = functions.https.onRequest((req, res) => {
37-
const body = JSON.parse(req.body);
38-
// Flip `visible` field to false;
39-
firestore.document(`published/${body.postID}`).update({visible: false})
40-
.then(() => res.json({status: 200}));
19+
res.json({status: 200});
4120
});

0 commit comments

Comments
 (0)