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

@backan/builder

v0.0.19

Published

<!-- PIGEONPOSSE START HEADER -->

Downloads

833

Readme

Backan - Builder

HEADER

Web About Us Donate Github Twitter Instagram Medium

License Version

BACKAN Create endpoints with type validations and OpenApi documentation, safely and quickly.

This package contains BACKAN Builder library

The backan builder library allows you to build multiple things. Among others:

🔑 Installation

npm install @backan/builder 
pnpm i @backan/builder
yarn add @backan/builder 

NPM Version

Build binaries

Package your Node.js project into an executable that can be run even on devices without Node.js installed.

The construction of the binary allows compilation on arm and x64 architecture.

If you compile on an x64 system it will not create the binaries for arm, but if you compile on arm it will create the binaries for both architectures.

This library works thanks to ncc, pkg and esbuild, which facilitate this process.

Using Backan Builder is simple and will work in most cases, but that may not be the case. If so, we recommend using other alternatives such as ncc or pkg.

📈 usage

import {build} from '@backan/builder'

await build( {
 input  : 'src/server.js', // JS or TS file
 name   : 'app-name', // default is input filename
} )
backan-builder --input=src/server.js --name=app-name

⚙️ Configuration

All of these options are available with the backan-builder command by adding the suffix -- and followed by an = and its value.

type BuilderParams = {
 /**
  * The app server input file.
  *
  * The input can be provided without an extension. 
  * If the extension is omitted, the system will automatically look for the following extensions: `.ts`, `.js`, `.mjs`, `.mts`.
  */
 input: string, 
 /**
  * Binary name.
  */
 name?: string,
 /**
  * Directory for the output build.
  *
  * @default './build'
  */
 outDir?: string, 
 /**
  * Build only binary for your current OS.
  *
  * @default false
  */
 onlyOs?: boolean
 /**
  * The build type Result [all|cjs|bin].
  *
  * @default 'all'
  */
 type?: 'all'|'cjs'|'bin'
 
}

Build JSON | Types schema

import {buildSchema} from '@backan/builder'
import {app} from './your-backan-app.js' 

buildSchema( {
 app    : app,
 output : 'openapi-schema.json',
} )

Parameters

export type BuilderSchemaParams = {
	/**
	 * The instance of the Backan application used to generate the OpenAPI schema.
	 */
	app: App<Env>,
	/**
	 * The path where the resulting `json` file will be saved.
	 */
	output: string 
	/**
	 * Generate dts file.
	 *
	 * @default true
	 */
	dts?: boolean
}

Build Markdown documentation

import {buildMD} from '@backan/builder'
import {app} from './your-backan-app.js' 

buildMD( {
 app    : app,
 output : 'api-documentation.md',
} )

Parameters

type BuilderMDParams = {
	/**
	 * The instance of the Backan application used to generate the OpenAPI schema.
	 */
	app: App<Env>,
	/**
	 * The path where the resulting `Markdown` file will be saved.
	 */
	output: string 
}

Create client

Create a client for your backan API and make your frontend app able to access your API easily and with type. To achieve this, backan makes use of the openapi-featch library.

import { createClient } from '@backan/builder'
import type { paths }   from './openapi.d.ts' // Generate with buildSchema

const client = createClient<paths>( {
	baseUrl : 'http://localhost:1312/',
} )

export {client}

Example of call

import {client} from './client'
const response = await client.GET( '/random/child', {
	params : {
		query : {
			value : 'myValue', 
		}, 
	},
} )

console.log( response ) 

More from Backan

👨‍💻 Development

BACKAN is an open-source project and its development is open to anyone who wants to participate.

Issues Pull requests Read more

☕ Donate

Help us to develop more interesting things.

Donate

📜 License

This software is licensed with GPL-3.0.

Read more

🐦 About us

PigeonPosse is a ✨ code development collective ✨ focused on creating practical and interesting tools that help developers and users enjoy a more agile and comfortable experience. Our projects cover various programming sectors and we do not have a thematic limitation in terms of projects.

More

Collaborators

| | Name | Role | GitHub | | ---------------------------------------------------------------------------------- | ----------- | ------------ | ---------------------------------------------- | | | Angelo | Author & Development | @Angelo | | | PigeonPosse | Collective | @PigeonPosse |

Web About Us Donate Github Twitter Instagram Medium