Skip to content

enescidem/node-ts-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A REST API With Node, Express, TypeScript & MongoDB + Authentication

Medium Links:

English: https://medium.com/@enescidem/jwt-authentication-user-management-with-typescript-express-bcac5ed28248

Turkish: https://medium.com/@enescidem/typescript-express-ile-jwt-kimlik-doğrulama-ve-kullanıcı-yönetim-sistemi-b4ec1c66f723

This project demonstrates a RESTful API built with Node.js, Express, TypeScript, and MongoDB, featuring user authentication and CRUD operations. It was developed to practice backend architecture, authentication flows, database integration, and API testing using Restfox.


🚀 Features

  • Built with Node.js and Express
  • Written in TypeScript
  • Database: MongoDB
  • Authentication (login & register endpoints)
  • CRUD operations for data management
  • API testing with Restfox

📌 Overview

The API allows users to:

  • Register and log in securely with JWT authentication
  • Perform CRUD operations on stored data
  • Connect to a MongoDB database
  • Test endpoints easily using Restfox

⚙️ Project Setup

git clone https://github.com/username/repository-name.git
cd repository-name
npm install
npm run dev

Server runs at: http://localhost:8000


🔑 Authentication Flow

  1. Register → Create a new user with encrypted password.
  2. Login → Authenticate and receive a token.
  3. Use Token → Access protected routes (CRUD operations).

📸 Project in Action

1. Register a New User with Restfox

Register Restfox

2. User Saved in MongoDB

Register MongoDB

3. Wrong Login Attempt

Wrong Login Restfox

4. Correct Login – Token Returned

Correct Login Restfox

5. Login with Cookies Stored

Correct Login Cookies

6. Get All Users (Authorized Request)

Get Users Restfox

7. Register Another User via Restfox

Another Register Restfox

8. Verify Second User in MongoDB

Another Register MongoDB

9. Fetch Users Again

Get Users Again

10. Delete a User – Restfox

Delete User Restfox

11. Verify User Deleted – MongoDB

Delete User MongoDB

12. Fetch Users After Deletion

Get After Delete

13. Register One More User

Register Again

14. Get Users – Restfox

Get Users

15. Try Deleting Without Login (Unauthorized)

Delete Without Login

16. Login Again

Login Again

17. Delete User With Login (Authorized)

Delete With Login

18. Update User Information

Update Restfox

19. Verify Updated Data in MongoDB

MongoDB After Update


🛠️ Technologies Used

  • Node.js & Express
  • TypeScript
  • MongoDB & Mongoose
  • JWT Authentication
  • Restfox

📌 Conclusion

This project shows how to build a secure REST API with authentication, database operations, and clean TypeScript code. The screenshots illustrate the full flow — from registration to login, CRUD operations, and database verification.

It can be extended with:

  • Role-based authorization
  • Advanced input validation
  • Deployment on platforms like AWS, Render, or Docker

About

A REST API built with Node.js, TypeScript & MongoDB + Authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published