Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Full-Stack React Projects

You're reading from   Full-Stack React Projects Modern web development using React 16, Node, Express, and MongoDB

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788835534
Length 470 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Shama Hoque Shama Hoque
Author Profile Icon Shama Hoque
Shama Hoque
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Unleashing React Applications with MERN FREE CHAPTER 2. Preparing the Development Environment 3. Building a Backend with MongoDB, Express, and Node 4. Adding a React Frontend to Complete MERN 5. Starting with a Simple Social Media Application 6. Exercising New MERN Skills with an Online Marketplace 7. Extending the Marketplace for Orders and Payments 8. Building a Media Streaming Application 9. Customizing the Media Player and Improving SEO 10. Developing a Web-Based VR Game 11. Making the VR Game Dynamic Using MERN 12. Following Best Practices and Developing MERN Further 13. Other Books You May Enjoy

Game APIs


The backend in the MERN VR Game will expose a set of CRUD APIs for creating, editing, reading, listing, and deleting games from the database, which can be used in the frontend of the application, including in the React 360 game implementation, with fetch calls.

The create API

A user who is signed in to the application will be able to create new games in the database using the create API.

Route

In the backend, we will add a POST route in game.routes.js, that verifies that the current user is signed in and authorized, and then creates a new game with the game data passed in the request.

mern-vrgame/server/routes/game.routes.js:

router.route('/api/games/by/:userId')
    .post(authCtrl.requireSignin,authCtrl.hasAuthorization, gameCtrl.create)

To process the :userId param and retrieve the associated user from the database, we will utilize the userByID method from the user controller. We will also add the following to the game routes, so the user is available in the request object as profile...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image