Skip to content

📝✨ Affable is a TypeScript project that provides REST APIs for managing your blog, as well as viewing others' blogs. With Affable, you can easily manage your blog content and streamline your publishing workflow.

Notifications You must be signed in to change notification settings

ahmedeid6842/Blog

Repository files navigation

Logo

Affable

Affable manages your Blog through REST API and you can also see others' Blogs .

Demo

Insert gif or link to demo

Requirements

Environment Variables

To run this project, you will need to add the following environment variables to your config/default.json file

PORT

HOST

MONGO_URI

saltWorkFactor

jwtSecret

you can also take config/test.json as reference

Installation

Install my-project with npm

  npm install
  npm run dev #if your are a developer 
  npm run start

Usage

Import this JSON file into Postman Collection, and you will be able to use all REST APIs.

If you don't know how to do it, watch this video.

API Reference

Authentication

Create User

  POST /api/v2/user/
Request Body Type Description
userName string Required .user's username
email string Required .user's email
password string Required .user's password
passwordConfirmation string Required

Login

  POST /api/v2/session/login
Request Body Type Description
email string Required .email of exist user
passwrod string Required .password of that email

Find User

  GET /api/v2/user?
Request Query Type Description
userName string username of selected user
email string email of selected user
id Int id of selected user

Logout

  GET /api/v2/session/logout

CRUD Blog

Create Blog

  POST /api/v2/blog/
Constraints Type Description
isAuthenticated middleware Required you must be logged in to create a post
Request Body Type Description
title string Required .main title of blog
description string describe your blog
tags string tag your post to specific topic ["programming", "health", "sports"]

Find Blog

  GET /api/v2/blog?
Request Query Type Description
id string get blog with it's id
author string get blogs for specific author

Delete Blog

  DELETE /api/v2/blog/${id}
Constraints Type Description
isAuthenticated middleware Required you must be logged in to create a blog
isAuthorized middleware Required you must be that owner of the blog
Request Parameters Type Description
id string Required .id of deleted blog

Contributing

Contributions are always welcome!

Authors

Lessons Learned

  • How to transition from javascript to typescript and reap the benefits of typescript.
  • How to use Zod for validation.
  • How to migrate MongDB and typescript.
  • There is always something new to learn.

About

📝✨ Affable is a TypeScript project that provides REST APIs for managing your blog, as well as viewing others' blogs. With Affable, you can easily manage your blog content and streamline your publishing workflow.

Resources

Stars

Watchers

Forks

Packages

No packages published