Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lad

> 前端框架
Open source

Node.js framework made by a former @expressjs TC and @koajs team member. Built for @forwardemail, @spamscanner, @breejs, @cabinjs, and @lassjs.

2.3K stars0 likes2 views
WebsiteGitHub

About

Node.js framework made by a former @expressjs TC and @koajs team member. Built for @forwardemail, @spamscanner, @breejs, @cabinjs, and @lassjs.




Table of Contents

  • Features
    • Microservices
    • Front-end
    • Back-end
    • Translation
    • Email Engine
    • Error Handling
    • Performance
    • Security
  • Get Started
    • Requirements
    • Install
    • Usage
    • Configuration
    • Tutorials
    • Community
  • Architecture
  • Principles
  • Related
  • Contributing
  • Contributors
  • Trademark Notice
  • License

Features

Lad boasts dozens of features and is extremely configurable.

Microservices

These microservices are preconfigured for security, performance, and graceful reloading.

  • Webapp server → web.js
  • API server → api.js
  • Job scheduler → bree.js
  • Proxy server → proxy.js

Front-end

  • Browser linting using [eslint-plugin-compat][] and [browserslist][] (see .browserslistrc for the default config)
  • [Pug][] template engine (you can easily use [Moon][], [Vue][], [React][], or [Angular][], though typically [you aren't going to need it][yagni])
  • [Gulp][] (latest version 4.x)
  • [Sass][]
  • [PostCSS][] (with [font-magician][], [import-url][], [font-grabber][], [base64][], and [cssnext][] pre-configured)
  • [Bootstrap][]
  • [Font Awesome][font-awesome]
  • [SpinKit][]
  • [SweetAlert2][]
  • [Dense][]
  • [Waypoints][]
  • [LiveReload][]
  • …

Back-end

  • Redis, sessions, and flash toast and modal [SweetAlert2][] messages (uses [ioredis][] which has support for [Cluster][redis-cluster], [Sentinel][redis-sentinel], and more)
  • Koa-based webapp and API servers (uses HTTP/2 for production!)
  • Pagination built-in (using [ctx-paginate][])
  • RESTful API with BasicAuth and versioning
  • Automated job scheduler with cron and human-readable syntax (backed by [Mongoose][] and [Bree][])
  • Passport-based authentication and group-based (Unix-like) permissioning
  • Stripe-inspired error handling
  • Mongoose and MongoDB with common database plugins
  • Email template engine with [Nodemailer][] and local rendering
  • Proxy eliminates need for Nginx reverse-proxy or Apache virtual hosts
  • Multilingual through built-in i18n translation support (see configuration)
  • Automatic phrase translation with Google Translate
  • Sitemap generator for simple SEO
  • …

Translation

Finally a framework that solves i18n everywhere; complete with automatic translation.

  • Translation constants built-in so you [don't repeat yourself][dry]
  • Webapp error messages and templates are translated
  • Emails are translated
  • API responses are translated
  • Database errors are translated
  • Authentication errors are translated
  • …

Email Engine

Our beautiful email engine uses [email-templates][] (which is also made by the creator of Lad)!

  • Test your emails locally with automatic browser-rendering on the fly
  • Automatically inlines CSS for cross-browser and cross-platform email client support
  • Use [Bootstrap][] in your email template designs
  • Reuse your existing CSS and webapp styling
  • Use any template engine (defaults to Pug)
  • [Render custom fonts in emails with code][custom-fonts-in-emails]
  • [Add icons with Font Awesome with code][font-awesome-assets]
  • [Automatically avoid email client caching][nodemailer-base64-to-s3]
  • Include any image you want and it will be properly rendered
  • Rids the need for awkward embedded image CID attachments
  • …

Error Handling

We've spent a lot of time designing a beautiful error handler.

  • Supports text/html, application/json, and text response types
  • User-friendly responses
  • HTML error lists
  • …

See [koa-better-error-handler][] for a complete reference.

Performance

  • Compression and zero-bloat approach
  • Stream-based file uploading
  • Graceful reloading, shutdown, and reconnection handling
  • Manifest asset revisioning
  • Amazon S3 and CloudFront ready
  • …

Security

  • Database security plugins and helpers
  • Automated tests and code coverage
  • CORS, SameSite set to "lax" ([an alternative to CSRF][csrf-alternative]), CSRF (since [not all browsers][csrf-caniuse] support SameSite yet) XSS, and rate limited protection
  • Dotenv support for environment-based configurations
  • App, user, and request-based logging
  • SSL-ready (see instructions below)
  • …

Get Started

We strictly support Mac and Ubuntu-based operating systems (we do not support Windows).

Requirements

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

    • After installing nvm you will need to run nvm install node
    • We also recommend you install [yarn][], which is an alternative to [npm][]
  • [MongoDB][] (v3.x+):

    • Mac (via [brew][]): brew tap mongodb/brew && brew install mongodb-community && brew services start mongodb-community.

    • Ubuntu:

      bash
      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:

      bash
      sudo add-apt-repository -y ppa:chris-lea/redis-server
      sudo apt-get update
      sudo apt-get -y install redis-server

Install

[npm][]:

bash
npm install -g lad

[yarn][]:

bash
yarn global add lad

Usage

Create a project

bash
lad new-project
cd new-project

Development

To 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][]:

bash
npm start all

[yarn][]:

bash
yarn start all
Debugging
  • DEBUG - debug using [debug][] output (widely adopted package in the community for debugging across all Node packages):

    bash
    DEBUG=* ...
  • NODE_DEBUG - debug [node][] internal modules:

    bash
    NODE_DEBUG=* ...
  • MONGOOSE_DEBUG - debug Mongoose raw database operation output:

    bash
    MONGOOSE_DEBUG=true ...
  • TRANSPORT_DEBUG - debug Nodemailer transport:

    bash
    TRANSPORT_DEBUG=true ...
  • REDIS_MONITOR - debug Redis using MONITOR (uses [@ladjs/redis][ladjs-redis] and passes true for the monitor argument):

    bash
    REDIS_MONITOR=true ...
  • REDIS_FRIENDLY_ERROR_STACK - debug Redis with friendly error stack messages (see [showFriendlyErrorStack][show-friendly-error-stack] option of [ioredis][])

    bash
    REDIS_FRIENDLY_ERROR_STACK=true ...

Production

We strongly recommend using [SemaphoreCI][], [PM2][], and [Digital Ocean][do] for production deployment.

  1. 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.

  2. 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][].

  3. You can test this locally by installing [PM2][] globally with [npm][] or [yarn][], and then running the following command:

    bash
    NODE_ENV=production pm2 start
  4. See the Continuous Integration and Code Coverage and Tutorials sections below for instructions on how to setup continuous integration, code coverage, and deployment.

  5. 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.

Provisioning

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.

Deployment
  1. Set up host configuration by copying the hosts.yml file template:

    bash
    cp ansible/playbooks/templates/hosts.yml hosts.yml
  2. Edit 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.

    bash
    vim hosts.yml
  3. Set up environment configuration by copying the env file template:

    bash
    cp ansible/playbooks/templates/env .env.production
  4. Edit 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.

    bash
    vim .env.production
  5. Generate [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.

    bash
    node ansible-playbook ansible/playbooks/ecosystem.yml -l 'localhost'
  6. Set up the web and API server(s) (see patterns and ansible-playbook flags docs if you need he

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptapiasync-awaitavaaws

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架