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

sbr-generator

v1.0.5

Published

Spring Boot Rest Generator is a python Library used to generate source code modules starting from config files . The Generated source code is a CRUD Rest Spring Boot Server.

Downloads

16

Readme

SBR-Generator

Build Status npm version

SBR generator is a Spring Boot Rest Generator npm binary cli used to generate source code modules starting from config file.

The Generated source code is a CRUD Rest Spring Boot Server, ready to build and run .

How to install

It's a node package with CLI (command line interface) binary , can be installed by

npm install -g sbr-generator

Prerequisites

To work correctly SBR needs python to be installed . All needed python mudules with be installed automatically when installing SBR.

How To use

To Generate a ready to use Spring boot Rest Server , SBR need a configuration file You can start by using the example one

~$ sbrgen  -h
usage: SBR Generator [-h] [-v] [-t] [-s] -c CONFIGFILE [-o OUTPUTDIR]

SBR generator: Generate Spring Boot Rest source code.

optional arguments:
  -h, --help            show this help message and exit
  -v, --mode-verbose    Enable verbose traces
  -t, --enable-tests    Enable tests
  -s, --disable-security
                        Disable security
  -c CONFIGFILE, --config-file CONFIGFILE
                        The Yaml config file
  -o OUTPUTDIR, --outputDir OUTPUTDIR
                        The Output folder where to store generated source code

Additionally , SBR support :

  • Verobse mode using -v
  • Disabling Security based on spring role and JWT token mode using -s
  • Enabling generating tests using -t

Like Below, to generate project with security enabled and tests using example config file :

~$ sbrgen  -v -t -c  examples/config.yaml

This will generate the next folder strcutue :

$  tree serverTest-0.0.1-SNAP/
serverTest-0.0.1-SNAP/
├── pom.xml
├── README.md
└── src
    ├── main
    │   ├── java
    │   │   └── com
    │   │       └── easin
    │   │           └── serverTest
    │   │               ├── Application.java
    │   │               ├── conf
    │   │               │   └── ....java
    │   │               ├── controllers    
    │   │               │   └── ....java
    │   │               ├── entities    
    │   │               │   └── ...java
    │   │               ├── exceptions    
    │   │               │   └── ...java
    │   │               ├── repositories    
    │   │               │   └── ....java
    │   │               ├── security
    │   │               │   ├── api
    │   │               │   │   └── ...java
    │   │               │   └── ...java
    │   │               └── services
    │   │                   └── ...java
    │   └── resources
    │       ├── application.yaml
    │       ├── data.sql
    │       └── log4j2.xml
    └── test
        └── java
            └── com
                └── easin
                    └── serverTest
                        └── ...java

How to use Generated source code

The generated source code is a spring boot rest maven project with a read me file ,a complete project ready to use :

To build and Run :

cd testServer-0.0.1/
mvn clean package -Dmaven.test.skip=true
mvn spring-boot:run -Dmaven.test.skip=true

To Run Crud unit tests ( already generated ):

cd testServer-0.0.1/
mvn test

Configuration File

The Configuration is a yaml file having 3 sections : project, logging and entities.

project section

Contains all project specific data used in the pom file and the Readme and in sourec conde generations ..

project:
    longname: Easy Soft IN Selling Server # the project long name used in the pom files and the Readme     
    description: Easin Selling Server     # a description for the project
    url: http://easysoft-in.com           # the url of the project
    name: serverTest                      # the short name
    restPath: /serverTest                 # the rest base path generated
    package: com.easin.serverTest         # the package of the project
    version: 0.0.1-SNAP                   # the version of the prpoject
    security:                             # security data if activated to generate
      extraroles:                         # security extra roles (*SBR* already manage admin and user) please do not prefix roles with ROLE_ !      
        - "PROVIDER"
        - "CONSUMER"

logging section

it will be used to generate the src/main/resources/log4j2.xml file , extra configuration need to be added manually to the file .

logging:
  RootLoggerLevel: trace
  Loggers:
    - name: com.easin
      level: trace
    - name: org.springframework.web.client.RestTemplate
      level: trace
    - name: org.apache.catalina.filters.RequestDumperFilter
      level: trace

entitiess section

This section is used to generate java package for entity's, services, controllers, and beyond : @Entity class and JpaRepository for each one .. User: be Aware that the User entity is specific as it already managed by SBR, when using it on your entity, SBR will merge your fiels and his.

entities:
  - name: User
    comment: Class representing the User parameters
    fields:
      - name: mail
        type: String
        comment: the official Mail of the User
        annotations:
          - "@Email"
      - name: phone
        type: String
        comment: the official Phone number of the User
        annotations:  []
      - name: name
        comment: name of the User
        annotations:
          - "@Column(nullable = false)"
        type: String
  - name: Company
    crudRest: true
    baseclass: BaseEntity
    comment: Class representing the company parameters
    fields:
      - name: user
        comment: User created
        annotations:
          - '@JoinColumn(name="user_id", insertable=false, updatable=false)'
          - "@ManyToOne(targetEntity = User.class, fetch = FetchType.EAGER)"
          - "@JsonIgnore"
          - "@ToString.Exclude"
        type: User

How it's Works

SBR is using python and jinja2 Template machine.. SBR will also generate Swapper html api pages on : http://localhost:8080/project.name/project.version/swagger-ui.html OR json format under http://localhost:8080/project.name/project.version/v2/api-docs