Giter VIP home page Giter VIP logo

next-blog-api's People

Contributors

guilhermealvesc avatar yurihnrq avatar

Watchers

 avatar

next-blog-api's Issues

Allow creation of admin users

Description

Implement a feature where when creating a specific user it will have admin privileges. Maybe a .env config telling the email of the user that, when created, will be admin.

Tasks

  • Give users a field called isAdmin (boolean)
  • Implement a way to create the first admin user
  • Give admin users the right to change others users type: isAdmin (true or false) (patch endpoint?)

Routes for posts CRUD operations

Description

Create API endpoints for all CRUD operations over blog posts.

Tasks

  • Create posts repository
  • Create posts services
  • Create posts controllers
  • Create posts router

Reimplement features which got lost after app refactoring

Description

Some features got lost after the refactor in this PR #13.

They need to be reimplemented for the app development get back in progress.

Tasks

  • Users CRUD routes
  • Login route (change its name to auth)
  • Authentication middleware

OBS: Try to use TDD in the coding of this tasks. ๐Ÿ‘†

Routes for users CRUD operations

Description

Create users router to provided endpoints for all users CRUD operations.

Tasks

  • GET /users/ to get all users
  • GET /user/:id to get user by id
  • POST /user/ to create a user
  • DELETE /user/:id to delete user with the provided id
  • PUT /user/:id to update user data

Change ts code runner from ts-node-dev to tsx

Description

tsx is a simplier, newer and better ts code runner. It`s powered by esbuild and is very fast.
Add tsx as the code runner for development and remove ts-node-dev from the project.

Tasks

Tasks for the issue.

  • Install and configure tsx
  • Remove ts-node-dev

Add user verification

Description

Send verification e-mail with token to user on account creation. Create and endpoint (users\:userId\verify) to confirm verification.
A new property should be added to the User model: isVerified.

Tasks

  • Create EmailProvider interface and implement it with Nodemailer.
  • Create SendVerificationEmailService.
  • Send verification e-mail at CreateUserController.
  • Create users\:userId\verify route and VerifyUserController.

Create Swagger documentation

Description

Generate a /docs route to access Swagger UI documentation of the API.

Tasks

  • Install and setup swagger-ui
  • "/docs" route
  • Documentation creation

Create exception handling to tokenProvider errors at AuthMiddleware

Description

Add proper exception handling at AuthMiddleware to return a better response when a invalid token is provided.
On token validation error, the response should be APIError(401, 'Unauthorized request.').

Images

Current response when invalid token is provided.

image

Tasks

  • Add try_catch block at AuthMiddleware
  • Add proper error response

User authentication middleware with JWT

Description

Create an express middleware do validate user authentication.

Tasks

  • Create auth middleware for jwt authentication.
  • Use auth middleware in update and delete routes.

Better error handling

Description

Create a middleware that handle all errors thrown by controllers, services and repositories.

Tasks

  • Create errors model (class) following this interface:
interface APIError {
  status: number;
  message: string;
}
  • Create middleware that handles errors
  • Routes must throw APIError errors which must be catch by the middleware

Create DTOs for users services and repository

Description

Improve code quality by creating DTO interfaces for users module.

Tasks

  • Create DTOs interfaces for users services and repository
  • Refactor services and repository to use DTOs interfaces
  • Correct unit tests

Create project dev container

Description

Use Fedora base image to create a development container for the project.

Tasks

The image should be configured with

  • ZSH as default terminal
  • Spaceship prompt
  • Node in the latest LTS version (with yarn)
  • Non root user
  • PostgreSQL

Initial API project setup

Description

Setup up the project with requested tools.

Tasks

  • Typescript as development language.
    • ES modules setup (target and module as ESNext).
    • nodemon with ts-node for dev environment.
  • Express as application framework.
  • Prisma as ORM tool.
  • Jest as unit test tool.
  • pm2 as production process manager.
  • ESLint, Prettier and EditorConfig setup.
  • Pre-commit hook with lint-staged and husky.

Create reusable middleware which uses a zod schema for data validation

Description

Use zod for request schemas validation using a middleware that receive an schema and use it to validate the request body.

Tasks

Tasks for the issue.

  • Implement the new validation middleware that uses zod schemas
  • Create types and interfaces based on created schemas
  • Use the new validation middleware to validate body data on necessary routes

Create GetUserPostsController

Description

Create endpoint to fetch specific user posts. This endpoints should be /users/:id/posts.

Tasks

  • Create necessary users repository method
  • Create necessary users services
  • Create necessary controller
  • Create necessary route
    • Update api collection
    • Update swagger specs

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.