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

backend-smith

v1.0.5

Published

A CLI tool for automating backend component generation in Express.js, including modules, schemas, routes, services, and more.

Downloads

20

Readme

Backend Smith (CLI Tool)

Backend Smith is a custom CLI tool, invoked using the command bs, designed to help automate the creation of various components such as modules, schemas, routes, services, controllers, validations, and DTOs for an Express.js backend. It simplifies backend structure generation.

What's new

Bug fixes, enum support and auto-formatting for generated files

Table of Contents

Installation

To use Backend Smith, install it globally or locally.

Global Installation

npm install -g backend-smith

Local Installation

To use it locally in your project:

npm install backend-smith --save-dev

Then, you can run it with npx:

npx bs <operation> <name> [fields...]

Usage

Run the CLI using the following syntax:

bs <operation> <name> [fields...]

Available Commands

Backend Smith supports the following operations:

| Operation | Description | |-----------------------|---------------------------------------------| | create | Creates a base structure for the given name | | create:module | Creates a module with the specified fields | | create:schema | Creates a schema with the specified fields | | create:route | Creates a route | | create:service | Creates a service | | create:controller | Creates a controller | | create:validation | Creates validation logic for the fields | | create:dto | Creates a Data Transfer Object (DTO) |

Command Options

  • <operation>: Specifies the type of component to create (e.g., create:module, create:route, etc.).
  • <name>: The name of the component to be created.
  • [fields...]: An optional list of fields to be used in schemas, DTOs, or validations. Fields should be provided in the format fieldName:fieldType (e.g., username:String, age:Number).

You can also pass fields as an array or object:

  • Array: Pass multiple fields as separate arguments (e.g., username:String age:Number email:String).
  • Object: Pass fields in the format { fieldName: fieldType } (e.g., { username:String, age:Number, email:String }).
  • enum: Pass fields in the format fieldName:fieldTypes (e.g., role:USER|ADMIN).

To mark a field as required, prepend the field name with an asterisk (e.g., *username:String).

Examples

  1. Create a base structure:

    bs create app-name

  2. Create a module with fields:

    bs create:module user *username:String age:Number *email:String *role:USER|ADMIN

  3. Create a schema:

    bs create:schema user *username:String age:Number *email:String *role:USER|ADMIN

  4. Create a route:

    bs create:route user

  5. Create a service:

    bs create:service user

  6. Create a controller:

    bs create:controller user

  7. Create validation for fields:

    bs create:validation user *username:String age:Number *email:String *role:USER|ADMIN

  8. Create a Data Transfer Object (DTO):

    bs create:dto user *username:String age:Number *email:String *role:USER|ADMIN

Error Handling

  • If no operation is provided, the CLI will log:

    Operation is required!

  • If no name is provided for the component, the CLI will log:

    Name is required!

  • If an invalid operation is provided, the CLI will log:

    Invalid <operation> operation

Contributing

Contributions are welcome! To contribute to Backend Smith, feel free to fork the repository and submit a pull request.

Repository: Backend Smith GitHub