Code Monkey home page Code Monkey logo

blogservice's Introduction

Blog Service API

Setup and Run

Step 1: Install Docker

  • Following this site

Step 2: Run command

Need admin permission

  • Update ormconfig.ts file
{
    "type": "mysql",
    "host": "mysqlDb",
    "port": 3306,
    "username": <your dbuser>,
    "password": <your password>,
    "database": "blog",
    "entities": [
        "dist/entities/**/*.js"
    ],  
    "cli": {
        "entitiesDir": "src/entities"
    },
    "synchronize": true
}
  • Update dock-compose.yml file
...
services:
    ...
    mysqlDb:
        ...
        environment:
            MYSQL_ROOT_PASSWORD: <your password>
            MYSQL_DATABASE: blog
  • Then run command:
docker-compose up
  • If you meet Error: "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
  • Open 1 more command line and excute following commands:
docker ps
  • Copy CONTAINER ID of the container which image's name is mysql:8 or mysql:lastest
  • Run command:
docker exec -it <CONTAINER ID> /bin/bash
  • You will get inside terminal of container
  • Excute:
mysql -u root -p
  • Input "root" as password
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '<your password>';
mysql> FLUSH PRIVILEGES;
mysql> exit
  • Run again
docker-compose up

API

Route: /user/signup

  • Method POST

body

{
	"fullname": string,
	"username": string,
	"password": string,
	"email": string,
	"phone": string
}

Route: /user/signin

  • Method POST
  • Return Token

body

{	
	"username": string,
	"password": string,
}

Route: /user

Token required

  • Method GET

  • Method PUT

body

    "id": string
    "fullname": string,
    "password": string,
    "email": string,
    "DoB": string,
    "phone": string, 

Route: /blog

Token required

  • Method Get

  • Method POST

body

{
	"title": string,
	"content": string
}
  • Method PUT

body

{
    "id": string,
	"title": string,
	"content": string
}

Route: /blog/:id

Token requried

  • Method GET

  • Method DELTE

/comment

Token requried

  • Method POST

body

{
	"content": string,
	"idBlog": string
}
  • Method PUT

body

{
	"id": string,
	"content": string
}

Route: /comment/:id

Token requried

  • Method GET

  • Method DELETE

/comment/sub

Token required

  • Method POST

body

{
	"content": string,
	"idComment": string
}

Route: /rate

Token requried

  • Method POST

body

{
	"rating": number,
	"idBlog": string,
    "idUser": string
}
  • Method PUT

body

{
	"id": string,
	"rating": string
}

Route: /rate/:id

Token requried

  • Method GET

  • Method DELETE

Stop running image

docker-compose down

blogservice's People

Contributors

luat111 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.