REST API for my Gatsby talk about building static & dynamic apps with Gatsby
Please create a new file .env
and put these env variables
DB=mongodb://localhost:27017/todo
SECRET_KEY=NSA
REACT_APP_URL=http://localhost:8000 // when cors is enabled, this will be the only origin to send requests
Installing the dependencies
npm i
npm run database
npm run dev
User:
Post:
POST /api/user/register
// Register a new user and returns user data with the generated token
// Public
POST /api/user/login
// Login user and returns user data with the generated token
// Public
GET /api/user/verify
// Verifies token and returns current user data
// Private
DELETE /api/user/logout
// Logout
// Private
POST /api/post
// Create a new post
// Private
GET /api/post/all
// Get all the posts
GET /api/post/:id
// Get Post by ID
// Private
DELETE /api/post/:id
// Delete Post by ID
// Private
PATCH /api/post/:id
// Update a post
// Private
This project is licensed under the MIT License - see the LICENSE.md file for details
If you love this Gatsby template and want to support me, you can do so through my Patreon