2.5.0 • Published 3 years ago

rewyre v2.5.0

Weekly downloads
21
License
MIT
Repository
github
Last release
3 years ago

The rewyre framework is built on top of express, and express-ws and utilises TypeScript and decorators to give you a powerful wiring tool to create API applications in a very short time with built-in support for MySQL/MongoDB for models.

Important Changes

See the docs/migrating/v1-v2.md for more information regarding the move to V2.

The framework's version 2 release is now licensed under MIT.

Installation

You can install from NPM with:

npm install --save rewyre

Bootstrap Application

As part of some new changes, I have added a simple bootstrap script, it doesn't do very much other than create a basic application with eslint, and all the required packages, you can use it like:

npx rewyre create-rewyre <foldername/appname>

Getting Started

Below is a simple example showing a database connection and a simple find, for a more in-depth example, have a look at the test folder in the source, which has a simple to-do demo.

Note: The expectation is that this framework is to be used with TypeScript specifically and that you would you use your own tooling for building and compiling it, of course, you can use JavaScript and babel instead, but it is suggested to use TypeScript, for help with setting up, look at the tsconfig.json file inside of the test folder.

// Import the parts we need.
import { Framework, Drivers, Controller, Route, IReturn, Model, AbstractModel, AbstractController } from 'rewyre';


// Define our controller.
@Controller('/', 'home')
class HomeController extends AbstractController {

	@Route('GET', '/')
	public async index(): Promise<IReturn> {
		const users = await this.users.find({});
		return { status: 200, content: users };
	}
}


// Define our model.
@Model('users', 'general', {
	username: 'string',
	password: 'string',
	blocked: 'boolean',
	block_reason: '?string',
})
class UsersModel extends AbstractModel {}


// Create an isolated async function.
(async() => {

	// Create an instance of the framework.
	const application: Framework = new Framework({
		port: 3005,
		database: true,
		databases: [
			{
				unique: 'primary',
				host: 'localhost',
				port: '27017',
				name: 'example-app',
				driver: Drivers.MONGO,
				default: true,
			},
		],
	});

	// Register classes.
	application.register([
		HomeController,
		UsersModel,
	]);

	// Start the server.
	await application.start();
})();

Available Features

The below lists the features and their stable state, this framework's API will not change for the forseable future, any changes will be fully implemented and any non-backwards compatible changes will be in the latest major version, following the semver versioning scheme.

FeatureDescriptionStatus
HTTP ServerThe HTTP server is the base for the framework and is built on top of Express.Stable
WebSocket ServerThe WebSocket server uses express-ws package to apply WebSocket support.Stable
Middleware SupportStandard Express middleware is supported using the useMiddleware method.Stable
Static AssetsStandard Express static is supported as well using the useStatic method.Stable
ControllersController classes and the @Controller decorator are both implemented.Stable
Controller RoutesController routes are and the @Route decorator are both implemented.Stable
ModelsModel classes and the @Model decorator are both implemented.Stable
DriversDatabase drivers allow you to use one of the many implemented into the framework.Stable
Custom DriversDefine your own database drivers to implement other databases into your framework.Stable
Framework HooksAllows you to hook functions into internal events.Beta
Plugin SupportSee documentation but plugins are now implemented to allow you to package code pieces into reusable and shareable components.Beta
Multiple DatabasesYour models can use any database, including multiple, have data in many databases? Write a model around a specific database instead or just fallback to the default.Beta
InjectionsInjections are done using a single @Inject decorator and you can inject one or many, you can inject models and providers to any service or controller as required.Stable
ServicesService classes and the @Service decorator are both implemented and services can run on a loop based on seconds.Stable
ProvidersProviders and the @Provide decorator are both implemented, the provider allows you to create built in helper classes that can be injected to controllers, and services.Stable

Upcoming Features

Upcoming features that are planned, some features may come out quicker due to technical requirements.

  • Plugin Support - There is a plan to add plugin support, but I am not sure what this will look like yet.
  • Multiple Databases - Support for using multiple databases using database drivers alongside your own.
  • Model Extend - Allow developers to extend models to add more fields for validation.

Future Plans

The future for this library is big, I have many plans to add lots of new features and more decorators to add additional features, and I plan to turn this (slowly) into a full out-of-the-box TypeScript based framework for building Node.JS server side applications. This framework will be able to handle any structure and can be included into other applications like Vue.JS Server-Side Rendering alongside using it render HTML based applications instead of only API based.

2.5.0

3 years ago

2.4.4

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.4.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.0.2

3 years ago

2.1.3

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago