altlokalt / ecombackend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NodeJS,Mongoose,Express Project in MVC Architecture

if mysql database How to update SQL (MySQL, PostgreSQL, SQL Server) database to DhiWise through VS Code? (New update) Copy the VS Code extension token from the platform and paste it into the access token field. Fill all the required SQL credentials That's it. Your SQL Database's Tables are added as Models in your application πŸ₯³

if postgres database server port username password

Supported version of nodejs >= 12, Supported version of mongoose >= 6

Version of displayed code:v1.0.1 Last build version:v1.0.1 Code architecture:MVC

CLI Quickly generate Node APIs and models. Installation Install DhiWise Node generator with the following command. npm i -g @dhiwise/node-generator

Create Model Create a single model file in the directory. dhi create-model

Crete API Create a single API in your specific module or platform. dhi create-api

Create Module This module will contain controller, CRUD operations, and other features. dhi create-module

Create Application Create boilerplate application. dhi create-app

ooops ntegrate your source code to GitHub or GitLab or download the source code. Download source code Synced with GitHubBranch name:altlokalt/ecombackend Repo URL:https://github.com/altlokalt/ecombackend Commit

API document Access your API documentation viewdocument blob:https://app.dhiwise.com/495773bf-fd7c-4dff-8647-85d6d5e662c6 or get the zip postman-collection from https://app.dhiwise.com/node/dashboard/641eaee842eacd0014b95eae or uploaded in google doc

About

  • This is a Node application, developed using MVC pattern with Node.js, ExpressJS, and Mongoose.
  • MongoDB database is used for data storage, with object modeling provided by Mongoose.

Initial

  1. $ npm install

  2. $ npm start

  3. Credentials

    • One user with User role,

    Default User credentials

    username : Caleb.Erdman69 password : QpPCXqEiR8eGjOj

    • One user with Admin role,

    Default Admin credentials

    username : Virgil.Jacobi19 password : H97DmukSybXgJTz

How to use generated APIs:

Click here to visit documentation

How to run with Docker ? :

  • if you have docker file you can execute following command
  • build the image $ docker build --pull --rm -f "Dockerfile" -t <imageName>:latest "."
  • execute the command $ docker run -p 3000:3000 <imageName>

Folder structure:

  β”œβ”€β”€ app.js       - starting point of the application
  β”œβ”€β”€ config
  β”‚   └── db.js    - contains api database connection
  β”œβ”€β”€ constants    - contains commonly used constants 
  β”œβ”€β”€ controllers               
  β”‚   └── platform - contains business logic
  β”œβ”€β”€ jobs         - cron jobs
  β”œβ”€β”€ models       - models of application
  β”œβ”€β”€ postman      - postman collection files
  β”œβ”€β”€ routes       - contains all the routes of application
  β”œβ”€β”€ services     - contains commonly used services
  β”œβ”€β”€ views        - templates
  └── utils        - contains utility functions    

Detail Description of Files and folders

  1. app.js
  • entry point of application.
  1. config
  • passport strategy files
  • database connection files
  1. constants
  • constants used across application.
  1. controllers
  • Controller files that contains Business logic
	β”œβ”€β”€ controller
		β”œβ”€β”€ platform
			└── modelNameController.js        - contains CRUD Operations
  1. jobs
  • Cron jobs
  1. middleware
  • Middleware files for authentication, authorization and role-access.
  1. models
  • Database models
  1. postman
  • Postman collection of APIs (Import this JSON in Postman to run the APIs)
  1. public
  • Assets used in application
  1. routes
	β”œβ”€β”€ routes
		β”œβ”€β”€ platform
			β”œβ”€β”€ modelNameRoutes.js   - contains CRUD operation routes
			└── index.js             - exports model Routes
		└── index.js                 - exports platform routes

  • index.js file, exports platform routes, imported into app.js to access all the routes.
  1. services
	β”œβ”€β”€ services
		β”œβ”€β”€ jobs                     - cron jobs
		└── auth.js                  - Authentication module service

  1. utils
	β”œβ”€β”€ utils
		β”œβ”€β”€ validations              - joi validations files for every model
		β”œβ”€β”€ dbService.js             - Database functions 
		β”œβ”€β”€ messages.js              - Messages used in sending response 
		β”œβ”€β”€ responseCode.js          - response codes 
		└── validateRequest.js       - validate request based on model schema

  1. env files
  • You can add credentials and port, database values as per your environment(Development/Production).
  • If you are running test environment then test cases will run using test database,and its configuration is there inside app.js

VS Code extension Download our VS Code extension to access and sync your application code directly to your VS Code IDE. Application token - https://app.dhiwise.com/node/dashboard/641eaee842eacd0014b95eae eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoiNjNmNTg4ZDIyNWUyMmUwMDIzODQ5YWRiIiwiX2lkIjoiNjNmNTg4ZDIyNWUyMmUwMDIzODQ5YWRiIn0sImNvbXBhbnlJZCI6IjYzZjU4OGQyMjVlMjJlMDAyMzg0OWFkZCIsImFwcGxpY2F0aW9uSWQiOiI2NDFlYWVlODQyZWFjZDAwMTRiOTVlYWUiLCJpYXQiOjE2Nzk3MzI0NTl9.AnfuL-PtUpn6aW383ciZe3J5bxqwqCiV6nPxoL1UDYs

Deploy application Deploy your code on sandbox or production. Deploy on production Take your app to production and beyond with a click. key 9add-5eae.dhi.codes

Deploy on sandbox Test your APIs before taking it to live. https://b95eae-kend-sandbox.dhiwise.co key b95eae-kend-sandbox.dhiwise.co

About