Lad – The best Node.js framework

Lad – The best Node.js framework

2022-10-31 0 1,283
Resource Number 47259 Last Updated 2025-02-21
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

The Lad recommended in this issue is the best Node.js framework, made by former Express TC and Koa team members.

Lad – The best Node.js framework插图

Lad feature

Lad has dozens of features and is very configurable.

Microservices

These microservices are pre-configured for security, performance, and elegant reloads.

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

< Back end

  • Redis, session, Flash toast, and schema SweetAlert2 messages (using ioredis that supports Cluster, Sentinel, etc.)
  • Koa based webapp and API server (production using HTTP/2!)
  • Built-in paging (use ctx-paginate)
  • RESTful API with BasicAuth and version control
  • Automated job scheduler with cron and human-readable syntax (supported by Mongoose and Bree)
  • Passport-based authentication and group-based (Unix-like) licensing
  • Stripe inspired error handling
  • Mongoose and MongoDB with universal database plug-ins
  • Email template engine with Nodemailer and local rendering
  • Proxy eliminates the need for an Nginx reverse proxy or Apache virtual host
  • Support for multiple languages via built-in i18n translation (see Configuration)
  • Sitemap generator for simple SEO

< Performance

  • Compression and zero expansion methods
  • Stream-based file upload
  • Elegant reload, close, and reconnect handling
  • List Asset revision
  • Ready Amazon S3 and CloudFront

Start using

Strict support for Mac and Ubuntu-based operating systems (not Windows).

< Requirements

Make sure you have the following software installed on your operating system:

  • Git – see GitHub installation tutorial
  • Node.js (v10+) – Install it on any operating system using nvm
    • nvm needs to run after installation nvm install node
    • It is recommended that 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:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc) "/ mongo - 3.4 - / - org multiverse" < / span > | sudo tee/etc/apt/sources list. D/mongo - org < span Class = "HLJS - number" > 3.4 < / span >. 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

Install

npm:

npm install -g lad

yarn:

yarn global add lad

< Usage

Create project

lad new-project
cd new-project

First, try typing npm start(or) on the command line. yarn start This will show you all the scripts you can run.

This start script (and many others) uses nps and nps-utils in the background.

The script accepts an < task> Parameter, and a task all will generate, monitor, and recompile all of the above microservices.

Just open http://localhost:3000 and test!

npm:

npm start all

yarn:

yarn start all

< Debugging

  • DEBUG- Debug using debug output (a widely adopted package in the community for debugging across all Node packages) :
DEBUG=* ... 
  • NODE_DEBUG- Debugs internal modules of a node:
NODE_DEBUG=* ... 
  • MONGOOSE_DEBUG- Debug Mongoose original database operation output:
MONGOOSE_DEBUG=true ... 
  • TRANSPORT_DEBUG- debug Nodemailer transport:
TRANSPORT_DEBUG=true

REDIS_MONITOR- Debug Redis using MONITOR (use @ladjs /redis and pass parameters) : truemonitor

REDIS_MONITOR=true ... 
  • REDIS_FRIENDLY_ERROR_STACK- Debug Redis with friendly error stack messages (see showFriendlyErrorStack option for ioredis)
REDIS_FRIENDLY_ERROR_STACK=true ... 

Configuration

Environment variable

According to Twelve-Factor, we simplified the configuration of the Lad project with the dotenv configuration package named @ladjs/env.

We use the following three packages to manage configuration:

  • dotenv-extended – allows us to use.env in a file called.env.schema
  • mustache – allows us to use the Mustache template language in our configuration files. env.env.defaults
  • dotenv-parse-variables – automatically parses the variable type process.env (e.g., FOO=4 will set process.env.FOO =4 as the Number variable type instead of a String)

The configuration is managed by the following in order of priority:

  • File contents located in config/index.js (read process.env environment variable)
  • Contents of the files in the directory config/environments/ (Setting default values for each environment, for example, you can use NODE_ENV=staging, It will load the config file/environments/staging. Js) < / li >
  • Used to override defaults or set required environment variables (e.g. NODE_ENV=production)
  • Environment configuration in.env
  • Environment Settings in.env.defaults

The priority is the environment profile, the environment variables, and then the.env file.

Basically, if dotenv has detected that it was passed as an environment variable, it will not set the environment variable.

View the contents of the config folder and the default values of.env.defaults.

Continuous integration and code coverage

Here are the simple steps needed to set up SemaphoreCI using Codecov:

  • Go to SemaphoreCI and sign up for a free account
  • After pushing the repository to GitHub, add it as a project to SemaphoreCI
  • Configure your project on SemaphoreCI using the following build Settings:
  • Add your project on Codecov and copy the token to the clipboard
  • Set and add CODECOV_TOKEN as the environment variable for your project to go to SemaphoreCI (using the contents from the clipboard)
  • Run the test build on SemaphoreCI (” rebuild the latest version “) and check to make sure your code coverage report is uploaded correctly on Codecov
  • Make sure your README.md file has properly rendered build status and code coverage tags (if your GitHub repository is private, you’ll need to use different tag links from each provider)

—END—

Open Source license: MIT license

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code Lad – The best Node.js framework https://ictcoder.com/lad-the-best-node-js-framework/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services