Component-based node server architecture that is dockerized and ready for deployment

Overview

Introduction

Component based node server architecture that is dockerized and ready for deployment

Installation

  • clone the repo and then cd NODE-SERVER

Setup docker environment

  • Create .env file which will be consumed via docker-compose.yml

    • nano .env and paste the following variables

          # will be used by only in docker file to inject variables in docker-compose.yml
          # port will set by docker only
          PORT=5050
          DB_PORT=5090
          DB_NAME=node_db
          DB_USERNAME=username
          DB_PASSWORD=password
      
          BASE_URL=https://localhost:5090/
          KEY_PATH=server.key
      
      REDIS_PASS=NODE_dev_redis
      
      
      - **NOTE:** all these variables will only be consumed via `docker-compose.yml` file and will not affect the code.
      - `BASE_URL` is the url which our node app is running
      - `PORT` is the port which app will be running on via `docker-compose up` **(this value can be changed as you want)**
      - `DB_PORT` is the port will be exposed to your `localhost` incase you want to connect to db vai any tool _eg. no sql booster_ **(this value can be changed as you want)**
      - Other variables is straight forward to conclude.
      
  • Create docker.env file which you will be using in code in docker environment

    • nano docker.env and paste the following variables

              # will be used in code in docker environment
      
              DB_HOST=NODEdb
              DB_PORT=27017
              DB_NAME=node_db
              DB_USERNAME=username
              DB_PASSWORD=password
              jwtPrivateKey=123
      
          REDIS_PASS=node_dev_redis
          # should be the redis container name
          REDIS_HOST=cache
      
          BASE_URL=https://localhost:5050
          KEY_PATH=server.key
      
      
      - `BASE_URL` is the url which our node app is running
      - `DB_HOST` is the name of the host of our db in docker environment.
      - `DB_PORT` is the port which we will use to connect to db via code.
        - **NOTE** This port value should be _27017_ cuz we are connecting to the image(NODEdb) itself not the mapping port in our host(localhost)
      - Other variables is straight forward to conclude.
      
  • Happy coding via docker-compose up

    • Your app is running and accessible on localhost:${PORT} => which comes from .env file
    • Your app is running and accessible on mongodb://${DB_USERNAME}:${DB_PASSWORD}@localhost:${PORT}/?authSource=admin => which comes from .env file

Setup local environment

If you want to run local/debug but on same db on docker follow the below steps 👇 👇

  • Create local.env file which you will be using in code in local/debug environment

    • nano local.env and paste the following variables

             # will be used in code in local and debug environment
      
            PORT=6060
            DB_HOST=localhost
      
              # should be exactly as DB_PORT in .env when running on docker db
              #                but if we want to connect to local mongo host should be 27017
              DB_PORT=5090
              DB_NAME=node_db
              DB_USERNAME=username
              DB_PASSWORD=password
              jwtPrivateKey=123
      
              REDIS_PASS=NODE_dev_redis
              REDIS_HOST=localhost
      
              BASE_URL=https://localhost:5090/
              CERT_PATH=server.cert
              KEY_PATH=server.key
      • To work with redis you will need to run the compose(at least the redis service)
      • PORT is the port which app will be running on in local/debug mode (this value can be changed as you want)
      • BASE_URL is the url which our node app is running
      • DB_HOST is the name of the host of our db in local/debug mode.
      • DB_PORT is the port which we will use to connect to db via code.
        • NOTE This port value should be same as DB_PORT in .env file cuz we are connecting to the db which is running on the image(NODEdb).
      • Other variables is straight forward to conclude.

If you want to run local/debug but on the host db

  • Do the last steps in setting up local.env file but change the DB_PORT to 27017

  • Happy coding via npm run local/ debug mode by F5

Configuration environment

ADMIN CREDENTIALS

  • ADMIN_USERNAME: is the admin login phone number and must to be a valid mobile
  • ADMIN_PASSWORD: is the admin login password
You might also like...

✨ Create server-rendered universal JavaScript applications with no configuration

✨ Create server-rendered universal JavaScript applications with no configuration

Universal JavaScript applications are tough to setup. Either you buy into a framework like Next.js or Nuxt, fork a boilerplate, or set things up yours

Jan 8, 2023

A NodeJS Express server that uses Prisma ORM.

Express - Prisma Template (Typescript) A NodeJS Express server that uses Prisma ORM. Stack NodeJS Express Prisma TypeScript File Structure src/config

Feb 4, 2022

Apollo Server Express Boilerplate

Boilerplate for graphql and graphql-ws using Apollo Server Express and powered by TypeORM and TypeGraphQL to make your work is quicker and easier.

