npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@e-square/nx-ddd

v1.2.0

Published

Enforces domain-driven design development

Downloads

8

Readme

@e-square/nx-ddd

npm GitHub

Enforces domain-driven design development.

✅ Support Angular and React

Table of Contents

  1. Prerequisites
  2. Overview
  3. Type of Libraries
  4. Installation
  5. Usage
  6. API
  7. How To Customize the Library Generator
  8. License

Prerequisites

Overview

Applications grow in size and complexity and in a large organization there are many ways to reuse code to maintain consistency and to lower the development effort.

Developing in a modular way can be done using libraries, which are simply a collection of related files that perform a certain task. These are composed together to make up an application.

Libraries require classifiers to describe their contents and intended purpose. These classifiers help to organize the libraries and to provide a way to locate them.

Scope

Scope relates to a logical grouping, business use-case, or domain contain libraries that manage a sub-domain of application logic.

Type

Type relates to the contents of the library and indicates its purpose and usage. Examples of types are data-access, feature, ui, and util.

Types of Libraries

Feature Libraries

Developers should consider feature libraries as libraries that implement smart UI (with access to data sources) for specific business use cases or pages in an application.

UI Libraries

A UI library contains only presentational components (also called "dumb" components).

Data-Access Libraries

A data-access library contains code for interacting with a back-end system. It also includes all the code related to state management.

  • state - for state files
  • application - for facades
  • entities - for interfaces, enums
  • infrastructure - for services

Utility Libraries

A utility library contains low-level utilities used by many libraries and applications.

Installation

npm i -D @e-square/nx-ddd

nx g @e-square/nx-ddd:init

OR

ng add @e-square/nx-ddd

Usage

Create a DDD Library

nx g @e-square/nx-ddd:library

Create an Angular ddd feature library example.

nx g @e-square/nx-ddd:library posts --framework angular --type feature --domain blog

Create a React ddd feature library example.

nx g @e-square/nx-ddd:library posts --framework react --type feature --domain blog

API

@e-square/nx-ddd:init

| Argument | Alias | Type | Default | Description | | ------------- | ----- | ------ | -------- | ------------------- | | sharedDomain | | string | 'shared' | The shared domain | | domainTagName | | string | 'scope' | The domain tag name |

@e-square/nx-ddd:library

| Argument | Alias | Type | Default | Description | | ------------------- | ----- | -------------------------------------------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | | framework | f | 'angular' | 'react' | '' | The framework to be used for library generation | | type | t | 'feature' | 'ui' | 'data-access' | 'util' | 'data-access' | The library type | | name | | string | '' | The name of the library | | domain | d | string | '' | The domain the library belongs to | | directory | | string | '' | A directory where the library is placed inside the domain directory | | withoutTypePrefix | | boolean | false | Create the library inside library type directory <domainName>/<libraryType>-<libraryName> to <domainName>/<libraryType>/<libraryName> | | standaloneConfig | | boolean | false | Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json |

How To Customize the Library Generator

There are situations you need to customize the generated files more than what exists today.

It's very easy to customize existing generators with nx workspace generators.

This library exposed the generators to allow customization.

Create Nx Workspace Generator

nx g workspace-generator shared-ui

Update The Generator Implementation

import { formatFiles, readProjectConfiguration, Tree } from '@nrwl/devkit';

import {
  DDDLibraryFramework,
  dddLibraryGenerator,
  DDDLibraryType,
} from '@e-square/nx-ddd';

import { SharedUIScheme } from './scheme';

export default async (tree: Tree, { name }: SharedUIScheme): Promise<void> => {
  // Creates the library and return dddLibraryStructure object.
  const dddLibraryStructure = await dddLibraryGenerator(tree, {
    name,
    framework: DDDLibraryFramework.Angular,
    type: DDDLibraryType.UI,
    domain: 'shared',
    withoutTypePrefix: true,
    standaloneConfig: true,
  });

  // Let's read the project which was created.
  const projectConfiguration = readProjectConfiguration(
    tree,
    dddLibraryStructure.project
  );

  /**
   * Here you can use the projectConfiguration
   * For adding, deleting and updating files.
   */

  await formatFiles(tree);
};

Run The Generator

nx workspace-generator shared-ui --name button

License

MIT