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

jova.js

v1.5.5

Published

Jova.js - A semi-advanced Express.js framework by Bracketed Softworks!

Downloads

23

Readme

A semi-advanced Express.js framework by Bracketed Softworks! This is a package built revolving around Express.js to allow the easy usage of Express' API and adding extra things like built in middlewares, event listeners etc.

Wiki available at https://github.com/Bracketed/jova.js/wiki

- A Framework package built for Express.js that uses @bracketed/logger for logging. - It utilises a range of packages to bring you the best experience! Some of these are, ioRedis for Database-Based ratelimit buckets, Express Rate Limit for the ratelimiting middleware, CORS for CORS middleware, TCP Port Used for determining used ports and a few minor packages that can be found in the dependencies tab for small tasks in Jova.js.

Install via yarn or npm:

yarn add @bracketed/jova.js
npm install --save @bracketed/jova.js

Jova.js has a specific file structure it works by, this is shown below:

project
│   index.ts
│
└───events
│   │   Ready.ts
│   │   Error.ts
│   │   ...
│   │
│   └───more-events (subfolders are supported)
│       │   Mount.ts
│       │   Route.ts
│       │   ...
│
└───routes
│   │   Route.ts
│   │   Index.ts
│   │   ...
│
└───middlewares
    │   Middleware1.ts
    │   Middleware2.ts
    │   ...

Jova.js also has two other exports, @bracketed/jova.js/utilities and @bracketed/jova.js/types.

  • @bracketed/jova.js/utilities - Utilities for routers and middlewares currently, may contain more in future versions of Jova. Exports request and response, utilities containers. All are documented using jsDoc.
  • @bracketed/jova.js/types - Typings for Jova.js, used in routes, middlewares, events etc.

Initiating a new Jova Server.

// ESM
import { JovaServer } from '@bracketed/jova.js';

const Jova = new JovaServer();

await Jova.listen(3000);
// CJS
const { JovaServer } = require('@bracketed/jova.js');

const Jova = new JovaServer(); // All options for JovaServer are documented in the instance as jsDocs

await Jova.listen(3000);

You can find an application example in the Jova.js repository here or the direct folder here.

The default Express API can be utilised from the default Jova instance after being initiated e.g: get(), post(), etc.

However, you can set up routes, middlewares and event listeners like this:

Events:

// ESM
// ./events/Event.ts
import { ApplicationEvent, EventController, EventListenerOptions } from '@bracketed/jova.js/types';

export class Event extends EventController {
	public override setApplicationEventOptions(): EventListenerOptions {
		return {
			type: ApplicationEvent.ALL,
		};
	}

	public override async run(_e: ApplicationEvent, ..._args: any[]) {
		return;
	}
}
// CJS
// ./events/Event.ts
const { ApplicationEvent, EventController, EventListenerOptions } = require('@bracketed.jova.js/types');

export class Event extends EventController {
	public override setApplicationEventOptions(): EventListenerOptions {
		return {
			type: ApplicationEvent.ALL,
		};
	}

	public override async run(_e: ApplicationEvent, ..._args: any[]) {
		return;
	}
}

Routes:

// ESM
// ./routes/Route.ts
import {
	ApplicationRegistry,
	ApplicationRequest,
	ApplicationResponse,
	ApplicationRoute,
	Methods,
	RouteController,
} from '@bracketed/jova.js/types';

export class Route extends RouteController {
	public override registerApplicationRoutes(registry: ApplicationRegistry): ApplicationRoute {
		return registry.registerApplicationRoutes((route) =>
			route //
				.setRouteName('')
				.setMethod(Methods.GET)
		);
	}

	public override async run(
		request: ApplicationRequest,
		response: ApplicationResponse
	): Promise<ApplicationResponse | void> {
		this.logger.info('Recieved request for', request.baseUrl);
		return response.status(200).json({ message: 'Hello World!' });
	}
}
// CJS
// ./routes/Route.ts
const {
	ApplicationRegistry,
	ApplicationRequest,
	ApplicationResponse,
	ApplicationRoute,
	Methods,
	RouteController,
} = require('@bracketed/jova.js/types');

export class Route extends RouteController {
	public override registerApplicationRoutes(registry: ApplicationRegistry): ApplicationRoute {
		return registry.registerApplicationRoutes((route) =>
			route //
				.setRouteName('')
				.setMethod(Methods.GET)
		);
	}

	public override async run(
		request: ApplicationRequest,
		response: ApplicationResponse
	): Promise<ApplicationResponse | void> {
		this.logger.info('Recieved request for', request.baseUrl);
		return response.status(200).json({ message: 'Hello World!' });
	}
}

Middlewares:

// ESM
// ./middlewares/Middleware.ts
import {
	ApplicationNextFunction,
	ApplicationRequest,
	ApplicationResponse,
	MiddlewareController,
	MiddlewareOptions,
} from '@bracketed/jova.js/types';

export class Middleware extends MiddlewareController {
	public override setApplicationMiddlewareOptions(): MiddlewareOptions {
		return {
			middlewareName: 'middleware',
			runsOnAllRoutes: true,
		};
	}

	public override async run(
		_request: ApplicationRequest,
		_response: ApplicationResponse,
		next: ApplicationNextFunction
	): Promise<ApplicationResponse | void> {
		this.logger.info('Connected to middleware!');
		return next();
	}
}
// CJS
// ./middlewares/Middleware.ts
const {
	ApplicationNextFunction,
	ApplicationRequest,
	ApplicationResponse,
	MiddlewareController,
	MiddlewareOptions,
} = require('@bracketed/jova.js/types');

export class Middleware extends MiddlewareController {
	public override setApplicationMiddlewareOptions(): MiddlewareOptions {
		return {
			middlewareName: 'middleware',
			runsOnAllRoutes: true,
		};
	}

	public override async run(
		_request: ApplicationRequest,
		_response: ApplicationResponse,
		next: ApplicationNextFunction
	): Promise<ApplicationResponse | void> {
		this.logger.info('Connected to middleware!');
		return next();
	}
}

Feel free to contribute to this project, join our discord and help us with future developments of Project Bracketed & Packages by Bracketed Softworks. Please also notify us of errors within our projects as we may not be aware of them at the time.