Dec 14, 2022

Localtunnel module for Nuxt to allow remote/external access to your Nuxt development server.

Nuxt Localtunnel A Nuxt module for automatically running localtunnnel to externally expose your development instance of Nuxt to the outside world. All

Sep 7, 2022

X-Netflix is a streaming platform based on Netflix UI: built with ReactJS in frontend and nodeJS in backend.

X-Netflix is a streaming platform based on Netflix UI: built with ReactJS in frontend and nodeJS in backend.

X-Netflix X-Netflix is a streaming platform based on Netflix UI: built with ReactJS in frontend and nodeJS in backend. Built with FrontEnd: React.JS,

Aug 19, 2022

Hi there! This is a react native starter which used to build a awesome Event Booking App based on the Figma design. You can download or clone it to speed up your projects.

Hi there! This is a react native starter which used to build a awesome Event Booking App based on the Figma design. You can download or clone it to speed up your projects.

mcrn-event-booking-app-starter Hi there! This is a react native starter which used to build a awesome Event Booking App based on the Figma design. You

Dec 19, 2022

Web applications with node.js and React

Electrode Web Applications with node.js and React The Electrode project was developed to make node.js and React the primary tech choices for developin

Dec 10, 2022

This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the back end implementation and there is the React implementation as the front end

This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the back end implementation and there is the React implementation as the front end

Versão em português MERN stack This is a template project demonstrating how the MERN stack(Mongo, Express, React, Node) can be used, here we have the

Jan 22, 2022

A boilerplate for REST API Development with Node.js, Express, and MongoDB using TypesScript

node-mongo-boilerplate A simple boilerplate for NODEJS, EXPRESS and MONGODB REST API development . Quick Start Make sure you have node.js v14 + npm v8

Oct 16, 2022
Owner
Ahmed Mashhour
Ahmed Mashhour
A boilerplate for building production-ready RESTful APIs using Node.js, Express, and Mongoose

By running a single command, you will get a production-ready Node.js app installed and fully configured on your machine. The app comes with many built-in features, such as authentication using JWT, request validation, unit and integration tests, continuous integration, docker support, API documentation, pagination, etc. For more details, check the features list below.

Hagop Jamkojian 5k Dec 31, 2022
DDD/Clean Architecture inspired boilerplate for Node web APIs

Node API boilerplate An opinionated boilerplate for Node web APIs focused on separation of concerns and scalability. Features Multilayer folder struct

Talysson de Oliveira Cassiano 3k Dec 30, 2022
👩🏻‍💻 Developer Ready: A comprehensive template. Works out of the box for most Node.js projects.

node-typescript-boilerplate ????‍?? Developer Ready: A comprehensive template. Works out of the box for most Node.js projects. ???? Instant Value: All

IAD S.r.l. 6 Dec 15, 2022
About Folder pattern for express rest api starterkit clean architecture, easy to scalable and easy to maintenance.

Express Rest Api Clean Architecture The following is a folder pattern for express rest api starterkit structure pattern that I usually use, so if you

Restu Wahyu Saputra 50 Dec 20, 2022
React Native Boilerplate - The Boilerplate contains all the basic packages, common components and, prebuilt code architecture

The Boilerplate contains all the basic packages, common components and, prebuilt code architecture. It will save developer's project setup time.

MindInventory 36 Dec 26, 2022
A highly opinionated and complete starter for Next.js projects ready to production

The aim for this starter is to give you a starting point with everything ready to work and launch to production. Web Vitals with 100% by default. Folder structure ready. Tooling ready. SEO ready. SSR ready.

Fukuro Studio 28 Nov 27, 2022
Express Graphql Clean Architecture

Folder pattern for express graphql starterkit clean architecture, easy to scalable and easy to maintenance, explore documentation for more about this starterkit https://typegraphql.com

Restu Wahyu Saputra 10 Aug 14, 2022
Next Boilerplate with TypeScript, Redux Toolkit and Styled-Component.. For now

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Ibrahim Yaacob 2 Feb 17, 2022
An upgradable boilerplate for Progressive web applications (PWA) with server side rendering, build with SEO in mind and achieving max page speed and optimized user experience.

React PWA v2 A highly scalable, Progressive Web Application foundation,boilerplate, with the best Developer Experience. Demo: https://demo.reactpwa.co

Atyantik 2.5k Dec 26, 2022
A starter project to run your local server, and start sending voice packets to Deepgram

A starter project to run your local server, and start sending voice packets to Deepgram

Filip Grebowski 7 Sep 30, 2022