This is a simple blog that allows authors to register and create blog with read count and reading time. Fully paginated.
Clone the repo:
git clone https://github.com/udofia2/nkwed.git
cd nknwed
yarn install
cp .env.example .env
```bash
yarn dev
Compiling to JS from TS
yarn compile
Compiling to JS from TS in watch mode
yarn compile:watch
yarn commit
Testing:
# all tests
yarn test
# TypeScript tests
yarn test:ts
# JS tests
yarn test:js
# all tests in watch mode
yarn test:watch
# test coverage
yarn coverage
Linting:
# run ESLint
yarn lint
# fix ESLint errors
yarn lint:fix
# run prettier
yarn prettier
# fix prettier errors
yarn prettier:fix
List of available routes:
Auth routes:
GET /health
- health check\
Auth routes:
POST /v1/auth/register
- register
POST /v1/auth/login
- login
POST /v1/auth/refresh-tokens
- refresh auth tokens
POST /v1/auth/forgot-password
- reset password token
POST /v1/auth/reset-password
- reset password
Blog routes:
POST /v1/blogs
- create a blog
GET /v1/blogs
- get all blogs including published and draft
GET /v1/blogs/published
- get all published blogs
GET /v1/blogs/my/posts
- get all created blogs for a login author
GET /v1/blogs/:postId
- get blog
PATCH /v1/blogs/:postId
- update blog by a login author
DELETE /v1/blogs/:postId
- delete blog by a login author\
User routes:
POST /v1/users
- create a user
GET /v1/users
- get all users
GET /v1/users/:userId
- get user
PATCH /v1/users/:userId
- update user
DELETE /v1/users/:userId
- delete user\
[Entities]:
- Users : Represents a registered user on the blogging platform.
- Blogs : Represents a blog post created by a user.
- Tokens : Represents an authentication or authorization token associated with a user.
[Attributes]
User:
- _id (primary key)
- first_name
- last_name
- email (unique)
- password (hashed)
- role
- isEmailVerified
Blog:
- _id (primary key)
- title (unique)
- description
- author_id (foreign key referencing User._id)
- state
- read_count
- reading_time
- tags
- body
Token:
- _id (primary key)
- token (unique)
- user (foreign key referencing User._id)
- type (refresh, reset_password)
- expires
- blacklisted
[Relationships]:
- User - Token(one-to-many)
- Blog - User(many-to-one)
Diagram:
(1) (N)
User ----->* Token (N) |
| Blog
user_id user_id (FK) --------*-----> (only established relationship)