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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sprucejs/core

v0.0.5

Published

## Getting started

Downloads

11

Readme

SpruceJS

Getting started

The easiest way to start a SpruceJS project is by installing the CLI globally on your machine. You can do that with:

npm i -g @sprucejs/cli

Once this has installed, you'll find its behaviour very similar to the Angular and Nest CLI. Start a new project using:

spr new my-project-name

This will create a folder, place all of the starter files inside it and install the necessary dependencies.

Adding some features.

To add some routes to your app, try running:

spr generate routes user

or

spr g r user

By using the CLI, it will automatically add them to the nearest module. Spruce tries its best to guess what route path you want, but you can go ahead and change it if it didn't get it spot on. Lets take a look at what it's done.

export const appModule: IModule = {
  imports: [],
  providers: [UserController],
  routes: [{ url: '/user', router: UserRouter }]
};

Now, let's also make a controller.

spr g c user

As you may notice, Spruce will group your routes and controller in to a folder, to keep your code nice and modular. If you want to customise where these go, you can just use the direct URL instead of just the name of the file that you want to create. For example:

spr g c not-user-folder/user

In our controller, we can make methods available for our router to use. Any method in a controller must be asynchronous, in order to utilise the asynchronous behaviour of NodeJS. Don't worry, TypeScript will scream at you if you forget. This function also needs to adhere to the express middleware function prototype, which takes the req, res, and next arguments.

export class UserController {
  public async getAll(req: IReq, res: IRes, next: INext): Promise<string> {
    return 'allUsers';
  }
}

In our routes file, we can now hook this up by using the Spruce router service. That file should look something like this:

@injectable()
export class UserRouter extends CoreRouter {
  constructor(
    routerService: RouterService,
    private readonly _userController: UserController
  ) {
    super(routerService);
  }

  protected _generateRoutes(): void {
    this.routerService.get('/hello', this._userController.getAll.bind(this));
  }
}

Commands

You can take a look at the package.json file that gets generated to view the npm commands. To start the server, type npm run dev in to the command line and watch as Spruce sets up the application for you.

Advanced Routing

The place that Spruce really shines is routing. Spruce was built to be able to modularise routing within express and allow easy handling of child routes. Lets take a look at what we can do:

export const appModule: IModule = {
  imports: [],
  providers: [UserController, TodoController, SubtaskController],
  routes: [
    {
      url: '/users',
      router: UserRouter,
      children: [
        {
          url: '/:userId/todos',
          router: TodoRouter,
          children: [{ url: '/:todoId/subtasks', router: SubtaskRouter }]
        }
      ]
    }
  ]
};

What we've done here is allowed the user and todo routes to not only be accessible on their own, but also used as part of the URL for another resource.

The subtask resource will be accessible via /users/{userId}/todos/{todoId}/subtasks, and the values for each id will be stored in the req.params object for easy access.