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

@alfercom/be-page-builder

v2.4.1

Published

Backend page builder for Alfercom

Readme

Page Builder - Backend

Description

The Page Builder is a library used to create flexible and secure views at the backend side. This approach allows to accurately implement all the views needed in the application in the backend while keeping a light and simple frontend.

Check out the Page Builder - Frontend for the frontend side of the application.

Views

Views are subdivided in different types:

  • Forms: standard forms to input data;
  • Tables (CRUD): tables to read, filter, search and modify large ammounts of data;
  • Tabsets: groups of tabs, usually containing other views;
  • Cards: simple and elegant summaries of data.
  • Simple Views: flexible and highly customizable html views;
  • Dashboards
  • Catalougues

Installation

npm i --save @alfercom/be-page-builder

Documentation

In order to properly work The Page Builder needs:

A PermissionService that implements BasePermissionsService

The getUserPermissionsInstance() function is called by getStructure() in the ViewController class to check if the user can access the view.

import { BasePermissionsService } from "@alfercom/be-page-builder";

@Injectable()
export class PermissionsService implements BasePermissionsService{
  constructor() {}

  userHasPermissions(user: any, accessPermissions: string[]){
      //TODO implement
  }
}

A CustomViewController, CustomViewService and CustomViewModel

The CustomViewController must be marked by the @UseGuards(JwtAuthGuard) decorator to implement the security layer of the Page Builder.

import { ViewController } from "@alfercom/be-page-builder";

@UseGuards(JwtAuthGuard)
export class CustomViewController extends ViewController{}
import { ViewElement, ViewManagerService } from "@alfercom/be-page-builder";
import { InjectRepository } from "@nestjs/typeorm";
import { MongoRepository } from "typeorm";

export class CustomViewService extends ViewManagerService {
    constructor(
        @InjectRepository(ViewElement) private viewElement: MongoRepository<ViewElement>
    ) { 
        super(viewElement) 
    }
}
import { ViewBuilderModule, ViewElement } from "@alfercom/be-page-builder";
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { CustomViewController } from "./view-builder.controller";
import { CustomViewService } from "./view-builder.service";

@Module(
    {
        imports: [ViewBuilderModule, TypeOrmModule.forFeature([ViewElement])],
        controllers: [CustomViewController],
        providers: [CustomViewService],
        exports: [CustomViewService]
    }
)
export class CustomViewModule { }

The viewScanner in your main.ts

The view scanner loads the views form the database.

import { viewScanner } from '@alfercom/be-page-builder';

async function bootstrap() {
    ...
    viewScanner((app as any).container)
    ...
}

The ViewElement Entity in the entity list

import { ViewElement } from '@alfercom/be-page-builder';

return TypeOrmModule.forRootAsync({
        useFactory: () => ({
            ...
            entities: [
                ...
                ViewElement,
                ...
            ],
        })
    })

View Example

Create a new TestViewModule

@Module(
    {
        imports: [CustomViewModule, PermissionModule],
        controllers: [TestSimpleViewController],
        providers: [],
        exports: []
    }
)
export class TestViewModule { }

Create the TestSimpleViewController

import { Controller } from "@nestjs/common";
import { SimpleViewV1, SimpleViewV1Structure, SIMPLE_VIEW_V1_TYPE, SIMPLE_VIEW_V1_VERSION, ViewInstance } from '@alfercom/be-page-builder';
import _ = require("lodash");
import { ViewGetStructureParams } from '@alfercom/be-page-builder';
import { ViewStructure } from '@alfercom/be-page-builder';
import { PermissionsService } from "src/permission-service/permission.service";

export const TEST_VIEW_SIMPLE = "test-view-simple"

@Controller()
@ViewInstance({
    name: TEST_VIEW_SIMPLE,
    type: SIMPLE_VIEW_V1_TYPE,
    version: SIMPLE_VIEW_V1_VERSION,
})
export class TestSimpleViewController extends SimpleViewV1 {

    constructor(
        protected permissions: PermissionsService,
    ) {
        super(permissions);
    }

    async getStructure(
        params?: ViewGetStructureParams
    ): Promise<ViewStructure<SimpleViewV1Structure>>{
        const { user, parameters } = params

        const html = "Hello World!"

        const response: ViewStructure<SimpleViewV1Structure> = {
            name: this.name,
            description: _.get(this.publicInfo, "description", null),
            icon: _.get(this.publicInfo, "icon", null),
            title: _.get(this.publicInfo, "title", null),
            type: this.type,
            version: this.version,
            viewId: this.viewId,
            structure: {
                head: {
                    breadcrumbs: [
                        {
                            historyBack: true,
                            label: 'Back',
                            icon: 'fa fa-arrow-left'
                        }
                    ],
                    title: {
                        mainTitle: null,
                        position: 'center'
                    }
                },
                body: {
                    helpers: [],
                    content: {
                        html,
                    },
                    buttons: [],
                },
                vigilantOpts: {},
            }
        };
        return response;
    }
}

Add the Document to the View collection in the Database.

{
	"_id" : ObjectId("6183b6eecd2b389caf900f79"),
	"name" : "test-view-simple",
	"description" : null,
	"viewGroup" : null,
	"type" : "SIMPLEVIEW",
	"version" : "1.0",
	"publicInfo" : null,
	"permissions" : {
		"accessPermissions" : [ ],
		"ownPermissions" : null
	},
	"structure" : null,
	"content" : null,
	"domainsAllowed" : [ ],
	"isActive" : true,
	"_compiling_params" : null
},