All Projects → ZenSoftware → bundled-nest

ZenSoftware / bundled-nest

Licence: other
💥 Nest 🔰 Webpack 🔰 Docker 💥 --- 🏯 Now archived for historical reference ⛩

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to bundled-nest

nestjs-objection
Objection module for NestJS
Stars: ✭ 24 (-59.32%)
Mutual labels:  nest, nestjs
nestjs-asyncapi
NestJS AsyncAPI module - generate the documentation of your event-based services using decorators
Stars: ✭ 88 (+49.15%)
Mutual labels:  nest, nestjs
Stator
Stator, your go-to template for the perfect stack. 😍🙏
Stars: ✭ 217 (+267.8%)
Mutual labels:  nest, nestjs
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+218.64%)
Mutual labels:  nest, nestjs
nestjs-telegraf
🤖 Powerful Nest module for easy and fast creation Telegram bots
Stars: ✭ 300 (+408.47%)
Mutual labels:  nest, nestjs
Mongoose
Mongoose module for Nest framework (node.js) 🍸
Stars: ✭ 191 (+223.73%)
Mutual labels:  nest, nestjs
Notadd
A microservice development architecture based on nest.js. —— 基于 Nest.js 的微服务开发架构。
Stars: ✭ 2,556 (+4232.2%)
Mutual labels:  nest, nestjs
Serverless Core
Serverless Core module for Nest framework (node.js) 🦊
Stars: ✭ 154 (+161.02%)
Mutual labels:  nest, nestjs
nestjs-ratelimiter
Distributed consistent flexible NestJS rate limiter based on Redis
Stars: ✭ 49 (-16.95%)
Mutual labels:  nest, nestjs
MyAPI
A template to create awesome APIs easily ⚡️
Stars: ✭ 117 (+98.31%)
Mutual labels:  nest, nestjs
Crud
NestJs CRUD for RESTful APIs
Stars: ✭ 2,709 (+4491.53%)
Mutual labels:  nest, nestjs
nest-queue
Queue manager for NestJS Framework for Redis (via bull package)
Stars: ✭ 69 (+16.95%)
Mutual labels:  nest, nestjs
Elasticsearch
Elasticsearch module based on the official elasticsearch package 🌿
Stars: ✭ 176 (+198.31%)
Mutual labels:  nest, nestjs
Passport
Passport module for Nest framework (node.js) 🔑
Stars: ✭ 211 (+257.63%)
Mutual labels:  nest, nestjs
Config
Configuration module for Nest framework (node.js) 🍓
Stars: ✭ 161 (+172.88%)
Mutual labels:  nest, nestjs
Nestjs Typegoose
Typegoose with NestJS
Stars: ✭ 215 (+264.41%)
Mutual labels:  nest, nestjs
Throttler
A rate limiting module for NestJS to work with Fastify, Express, GQL, Websockets, and RPC 🧭
Stars: ✭ 145 (+145.76%)
Mutual labels:  nest, nestjs
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (+145.76%)
Mutual labels:  nest, nestjs
Jwt
JWT utilities module based on the jsonwebtoken package 🔓
Stars: ✭ 232 (+293.22%)
Mutual labels:  nest, nestjs
twitch-project
A weekly stream in which I build a web application with Neo4j and Typescript
Stars: ✭ 78 (+32.2%)
Mutual labels:  nest, nestjs

💥 Nest 🔰 Webpack 🔰 Docker 💥

🏯 Now archived for historical reference

We've concluded that it is not recommended to bundle NestJS, or actually, NodeJS web servers in general. This is archived for historical reference during the period of time when the community was attempting to tree-shake, and bundle NestJS apps. Refer to @kamilmysliwiec comment for details:

In many real-world scenarios (depending on what libraries are being used), you should not bundle Node.js applications (not only NestJS applications) with all dependencies (external packages located in the node_modules folder). Although this may make your docker images smaller (due to tree-shaking), somewhat reduce the memory consumption, slightly increase the bootstrap time (which is particularly useful in the serverless environments), it won't work in combination with many popular libraries commonly used in the ecosystem. For instance, if you try to build NestJS (or just express) application with MongoDB, you will see the following error in your console:

Error: Cannot find module './drivers/node-mongodb-native/connection'
at webpackEmptyContext

Why? Because mongoose depends on mongodb which depends on kerberos (C++) and node-gyp.


For an example of how to build an enterprise-grade tech stack, please check out my new project:

Zen Nest + Prisma + Angular 🏮 Full Stack Starter Kit


Historical reference...

This repo is a starting point for others who wish to build a Nest app with minimal footprint. Bundling dependencies with Webpack, and containerized for Docker.

Size
production bundle of a main.js "Hello World!" 1.49 MB
Containerized as a Docker image node:12-alpine 81.9 MB

The Alpine variant of Node.js - Docker base image is being used for minimal footprint. Node.js v12 has improved startup times over an already performant startup process. This enables Nest to be an excellent solution for a microservice architecture. Allowing for efficient spinning up of new Kubernetes pods to meet compute demands, and disposed as necessary. Written in Typescript, Nest allows for a more familiar, and declarative development experience for writing modern web services. Check out the official docs to learn more.

This repo demonstrates the minimal amount needed to integrate a bundling system and containerize the app as a Docker image. Though for commercial projects, I would strongly suggest using a project management tool like Nx, by the company Nrwl. Getting Started with Nx. It makes full stack development with Nest simple. Nest schematics even work with Angular Console - VS Code Extension, with zero configuration needed.

This repo is produced from a fresh nest new command, using nest-cli, with minimal modifications. Currently there are some intricacies with bundling dependencies for a Nest app. (Issue: #1706) Comments are included in the Dockerfile and webpack.config.json for clarification. This repo addresses the known issues for you. 🥂

The following packages were added to the default package.json.

webpack@latest
webpack-cli@latest
ts-loader@latest
tsconfig-paths-webpack-plugin@latest  # For targeting "tsconfig.build.json"

3 scripts have been added to the package.json

# Bundle with webpack
npm run build:prod

# Build the docker image
npm run docker:build

# Run the docker image
npm run docker:run

For containerization, ensure your app uses the port from the environment if it exists.

"main.ts"

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // For Docker containerization
  const PORT = process.env.PORT || 3000;
  await app.listen(PORT);

  console.log(`Server is running at http://localhost:${PORT}`);
}
bootstrap();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].