Skip to content
REST API for my Gatsby talk about building static & dynamic apps with Gatsby
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
config initial commit May 14, 2019
middleware initial commit May 14, 2019
models initial commit May 14, 2019
routes
.eslintrc.js
.gitignore initial commit May 14, 2019
README.md initial commit May 14, 2019
index.js
package-lock.json initial commit May 14, 2019
package.json initial commit May 14, 2019

README.md

Not Todo REST API for my Gatsby talk

Gatsby Talk Gatsby App

Prerequisites

  • Node Js
  • MongoDB Installed

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

Installing the dependencies

npm i

Start your mongodb database

npm run database

Start the dev server

npm run dev

Models

User:

  • username
  • email
  • password
  • tokens

Post:

  • title
  • isDone
  • date
  • _creator

Routes

  • User
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
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

Built with

  • Express Js
  • MongoDB & Mongoose
  • And these useful of JavaScript libraries package.json

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Support

If you love this Gatsby template and want to support me, you can do so through my Patreon

Support me on Patreon

You can’t perform that action at this time.