Node.js framework made by a former @expressjs TC and @koajs team member. Built for @forwardemail, @spamscanner, @breejs, @cabinjs, and @lassjs.
Node.js framework made by a former @expressjs TC and @koajs team member. Built for @forwardemail, @spamscanner, @breejs, @cabinjs, and @lassjs.
Lad boasts dozens of features and is extremely configurable.
These microservices are preconfigured for security, performance, and graceful reloading.
Finally a framework that solves i18n everywhere; complete with automatic translation.
Our beautiful email engine uses [email-templates][] (which is also made by the creator of Lad)!
We've spent a lot of time designing a beautiful error handler.
text/html, application/json, and text response typesSee [koa-better-error-handler][] for a complete reference.
We strictly support Mac and Ubuntu-based operating systems (we do not support Windows).
Please ensure your operating system has the following software installed:
[Git][] - see [GitHub's tutorial][github-git] for installation
[Node.js][node] (v10+) - use [nvm][] to install it on any OS
nvm you will need to run nvm install node[MongoDB][] (v3.x+):
Mac (via [brew][]): brew tap mongodb/brew && brew install mongodb-community && brew services start mongodb-community.
Ubuntu:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get -y install mongodb-org[Redis][] (v4.x+):
Mac (via [brew][]): brew install redis && brew services start redis
Ubuntu:
sudo add-apt-repository -y ppa:chris-lea/redis-server
sudo apt-get update
sudo apt-get -y install redis-server[npm][]:
npm install -g lad[yarn][]:
yarn global add ladlad new-project
cd new-projectTo begin, try typing npm start (or yarn start) on command line. This will display to you all the scripts you can run.
The start script (among many others) uses [nps][] and [nps-utils][] under the hood. This helps to keep scripts very developer-friendly, and rids the need to write in JSON syntax.
This script accepts a <task> argument, whereas a task of all will spawn, watch, and re-compile all of the microservices mentioned above.
Just open http://localhost:3000 for testing!
[npm][]:
npm start all[yarn][]:
yarn start allDEBUG - debug using [debug][] output (widely adopted package in the community for debugging across all Node packages):
DEBUG=* ...NODE_DEBUG - debug [node][] internal modules:
NODE_DEBUG=* ...MONGOOSE_DEBUG - debug Mongoose raw database operation output:
MONGOOSE_DEBUG=true ...TRANSPORT_DEBUG - debug Nodemailer transport:
TRANSPORT_DEBUG=true ...REDIS_MONITOR - debug Redis using MONITOR (uses [@ladjs/redis][ladjs-redis] and passes true for the monitor argument):
REDIS_MONITOR=true ...REDIS_FRIENDLY_ERROR_STACK - debug Redis with friendly error stack messages (see [showFriendlyErrorStack][show-friendly-error-stack] option of [ioredis][])
REDIS_FRIENDLY_ERROR_STACK=true ...We strongly recommend using [SemaphoreCI][], [PM2][], and [Digital Ocean][do] for production deployment.
We've provided you with a preconfigured ecosystem.json deployment file. You will need to modify this file with your server's IP, hostname, and other metadata if needed.
Make sure that your project's assets are built with NODE_ENV=production flag, e.g. NODE_ENV=production npm run build (or with yarn as yarn build);this creates a build/rev-manifest.json file per [koa-manifest-rev][].
You can test this locally by installing [PM2][] globally with [npm][] or [yarn][], and then running the following command:
NODE_ENV=production pm2 startSee the Continuous Integration and Code Coverage and Tutorials sections below for instructions on how to setup continuous integration, code coverage, and deployment.
If you specify an environment variable value for AWS_CF_DOMAIN and NODE_ENV=production is set then your assets will need to be published to Amazon S3/Cloudfront. To do so run npm start publish-assets (or with yarn as yarn start publish-assets). This command automatically sets NODE_ENV=production for you as well via cross-env.
See the ansible folder for our [Ansible][] configuration and playbooks, which we use to provision servers with.
We recommend you to install [yamllint][] and configure it in your editor while working with [Ansible][] playbooks.
Also note that [ansible-lint][] is a helpful linting tool you can use if you plan on making changes to playbooks. Note that our current playbooks have several existing lint errors.
First you must provision Ubuntu 18.04 LTS 64-bit server(s) using [Digital Ocean][digital-ocean], [Linode][], [Vultr][], or your host of choice. These newly provisioned server(s) should have your SSH key automatically added.
Follow the Deployment guide below for automatic provisioning and deployment instructions.
Set up host configuration by copying the hosts.yml file template:
cp ansible/playbooks/templates/hosts.yml hosts.ymlEdit this configuration and update the file with your newly created server aliases and IP addresses. You can add more than one host to each group if you are setting up load balancing. Refer to the Naming Convention documentation for our recommended approach to server alias naming. Note that this file is automatically ignored by git. If you have a private repository and would like to commit this, then remove hosts.yml from the root .gitignore file.
vim hosts.ymlSet up environment configuration by copying the env file template:
cp ansible/playbooks/templates/env .env.productionEdit this configuration and reference the official [Lad][] documentation for a list of all available environment variables (or see .env.defaults). You will need to open this file in your preferred editor and set the values for any fields containing TODO, whereby you replace TODO with the appropriate value. Preserve double quotes where they are already defined.
vim .env.productionGenerate [pm2][] [ecosystem files][ecosystem-files] using our automatic template generator. We created an ansible-playbook.js which loads the .env.production environment variables rendered with [@ladjs/env][] into process.env, which then gets used in the playbooks. This is a superior, simple, and the only known dotenv approach we know of in Ansible. Newly created ecosystem-api.json, ecosystem-bree.json, ecosystem-web.json files will now be created for you in the root of the repository. If you ever more add or change IP addresses, you can simply re-run this command.
node ansible-playbook ansible/playbooks/ecosystem.yml -l 'localhost'Set up the web and API server(s) (see patterns and ansible-playbook flags docs if you need he
No open issues yet, or sync has not completed.