Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

@4lch4/backpack

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@4lch4/backpack - npm Package Compare versions

Comparing version 0.0.8 to 0.1.0

@@ -1,69 +0,63 @@

import { InternalRoute, Elysia as PrimeElysia } from 'elysia';
/**
* A class containing various utility functions for use in APIs developed with [Elysia][0].
*
* [0]: https://elysiajs.com
*/
export declare class Elysia {
static printElysiaRoutes<T extends PrimeElysia>(app: T): void;
/**
* Prints the given array of Elysia routes to the console as a table.
*
* @param routes An array of routes from an Elysia instance to print to console.
*
* @example
* ```ts
* import { ElysAid } from '@4lch4/backpack'
* import { Elysia } from 'elysia'
*
* const api = new Elysia().get('/test', ctx => 'OK').post('/test', ctx => 'OK')
*
* ElysAid.printRoutes(api.routes)
*
* api.listen(4242)
*
* Output:
*
* ┌──────────────────────┬────────┐
* │ Path │ Method │
* ├──────────────────────┼────────┤
* │ /test │ GET │
* ├──────────────────────┼────────┤
* │ /test │ POST │
* └──────────────────────┴────────┘
*
* ```
*/
static printRoutes(routes: InternalRoute[]): void;
static healthCheckRoutes(prefix?: string): PrimeElysia<string, {
request: {};
store: {};
}, {
type: {};
error: {};
}, {}, {
[x: `${string}/health`]: {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
import { Elysia, InternalRoute } from 'elysia';
export declare function printRoutes(routes: InternalRoute[]): void;
export declare const healthCheckRoutes: Elysia<"", {
request: {};
store: {};
}, {
type: {};
error: {};
}, {}, {
"/health": {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
};
[x: `${string}/readiness`]: {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
};
"/readiness": {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
};
}, false>;
}
};
}, false>;
export declare function prefixedHealthCheckRoutes(prefix?: string): Elysia<string, {
request: {};
store: {};
}, {
type: {};
error: {};
}, {}, {
[x: `${string}/health`]: {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
};
};
[x: `${string}/readiness`]: {
get: {
body: unknown;
params: unknown;
query: unknown;
headers: unknown;
response: {
200: string;
};
};
};
}, false>;
//# sourceMappingURL=Elysia.d.ts.map
import Table from 'cli-table';
import { Elysia as PrimeElysia } from 'elysia';
/**
* A class containing various utility functions for use in APIs developed with [Elysia][0].
*
* [0]: https://elysiajs.com
*/
export class Elysia {
static printElysiaRoutes(app) {
const table = new Table({
head: ['Path', 'Method'],
colAligns: ['left', 'middle'],
style: {
head: ['cyan'],
},
});
for (const route of app.routes) {
table.push([route.path, route.method.toUpperCase()]);
}
console.log(`\n${table.toString()}\n`);
import { Elysia } from 'elysia';
export function printRoutes(routes) {
const table = new Table({
head: ['Path', 'Method'],
colAligns: ['left', 'middle'],
style: {
head: ['cyan'],
},
});
for (const route of routes) {
table.push([route.path, route.method.toUpperCase()]);
}
/**
* Prints the given array of Elysia routes to the console as a table.
*
* @param routes An array of routes from an Elysia instance to print to console.
*
* @example
* ```ts
* import { ElysAid } from '@4lch4/backpack'
* import { Elysia } from 'elysia'
*
* const api = new Elysia().get('/test', ctx => 'OK').post('/test', ctx => 'OK')
*
* ElysAid.printRoutes(api.routes)
*
* api.listen(4242)
*
* Output:
*
* ┌──────────────────────┬────────┐
* │ Path │ Method │
* ├──────────────────────┼────────┤
* │ /test │ GET │
* ├──────────────────────┼────────┤
* │ /test │ POST │
* └──────────────────────┴────────┘
*
* ```
*/
static printRoutes(routes) {
const table = new Table({
head: ['Path', 'Method'],
colAligns: ['left', 'middle'],
style: {
head: ['cyan'],
},
});
for (const route of routes) {
table.push([route.path, route.method.toUpperCase()]);
}
console.log(`\n${table.toString()}\n`);
}
static healthCheckRoutes(prefix) {
return new PrimeElysia({ prefix }).get('/health', () => 'OK').get('/readiness', () => 'OK');
}
console.log(`\n${table.toString()}\n`);
}
export const healthCheckRoutes = new Elysia()
.get('/health', () => 'OK')
.get('/readiness', () => 'OK');
export function prefixedHealthCheckRoutes(prefix) {
return new Elysia({ prefix }).get('/health', () => 'OK').get('/readiness', () => 'OK');
}
//# sourceMappingURL=Elysia.js.map

@@ -0,4 +1,4 @@

export * as ElysAid from './apis/Elysia.js';
export * as constants from './constants/index.js';
export * from './lib/index.js';
export * from './apis/Elysia.js';
//# sourceMappingURL=index.d.ts.map

@@ -0,4 +1,4 @@

export * as ElysAid from './apis/Elysia.js';
export * as constants from './constants/index.js';
export * from './lib/index.js';
export * from './apis/Elysia.js';
//# sourceMappingURL=index.js.map
{
"name": "@4lch4/backpack",
"displayName": "4lch4's Backpack",
"version": "0.0.8",
"version": "0.1.0",
"description": "A collection of useful functions, constants, and more, for use in a variety of NodeJS packages/projects.",

@@ -25,2 +25,7 @@ "keywords": [

"type": "module",
"exports": {
".": "./dist/index.js",
"./elysia": "./dist/apis/Elysia.js",
"./constants": "./dist/constants/index.js"
},
"main": "./dist/index.js",

@@ -53,5 +58,12 @@ "types": "./dist/index.d.ts",

},
"peerDependencies": {
"bun": "^1.0.7",
"bun-types": "^1.0.6",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-packagejson": "^2.4.6"
},
"engines": {
"node": ">=16.0.0",
"bun": ">=1.0.0"
"bun": ">=1.0.0",
"node": ">=16.0.0"
},

@@ -58,0 +70,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet