Skip to content

dalcorta/typescript-crud

Repository files navigation

CRUD Application Using Typescript, Node.js, Express, MongoDB and Inversify.

Table of Contents

Dependency

  • Typescript: TypeScript is a superset of JavaScript that adds static typing to the language. It compiles to JavaScript and can be used both in browser environments and in server-side environments like Node.js. Typesript also support generic class, type annotation, interface, enums, union type, private-protected memmber while JavaScript doesn't support.

  • Node.js: Node.js is a runtime environment that enables you to run JavaScript code on the server side.

  • Express: Express is a web application framework for Node.js that simplifies building APIs and web applications by providing a set of tools and utilities. It's like SpringBoot in Java, Django in Phyton, .Net for C#.

  • MongoDB: MongoDB is a NoSQL database system designed for storing and managing unstructured or semi-structured data.

  • Mongoose: Mongoose is an ODM library for MongoDB and Node.js. It simplifies interacting with MongoDB by providing a structured way to define schemas, models, and additional functionality.

  • Inversify: It deals with how components or classes obtain their dependencies without creating them directly. Instead of creating dependencies within a class, dependencies are "injected" from the outside.

Features

  • Establishing a MongoDB connection and transactions with mongoose ODM,
  • Route handling mechanism using Express.js framework,
  • Interface, enum, type alias, static typing, access modifiers, default parametre usage,
  • Dependency injection using Inversify,
  • Using Repository-MVC pattern,
  • Exact string match search like ?search=text%20most,
  • Data filtering like ?filter=likes:2-10,
  • Pagination posts/pagination?pi=2,
  • Sorting for fields ?sort=likes&orderby=asc | ?sort=title&orderby=desc | sort=author&orderby=desc,
  • Query combination-query pool;

?sort=description&pi=3 ?sort=title&orderby=desc&pi=2 ?q=find%20me&sort=author&orderby=asc&pi=2 ?sort=likes&orderby=asc&filter=likes:3-24&pi=2 ?sort=description&orderby=descpription&filter=likes:3-10&pi=1

Architecture

tree /f

Installation

git clone https://github.com/ahmetozydn/typescript-crud.git
cd yourproject
npm install
# After establishing your MongoDB connection!
npm start

Test

  • postman is used to test endpoints.

  • Query Combination;

pagination delete image

  • CRUD operations;
get a post delete a post
get all posts image delete a post image
get all posts create a post
get all posts image create a post image

Further topics

  • Architecture improvement
  • Generating dynamic di for pagination class,
  • Custom error handler mechanism,
  • Authentication, authorization,
  • Partial searching method for MongoDB because it doesn't provide efficient way
  • Rate limiting, caching
  • Handling file uploads through API endpoints.
  • Understanding CORS and configuring it for your API.
  • Support for multiple languages and locales.

About

Ejemplo Typescript Crud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published