Code Monkey home page Code Monkey logo

lemon-mart-server's Introduction

LemonMart Server LemonMart Server

Easy to learn and use TypeScript Node.js server using Minimal MEAN for Lemon Mart

Angular Version CircleCI DeepScan grade Coverage Status

Watch the video: Do More with Less: Full Stack TypeScript

Get the book: Lemon Mart Server is covered in my book Angular for Enterprise-Ready Web Applications. You can get it on https://AngularForEnterprise.com.

Setup

  • Install Node.js v8.3+
  • Recommended Editor/IDE: Visual Studio Code
  • For a magical development experience download these VS Code Extensions:
  • npm install
  • This will kick off a script, which will run npm install on all child folders.
  • Run npm run init:env to configure your environment variables in .env files

Manually Setup Environment Variables

Skip over this if you ran the automated command

  • Define a .env file at the root of the project and set the MongoDB admin passowrd. Do NOT commit this file.
MONGODB_ADMIN_PASS=your_password_goes_here
MONGODB_APPLICATION_DATABASE=app_db_name
MONGODB_APPLICATION_USER=app_user
MONGODB_APPLICATION_PASS=app_password
MONGO_URI=uri_to_mongodb
  • See more details about the MongoDB Docker container at excellalabs/mongo which also contains instructions on how to set things up on AWS ECS.

    In your server application use the application information to connect to the database. Sample connection URI: mongodb://app_user:app_password@localhost:27017/app_db_name?readPreference=primary

  • Sample .env file. Note: In configuring the MONGO_URI, instead of localhost or an IP address, you must specify database which is the name of the container as defined in docker-compose.yml file.

MONGODB_ADMIN_PASS=admin
MONGODB_APPLICATION_DATABASE=acme
MONGODB_APPLICATION_USER=john.smith
MONGODB_APPLICATION_PASS=g00fy
MONGO_URI=mongodb://john.smith:g00fy@database/acme
  • You need a seperate .env file under Server for development purposses. Note: We specify localhost, not the docker-compose name here.
MONGO_URI=mongodb://john.smith:g00fy@localhost:27017/acme

Run

Development

  • For development purposes run each service individually
    • Angular Web App: cd web-app then npm start -- which utilizes ng serve and will give you livereload. To debug use Augury
    • Server: cd server then npm start or use the debugger within VS Code (debug configuration is already included)
    • Database: npm start:database from the root

Architecture

  • web-app: This folder contains the client side Angular app, configured using Angular CLI along with its own individual Node.js server
  • server: This folder contains the server side Node.js app that can be used to serve REST APIs and it is capable of connecting to MongoDB
  • document-ts: The library to connect and query Mongo in an async, flexible and convenient manner
  • duluca/minimal-mongo: A fully-featured Mongo image (with Auth and SSL) inherited from the official image.

Continuous Integration and Hosting

  • CI is implemented on CircleCI CircleCI
  • Hosted on AWS ECS
    • You'll need to individually publish your Docker containers to ECS
    • Then update docker-compose.aws.yml to pull from the ECS repository
    • Run npm run publish:aws on the root folder to create the task definition
    • You'll need to create a new service and attach this task definition to it
    • See the Step-by-Step AWS ECS Guide on how to create container repositories, and attaching a task definition to a service here.
    • See the Configuring AWS ECS to have access to AWS EFS Guide to persist data using MongoDB here.

lemon-mart-server's People

Contributors

duluca avatar

Watchers

James Cloos 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.