1.4.15 • Published 5 years ago

falanteris v1.4.15

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Important Note:

This is not the finished version of the README, it only covers basic and smaller features.

Basics

Falanteris is a multi-functional framework that you can use to build a REST-api or a web development framework.

It shares design aspects from Express, a more popular REST-api framework, but it combines smaller aspects from Flask as well.

To get started, we'll need our app constructor, we can require the Falanteris function from the package. var Falanteris = require("falanteris").Falanteris let app = Falanteris("0.0.0.0",undefined,"http")

The constructor requires 4 arguments: 1. Network Interface you're going to run it in. 2. Dependency ( you can simply supply it with undefined to ignore, but we'll get to this later 3. protocol, which can be either http or https 4. https credentials, which should be supplied with an object consisting of key, and cert property.

Adding redirections

Now that we have our app ready, time to add some redirections, using the addRedir method fromt the app object.

app.addRedir(<method>,<endpoint>,<handler>,<middlewares>)

  1. The method can be either "GET", "POST", "PUT", and "DELETE" which can be supplied either by string. If you want a specific endpoint to have multiple redirections you can supply this argument with an array like ["GET","POST"].
  2. The endpoint is pretty self explanatory, but its pretty much the URL that needs to be accessed.
  3. the handler is a function that would be supplied with req, and res variables.
  4. middlewares is a list of functions that would be passed through by the request before entering the handler. The functions must consist of 3 parameters, req and res object, as well as thenext function.

Using URL as parameter

Often times, when developing a REST-api, this is a staple feature that is needed. Falanteris got that covered. In order to use the feature, we'll need to specify the exact location where the parameter is located using the [] square bracket.

Example: `/login/username/password/password

Now, the parameters should be stored in the req object, particularly in the rawParam property of it. To get the username you can call req.rawParam.username to retrieve the username specified in the URL. The same can be done with password.

Queries are also stored in a similar manner. In the rawQuery property of the req object.

Using Middlewares

Middlewares are useful when you want to run a checking pipeline towards incoming requests. Simply create a common function that takes three parameters, req, res, and next. The req and res object are similar to the ones you would use in your request handler. The next parameter contains the next middleware that needs to be run. After done performing necessary actions, you can invoke the next function to call the 'next' middleware in the pipeline.

Example: function myMware(req, res, next){ console.log("Checked by middleware"); next(); }

You can then deploy this middleware by inserting it into the last parameter of addRedir method in an array

app.addRedir(.., ..., ..., [myMware])

Final Notes

Now of course, you can export the whole app by using module.exports

Example: module.exports = app

Neat Little Features

  1. app.verbosity(); This feature would make the app verbose, displaying errors and partial information about the incoming request.

  2. app.enableMP(<number of cores>) An API to run multi-processing. You can specify how many cores you wish to use. Of course, it also considers the number of processors your machine has.

1.4.15

5 years ago

1.4.14

5 years ago

1.4.13

5 years ago

1.4.12

5 years ago

1.4.11

5 years ago

1.4.10

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.32

5 years ago

1.2.31

5 years ago

1.2.30

5 years ago

1.2.29

5 years ago

1.2.28

5 years ago

1.2.27

5 years ago

1.2.26

5 years ago

1.2.25

5 years ago

1.2.24

5 years ago

1.2.23

5 years ago

1.2.22

5 years ago

1.2.21

5 years ago

1.2.20

5 years ago

1.2.19

5 years ago

1.2.18

5 years ago

1.2.17

5 years ago

1.2.16

5 years ago

1.2.15

5 years ago

1.2.14

5 years ago

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago