Git Product home page Git Product logo

nodejs-ts-fastify-handler-service-model's Introduction

nodejs-app-structure-init

REST API


Table of Contents
  1. About The Project
  2. Getting Started

About The Project


App starter REST API With Node.js Fastify MongoDB - Typescript

(back to top)

Structure

Routes-Handlers-Servicess-Structure

📦nodejs-app-structure-init
 ┣ 📂src
 ┃ ┣ 📂config
 ┃ ┃ ┣ 📂swagger
 ┃ ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┃ ┗ 📜swagger.option.ts
 ┃ ┃ ┣ 📜config.ts
 ┃ ┃ ┣ 📜database.config.ts
 ┃ ┃ ┗ 📜index.ts
 ┃ ┣ 📂errors
 ┃ ┃ ┣ 📜article.errors.ts
 ┃ ┃ ┣ 📜auth.errors.ts
 ┃ ┃ ┗ 📜index.ts
 ┃ ┣ 📂handlers
 ┃ ┃ ┣ 📜article.handler.ts
 ┃ ┃ ┣ 📜auth.handler.ts
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜user.handler.ts
 ┃ ┣ 📂helpers
 ┃ ┣ 📂hooks
 ┃ ┃ ┣ 📜auth.hook.ts
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜protectedRoutes.hook.ts
 ┃ ┣ 📂interfaces
 ┃ ┃ ┗ 📂types
 ┃ ┃ ┃ ┣ 📂handlers
 ┃ ┃ ┃ ┃ ┣ 📜article.handler.types.ts
 ┃ ┃ ┃ ┃ ┗ 📜auth.handler.types.ts
 ┃ ┃ ┃ ┣ 📂hooks
 ┃ ┃ ┃ ┃ ┗ 📜auth.hook.types.ts
 ┃ ┃ ┃ ┗ 📂models
 ┃ ┃ ┃ ┃ ┣ 📜article.model.types.ts
 ┃ ┃ ┃ ┃ ┗ 📜user.model.types.ts
 ┃ ┣ 📂models
 ┃ ┃ ┣ 📜article.model.ts
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜users.model.ts
 ┃ ┣ 📂redis
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜redisClient.ts
 ┃ ┣ 📂routes
 ┃ ┃ ┣ 📂swagger-schema
 ┃ ┃ ┃ ┣ 📜article.route.schema.ts
 ┃ ┃ ┃ ┣ 📜auth.route.schema.ts
 ┃ ┃ ┃ ┗ 📜users.route.schema.ts
 ┃ ┃ ┣ 📜article.route.ts
 ┃ ┃ ┣ 📜auth.route.ts
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜users.route.ts
 ┃ ┣ 📂services
 ┃ ┃ ┣ 📜article.service.ts
 ┃ ┃ ┣ 📜index.ts
 ┃ ┃ ┗ 📜user.service.ts
 ┃ ┣ 📂utils
 ┃ ┃ ┣ 📜custom-error.ts
 ┃ ┃ ┗ 📜logger.ts
 ┃ ┣ 📜app.spec.ts
 ┃ ┗ 📜app.ts
 ┣ 📜.env
 ┣ 📜.eslintrc.ts
 ┣ 📜.gitignore
 ┣ 📜.prettierrc.ts
 ┣ 📜index.ts
 ┣ 📜jest.config.ts
 ┣ 📜package-lock.json
 ┣ 📜package.json
 ┣ 📜README.md
 ┣ 📜tsconfig.json
 ┣ 📜yarn.lock
 ┗ 📜[.]env

Built With

(back to top)

Getting Started

  • models - The schema definition of the Model

  • routes - The API routes maps to the handlers

  • handlers - The handlers handles all the logic behind validating request parameters, query, Sending Responses with correct codes.

  • services - The services contains the database queries and returning objects or throwing errors

  • interfaces/types - typescript interfaces

  • errors - Error type definitions

  • utils - Frequently used utility functions

Ref.route-controller-service-structure-for-expressjs

Prerequisites

  • npm
    npm install npm@latest -g

Installation

  1. Clone the repo
    git clone https://github.com/billowdev/nodejs-app-structure-init.git
  2. Install NPM packages
    npm install
  3. Enter your ENV in .env
  PORT=5000 | Your port
  JWT_SECRET=YourJWTSecret
  NODE_ENV=development
  CLIENT_URL=localhost

  REDIS_HOST=localhost
  REDIS_PORT=6379
  REDIS_USERNAME=default
  REDIS_PASSWORD=REDISPASSWORD
  REDIS_DATABASE=0
  REDIS_BIND=0.0.0.0

  DB_USERNAME= Your username for database
  DB_PASSWORD= Your password for database
  DB_DATABASE_DEVELOPMENT= database name for development
  DB_DATABASE_PRODUCTION= database name for production
  DB_DATABASE_TEST= database name for test
  DB_HOST=localhost | your host
  DB_DIALECT=postgres | mysql | your dialect

(back to top)

nodejs-ts-fastify-handler-service-model's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.