Simple user board web application using several libraries. To learn graphql and other libraries.
Features
- Login
- CRUD a post (Need login to CUD)
What used
Front-end : Bootstrap 4, jQuery
Back-end : Node.js, Express.js
Data fetching : GraphQL, Mongoose
Authentication : JWT
This project does not use front-end framework like Vue.js or React.js, but just use Express.js, Bootstrap and jQuery.
Prerequisite
- MongoDB and Node.js must be installed in your computer.
- MongoDB must be run in your computer.
How to run
- Clone or download project
- Go to the project directory in command prompt
- Install dependencies -> "npm install"
- Run app -> "DEBUG=/:* npm start"
- Load "localhost:3000" in web browser
You can go to url : localhost:3000/graphql to test graphql api
GraphQL queries and mutations
-
Query
- getUserInfo(Token): Return user information using token
- getUsers(Token) : Return user information list (need token to auth and user level must be greater than 0 in DB)
- getPosts : Return posts
- getPost(pid): Return single post (need pid)
-
Mutation
- signUp(userInfo) : Sign up for new user and return message of singup result
- login(id, pw): Login using id and pw and return message of login result
- writePost(postInput, token): Write a post and return message of write result (need token to verify document owner)
- updatePost(pid, token, postInput): Update a post and return message of write result (need token to verify document owner)
- deletePost(pid, token): Delete a post and return message of write result (need token to verify document owner)
Web endpoint
Mongoose Schema
- User
- id(_id)
- uid
- password
- nickname
- level
- Post
- id(_id)
- pid
- title
- content
- createdAt