GithubHelp home page GithubHelp logo

blogapi's Introduction

TechBlogAPI

A blog API that allows user to register with Authorization Schema. User receives a Token at the header, with the token the user can access Public blogs and create a blog with a username at the endpoint. User can also find blog and can adjust/delete blog with id. The API protects API with a hashed password. Usernames/Emails must also be unique during the registration process. Website:

Tech Stack Server: Node, Express

Database: MongoDB

Tools: Postman

Environment Variables To run this project, you will need to add the following environment variables to your .env file

MONGODB_URI JWT_SECRET SALT Run Locally To clone the project, you must follow all steps and have all dependencies in order to run the project locally.

Git clone - (https://github.com/Meeks71/blogapi)

Go to the DOCUMENTS directory

cd blogapi

Install dependencies npm init -y

npm i:

-bcrypt -dotenv -express -helmet -jsonwebtoken -mongoose -morgan

Routes

  • Endpoints, Parameters, Schema server -app.get('/') returns message "WELCOME TO MY BLOG API!!"

Routes Auth('/auth') creates Users and Login

router.post('/'): Register Users, AuthSchema is used. password is hashed

router.post('/'): Login with username and password only. Token is sent to header for further acess

router.get('/'): base endpoint Finds all users. Protected with token sent to header No parameters

Blog('/blog') router.get('/'): all Public blogs are included, must be logged in and have a token

router.post('/'): Creates Blog with blogSchema, username parameter(String) name is needed to post blog

router.put('/:id'): Updates blog with id, parameter(String) id is needed to update blog

router.get('/:id'): Returns blog associcated to id, parameter(String) id is required to find blog. onlyprivate blogs appear

router.delete('/:id): Deletes blog associated with id, need a token for Authorization and parameter(string) id is required to delete blog

Schemas userSchema: username: type: String, required: true

email: type: String, required: true

birthday: type: Date, required: true

age: type: Number, required: true

password: type: String, required: true

blogSchema:

username: type: String required: true,

password: type: String, required: true,

email: type: String, required: true,

birthday: type: Number, required: true,

age: type: Number

Middleware verifyToken: gets token from header and check that it matches token sent.

CreateBlog: uses login function to verify user is logged to aceess and post blogs. userame and password required, if passwords or username do not match 400 error will be sent

blogapi's People

Contributors

meeks71 avatar

Stargazers

 avatar  avatar Galekwan Sango avatar Raven avatar Felecia Davis avatar  avatar  avatar sl8//ton avatar  avatar  avatar Liubov Sariban avatar  avatar  avatar  avatar  avatar  avatar Abraham E. Tavarez avatar  avatar iamWajjih avatar Wendy Vuong avatar Elle Davis avatar Janette Campbell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.