Blog API using NestJS, Apollo Server, Prisma
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run build:prod
$ npm run start:prod
# build the image
$ docker build -t nestjs-boilerplate .
# run the image
$ docker run nestjs-boilerplate
Fill env variables in .env
file
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DATABASE
SECRET_KEY=
CLD_CLOUD_NAME=
CLD_API_KEY=
CLD_API_SECRET=
PORT=
TOKENEXPIRATION=
This project implements Prisma with PostgreSQL
Migration:
prisma migrate dev --name init
General functionality:
- Authenticate via JWT and HttpOnly cookie
- CRUD articles, paginate articles
- CRUD comments on articles
- Follow other users
- Upload image to Cloudinary storage
- Search articles by Full-text search and filter articles by category, view, lastest,...
Visit https://nestjs-boilerplate-7klb.onrender.com/graphql to demo this
mutation {
SignUp (signUpData: {
email: "YOUR_EMAIL",
name: "YOUR_NAME",
password: "YOUR_PASSWORD"
}) {
user {
id
name
avatar
}
token
}
}
mutation {
SignIn (signInData: {
email: "YOUR_EMAIL",
password: "YOUR_PASSWORD"
}) {
user {
id
name
avatar
}
token
}
}
query {
GetPostById(id: POST_ID) {
id
title
content
thumbnail
description
category
createdAt
updatedAt
}
}
mutation {
CreatePost(postData: {
title: ""
content: ""
description: ""
categoryId: ""
}) {
id
title
content
thumbnail
description
author {
id
}
category {
id
title
}
comments {
id
content
}
views
}
}
query {
FilterPost (filterData: {
page: 1,
limit: 10,
createdAt: DESC or ASC,
search: "keyword",
views: DESC or ASC,
}) {
docs {
id
title
content
thumbnail
description
category
createdAt
updatedAt
}
}
}