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

apisculptify

v1.0.2

Published

Apisculptify is a powerful Node.js tool designed to automate the process of generating RESTful APIs for your TypeORM models. With Apisculptify, you can quickly create a new project, define your TypeORM models, and effortlessly generate CRUD (Create, Read,

Downloads

29

Readme

Fast, unopinionated, minimalist web back-end tool for Node.js.

Table of contents

NPM Version NPM Install Size

Apisculptify - Automated REST API Generator for TypeORM Models

Apisculptify is a powerful Node.js tool designed to automate the process of generating RESTful APIs for your TypeORM models. With Apisculptify, you can quickly create a new project, define your TypeORM models, and effortlessly generate CRUD (Create, Read, Update, Delete) APIs for them and also swagger documentation.

Installation

To use Apisculptify in your Node.js project, you can install it via npm:

npm install -g apisculptify

Quick Start

Follow the steps below to quick started with Apisculptify:

1. Create a new project using the apisculptify new command:

apisculptify new
apisculptify -n
apisculptify --new

2. Apisculptify will ask for folder path up to 'src' directory or folder. you need to choose 'src' directory of you project.

apisculptify generate:api
apisculptify -g:api
apisculptify --generate:api

Apisculptify will automatically scan the model folder, detect your TypeORM models, and generate CRUD APIs for each model. The generated APIs will be placed in the src folder of your project. after that you need import routes from controller in src/app.ts

Naming convention rules for models

Rules & Behavior
    - model names shold be in lowerCase
    - append .model.ts after your model name (e.x. [model-name].model.ts)
    - your model name may contain more then one word,To separate your word in your model name use "-"(desh) (e.x. user-address.model.ts)
    - and inside model file class name follow title case with model keyword at last(e.x. export class UserAddressModel {...})

Full model example user.address.model.ts

import { Entity, Column, ManyToOne, JoinColumn, } from "typeorm";
import { BaseEntity } from '../util/base-entity.model'
import { UserModel } from "./user.model";
import { IsInt, IsString, Max, Min } from "class-validator";

@Entity("address")
export class UserAddressModel extends BaseEntity {

    @Column({ name: "pincode", nullable: false })
    @IsInt()
    @Min(99999)
    @Max(999999)
    pincode: number;

    @Column({ name: "city" })
    @IsString()
    city: String;

    @Column({ nullable: false })
    @IsString()
    state: String;

    @IsString()
    @Column({ name: "address" })
    address: string;

    @ManyToOne(type => UserModel, { eager: true })
    @JoinColumn({ name: "user" })
    user: UserModel;
}

Using the find Function

The find function allows you to retrieve records based on specific criteria by using query parameters. You can apply various filtering and pagination options to tailor your result set. Here's an example of how to use the find function to retrieve a list of users with specific filters:

 GET /user/search?name=John&age=30&isActive=true

In this example, the API will return a list of users named "John," aged 30, and who are marked as active.

Supported Operators

Apiscuptor supports a range of operators that you can use with the find function. These operators enable you to apply specific filtering conditions to your queries. For instance:

  • name:eq=John: Retrieve records where the "name" attribute is equal to "John".
  • age:gt=25: Retrieve records where the "age" attribute is greater than 25.* isActive:eq=true: Retrieve records where the "isActive" attribute is equal to true.You can combine multiple operators to create complex queries. Additionally, you can filter by parent details by using dot notation. For example:
GET /user/search?department.name:eq=Engineering

This query retrieves users who belong to the "Engineering" department.

  • you can also pass start and limit in the query string for pagination
GET /user/search?start=0&limit=10
  • you can also pass sorting details with column name
GET user/search?sort={"firstName":1}
  • you can perform all of above operation in single request
GET /user/search?sort={"firstName":1}&start=0&limit=10&firstName:lk=venish

Supported Operators

Apiscuptor supports a wide range of operators that can be used in your query parameters to customize your API responses:

  • nt: Not
  • lt: LessThan
  • lte: LessThanOrEqual
  • mt: MoreThan
  • mte: MoreThanOrEqual
  • eq: Equal
  • lk: Like
  • ilk: ILike
  • btw: Between
  • in: In
  • any: Any
  • inl: IsNull
  • ac: ArrayContains
  • acb: ArrayContainedBy
  • aol: ArrayOverlap
  • raw: Raw

Automatic Swagger Documentation

Apiscuptor generated project also provides a convenient way to automatically generate Swagger documentation for all your generated API routes. To generate the Swagger documentation, simply run the following command:

npm run swagger

This command will automatically generate the Swagger documentation based on the routes defined in your generated APIs. You can access the Swagger documentation by navigating to the specified URL in your browser. We have used tsoa. you can use tsoa decorator for your custom api

Swagger UI Swagger UI provides an interactive and user-friendly interface for exploring and testing your API endpoints. With the automatically generated Swagger documentation, you can easily visualize your API structure, request/response formats, and even execute API calls directly from the Swagger UI interface.

Project Structure

Apisculptify follows a specific project structure to organize your code effectively. Here's how your project structure should look like:

myproject/
  ├── src/
  │   ├── controllers/
  │   ├── models/
  │   ├── services/
  │   ├── utils/
  │   ├── app.ts
  │   └── ...
  ├── node_modules/
  ├── package.json
  ├── tsconfig.json
  └── ...

The src folder will contain the generated REST API files for your models.

Contributing

We welcome contributions from the community! If you find any issues or have ideas for improvements, please open an issue or submit a pull request on the GitHub repository.

License

Apisculptify is licensed under the MIT License.

Acknowledgments

We would like to express our gratitude to the TypeORM and Node.js communities for their invaluable contributions, without which this project would not have been possible.

Thank you for using Apisculptify! If you encounter any problems or have any questions, don't hesitate to reach out.

mail: [email protected]

Happy coding!