Easy to learn and use TypeScript Express.js server with REST, GraphQL, and MongoDB using Minimal MEAN for Lemon Mart
Watch the video: Do More with Less: Full Stack TypeScript
Get the book: Lemon Mart Server is covered in my book Angular for Enterprise Applications. You can get it at AngularForEnterprise.com.
npm install
npm install
on all child folders.npm run init:env
to configure your environment variables in .env
filesSkip over this if you already ran the automated command
.env
file at the project's root and set the MongoDB admin password. 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 duluca/minimal-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 container's name 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
.env
file under Server for development purposes. Note: We specify localhost, not the docker-compose name here.MONGO_URI=mongodb://john.smith:g00fy@localhost:27017/acme
npm start
docker-compose up
, which will build and configure your web app, server, and database.npm stop
or npm clean
to stop or clean Docker's cache.cd web-app
then npm start
-- which utilizes ng serve
and will give you live reload. To debug, use Angular DevToolscd server
then npm run watch
or use the debugger within VS Code (debug configuration is already included)npm start:database
from the rootdocker-compose.aws.yml
to pull from the ECS repositorynpm run publish:aws
on the root folder to create the task definitionThe OpenAPI schema for the project is hosted on /api-docs
using SwaggerUI.
Apollo Explorer is hosted on /graphql
.