2.1.4 • Published 5 years ago

node-rest-framework-pkg v2.1.4

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

node-rest-framework-pkg

Node Rest Framework provides some tools and helpers to enhance your experience using Node.js and Express. The project provides a way of structuring a project inspired by Django and Django Rest Framework in Python.

Install

npm install node-rest-framework-pkg --save

Use

Some explanations and examples are provided here for the main principles. Feel free to try them under the /examples folder in the sources.

Principles

The package exports the NRF class that must be instantiated and oconfigured. The, it can be used like a normal element with express using the "build" function. Example0

Basic example

While configuring the NRF object, you can use the "add" and "addRouter" functions. add registers all elements that will be used later addRouter is the router configuration In the router, you can use the elements that you declared with add or declare it directly inline.

Example1

Usable elements

The types of elements used with add are : middlewares, permissions, validators, controllers. Middlewares are run first Permissions are there to ensure the user can access a given route Validators can validate post data and return error messages Controllers are the final request manader You can declare all these elements with add or use them directly in the router

Example2

Routing

Routing works like the express router. We can create routes and sub routes.

Example3

Models

You can declare models and use them to easily generate CRUD routes.

Example41

Example42

Project structure

This framework allows you to easily organize your code in segments. See the real case example in the sources.

Code structure

2.1.4

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.5.0

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago