File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- const admin = require ( 'firebase-admin' ) ;
1615const 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
2018exports . 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} ) ;
Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- const admin = require ( 'firebase-admin' ) ;
1615const 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
2018exports . 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} ) ;
You can’t perform that action at this time.
0 commit comments