Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Installation

$ yarn install

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Test

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

blog-api-nestjs

REST_API

The Rest api to the blog api is described below,

AUTHENTICATION

Create User

Request

  • POST /user
curl --location 'http://localhost:3000/user' \
--header 'x-api-key: live_sk_65ab9353145cab9557ab93df95e31d62629c343' \
--header 'app-id: 9a2f92ad-3613-4074-9027-3b63de7149d8' \
--header 'Content-Type: application/json' \
--data-raw '{
    "user": {
        "username": "AKintunde Bello",
        "email": "AkinsTheMan@gmail.com",
        "password": "AkinsTheMan@123454"
    }
}'

Response

{
  "user": {
    "username": "AKintunde Bello",
    "email": "AkinsTheMan@gmail.com",
    "id": 14,
    "bio": "",
    "image": "",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImVtYWlsIjoiQWtpbnNUaGVNYW5AZ21haWwuY29tIiwidXNlcm5hbWUiOiJBS2ludHVuZGUgQmVsbG8iLCJpYXQiOjE3MTQ2OTM4MjEsImV4cCI6MTcxNDY5NDcyMX0.KwBXTmZJLOjArYg09c7ARd-reXkJtKJqzeoH3smlweM"
  }
}

User Login

Request

  • POST /user/login
curl --location 'http://localhost:3000/user/login' \
--header 'Content-Type: application/json' \
--data-raw '{
    "user":  {
        "email": "AkinsTheMan@gmail.com",
        "password": "AkinsTheMan@123454"
    }
}'

Response

{
  "user": {
    "id": 14,
    "username": "AKintunde Bello",
    "email": "AkinsTheMan@gmail.com",
    "bio": "",
    "image": "",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImVtYWlsIjoiQWtpbnNUaGVNYW5AZ21haWwuY29tIiwidXNlcm5hbWUiOiJBS2ludHVuZGUgQmVsbG8iLCJpYXQiOjE3MTQ2OTQxMDMsImV4cCI6MTcxNDY5NTAwM30.UNYYq8FXiSepeHUFHlHat8_PnTdXi8yqxEeLKtXBTPo"
  }
}

USER

Update User

Request

curl --location --request PUT 'http://localhost:3000/user' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImVtYWlsIjoiQWtpbnNUaGVNYW5AZ21haWwuY29tIiwidXNlcm5hbWUiOiJBS2ludHVuZGUgQmVsbG8iLCJpYXQiOjE3MTQ2OTQxMDMsImV4cCI6MTcxNDY5NTAwM30.UNYYq8FXiSepeHUFHlHat8_PnTdXi8yqxEeLKtXBTPo' \
--data '{
    "user": {
        "bio": "Some bio",
        "image": "https://i.stack.imgur.com/xHWG8jpg"
    }
}'

Response

{
  "user": {
    "id": 14,
    "username": "AKintunde Bello",
    "email": "AkinsTheMan@gmail.com",
    "bio": "Some bio",
    "image": "https://i.stack.imgur.com/xHWG8jpg"
  }
}

Get User

Request

curl --location 'http://localhost:3000/user' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTQsImVtYWlsIjoiQWtpbnNUaGVNYW5AZ21haWwuY29tIiwidXNlcm5hbWUiOiJBS2ludHVuZGUgQmVsbG8iLCJpYXQiOjE3MTQ2OTQxMDMsImV4cCI6MTcxNDY5NTAwM30.UNYYq8FXiSepeHUFHlHat8_PnTdXi8yqxEeLKtXBTPo'

Response

{
  "user": {
    "id": 14,
    "username": "AKintunde Bello",
    "email": "AkinsTheMan@gmail.com",
    "bio": "Some bio",
    "image": "https://i.stack.imgur.com/xHWG8jpg"
  }
}

ARTICLE

Create Article

Request

curl --location 'http://localhost:3000/articles' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiZW1haWwiOiJoYXJ3YXJsODdAZ21haWwuY29tIiwidXNlcm5hbWUiOiJkb2t1biIsImlhdCI6MTcxNDY3MTEyNSwiZXhwIjoxNzE0NjcyMDI1fQ.JMbPPRm6XUj1NutlNUAUgghx0711L4GUXTK1Rpv6hkU' \
--data '{
    "article": {
        "title": "This is my first article",
        "description": "This is my description",
        "body": "This is the body",
        "tagList": ["This is it"]
    }
}'

Get Article By Slug

Request

curl --location 'http://localhost:3000/articles/this-is-my-first-article--685hbx.w89l7' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiZW1haWwiOiJoYXJ3YXJsODdAZ21haWwuY29tIiwidXNlcm5hbWUiOiJkb2t1biIsImlhdCI6MTcxNDY3MTEyNSwiZXhwIjoxNzE0NjcyMDI1fQ.JMbPPRm6XUj1NutlNUAUgghx0711L4GUXTK1Rpv6hkU'

Get Article By Slug

Request

curl --location 'http://localhost:3000/articles/this-is-my-first-article--685hbx.w89l7' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MiwiZW1haWwiOiJoYXJ3YXJsODdAZ21haWwuY29tIiwidXNlcm5hbWUiOiJkb2t1biIsImlhdCI6MTcxNDY3MTEyNSwiZXhwIjoxNzE0NjcyMDI1fQ.JMbPPRm6XUj1NutlNUAUgghx0711L4GUXTK1Rpv6hkU'