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

ngpathway

v0.7.4

Published

NgPathway is a file-based router utilities library for Angular applications. It simplifies the process of creating and managing routes in your Angular app by allowing you to organize your routes in a directory structure that mirrors your application's UI

Downloads

5

Readme

NgPathway

NgPathway is a file-based router utilities library for Angular applications. It simplifies the process of creating and managing routes in your Angular app by allowing you to organize your routes in a directory structure that mirrors your application's UI structure.

Features

  • File-based routing: NgPathway helps to use file-based routing to create clear and concise routes to your data, making it easy to navigate and manage large datasets.

Requisites

  • NgPathway requires Angular 15+. All tests were carried out using the standalone components approach.
  • You can use Nx Angular Standalone Project or Angular CLI with @angular-builders/custom-webpack.

Installation

To get started with NgPathway, simply install the library using NPM:

npm install ngpathway --save

After the installation, a new folder called .ngpathway is created in the project's root directory. This folder initially contains two files: routes.ts and types.d.ts. Later, it will generate Angular routes inside a folder called router.

Next, you need to register the types.d.ts and router folder in your tsconfig.app.json. For example:

"include": [
  ".ngpathway/types.d.ts",
  ".ngpathway/router/**/*.ts"
]

After this, you need to add the webpack configuration to your angular.json or project.json by replacing the executor in the build and serve sections. For example, in an Nx workspace, the configuration should be adapted as shown in the following code snippet:

"build": {
    "executor": "@nrwl/angular:webpack-browser",
    "options": {
        ... other options
        "customWebpackConfig": {
            "path": "node_modules/ngpathway/lib/config/webpack.config.js"
        }
},

"serve": {
    "executor": "@nrwl/angular:webpack-dev-server",
}

To avoid conflicting with different webpack versions is recommended you run: npm dedupe. For more information the explanation here

Usage

To use NgPathway, create a directory called pages inside your application sources (e.g., src directory). Include the content of this file in your tsconfig.app.json. For example:

"include": [
  "src/pages/**/*.ts"
]

NgPathway maps the pages folder hierarchy to Angular routes. For example:

NgPathway will map the pages folders hierarchy to angular routes. For example:

  • pages/ -> /
  • pages/teams -> /teams
  • pages/teams/[id] -> /teams/:id

Inside each folder, you can create a Angular Component, the route providers, and matchers. NgPathway automatically generates the route structure for you in a file routes.ts inside the .ngpathway folder. Then, you can import this file in your main.ts. For example:

import { routes } from '../.ngpathway/routes';

bootstrapApplication(AppComponent, {
  providers: [provideRouter(routes, withEnabledBlockingInitialNavigation())]
}).catch((err) => console.error(err));

Then you are ready to continue creating new routes in the pages folder, and NgPathway will automatically generate the corresponding files.

Contributing

If you're interested in contributing to NgPathway, please feel free to submit a pull request or open an issue on GitHub. We welcome all contributions and feedback!

License

NgPathway is licensed under the MIT license. See the LICENSE file for more information.