Skip to content

This fullstack project encompasses a server-side and client-side architecture, delivering a feature-rich website for adopting dogs that includes secure authentication.

Notifications You must be signed in to change notification settings

Afek-Sakaju/dog-adopters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dog Adopters

This Fullstack project embodies my extensive knowledge of backend and frontend development, as it has been executed with adherence to best practices, standards, and strict guidelines.

The frontend part is still under development and not finished yet!


The project stores data in a database and provides access through REST APIs, these APIs are developed using NodeJS, typescript, and express ts.

For authentication and users For dogs data
+ Register user + Get dog by id
+ Login user + Get dog list with filters and sorting options
+ Logout user   - Authentication is required
+ Get user by id   - Pagination included in the response
  - Authentication is required + Create new dog
  - Authentication is required
  - Owner id is auto-assigned from the authenticated user
+ Update exists dog data
  - Authentication is required
  - Only owner/admin allowed to operate
+ Delete exists dog
  - Authentication is required
  - Only owner/admin allowed to operate
+ upload dog profile image file
  - Authentication is required
  - Only owner/admin allowed to operate
+ get available dog breeds in db for future filters
  - Authentication is required
  - Only owner/admin allowed to operate

In addition, the project boasts extensive Swagger API documentation, covering all the REST APIs mentioned above, accessible at:
http://localhost:3000/swagger

NOTE: Certain APIs necessitate authentication, requiring users to log in before executing them. These authenticated APIs are denoted by a lock symbol.
APIs that require authentication


Requirements

  • NodeJS version 16.4+
  • MongoDB service version 6.0.1+

Command lines

  • The command to init and install project
    • npm install
  • The command to run the project
    • npm run start
      (executing migrations, building the TypeScript code, and running the compiled JavaScript project)
  • Additional commands that are optional
    • npm run migrationDB
      (runs only migration)
    • npm run dev
      (runs typescript code for development with nodemon)
    • npm run test
      (runs only tests with jest + supertest for APIs tests)

Test Coverage:

coverage

The technologies used in this project include:

  • Nodejs : the project is javascript based.
  • Express : used for the server side routers, middlewares, controllers, and services.
  • Typescript : the project has been implemented using typescript interfaces, <filenames>.d.ts declarations files, etc..
  • DotEnv : utilizes dotenv files to manage environment variables, and incorporates dotenv-expand to enhance flexibility in the env files.
  • logger : utilizes colorized Winston logs with request ID (UUID) for recording server activities stored in daily rotating files (winston-daily-rotate-file).
  • Passport : authentication with passport-local strategy {username, password} for request body.
  • MongoDB : utilized with the mongoose library for defining schemas and models, which are then utilized in the controllers and services.
  • Bcrypt : user passwords are securely encrypted in accordance with best practices to ensure data security.
  • Swagger : the /swagger URL provides comprehensive API documentation and instructions for testing and debugging APIs,this functionality is available in non-production environments (for development), the project also utilizes mongoose-to-swagger to transform mongoose models into Swagger schema docs.
  • mongo-migrate : the migrations ensure that the MongoDB database has the latest updates of the data before running the project, they also handle important database initializations, including users creation and mocked dogs data.
  • express-rate-limit : to prevent cyber attacks like brute-force on the login API, user requests to specific APIs are restricted with a maximum number of attempts.
  • multer : utilizes the multer middleware API to enable file uploads, such as images, for the dog profile.

Additional technologies used as development tools include:

  • nodemon : watches for typescript file changes and compiles them in real-time.
  • Jest : Comprehensive typescript tests with extensive coverage, including password encryption, models, services, and router APIs, have been implemented using the supertest package.
  • mongodb-memory-server : running tests on an in-memory database, allowing for efficient and isolated testing.

In addition, the project incorporates the following features:

  • aggregations : a fully featured aggregate request filters dogs based on query parameters, populates the dog by its creator, and supports data limiting, offsetting, and sorting options.
  • transactions : the project does not incorporates multiple operations for a single process action, despite being aware of the concept.
  • server side pagination : the project implements pagination for the aggregation result data, enabling fetching a limited number of items based on the provided page number and items per page parameters.
{
"pagination": {
    "totalItems": 487,
    "page": 5,
    "itemsPerPage": 20,
    "totalPages": 25
},
"data": [...]
}
  • passport authentication : user authentication in the project follows best practices by comparing the encrypted password with the plaintext password provided.
  • override toJSON data : exclude the password from the user object when it is returned as JSON.
  • mongoose schema hooks : incorporates a pre-save hook that encrypts the user's password before creating a new user.
  • status code : HTTP request responses return the appropriate and correct status codes.
  • jest : comprehensive tests for thorough validation of all services and functions.
  • postman : postman collection for simplified testing and interaction with the project's APIs :
    dog_adopters_rest_api.postman_collection.json

Author

:octocat: Afek Sakaju

About

This fullstack project encompasses a server-side and client-side architecture, delivering a feature-rich website for adopting dogs that includes secure authentication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published