2.3.4 • Published 2 years ago

server-express-tool v2.3.4

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

Server Utility

server-express-tool is a simple tool that is built with express.js to simplify the process of setting up express.js and to prevent getting overwhelmed by only showing the options that are necessary.You will also get killer auto complete and documentation in your IDE because every method and option in the package is strongly typed with Typescript and JSDocs.

Installation

To install server-express-tool, run:

$ npm install server-express-tool

Usage

Import the core class

const Server = require("server-express-tool");

// OR

import Server from "server-express-tool";

Add a route to the server with Server.Route() it accepts three arguments.

  • The first one is the Type. This determines the type of route it is. For example: GET or POST.
  • Then there is the Path to the route. Like "/" for the root path or something like "/path" for a sub route.
  • The last argument is the Callback or Data that the route will send when someone visits or requests the route.
Server.Route("GET", "/", (req, res) => res.send("Hello, World!"));

Start the server with Server.Listen(). It accepts the following arguments:

  • The PORT is obviously the port number that the server will listen on. This is required.
  • Callback is an optional argument which is a function that will be called when the server successfully Starts up.
Server.Listen(3000);

Add a seperate Router to your main application with Server.Router() This works exactly the same as express.Router() It allows you to add seperate routes completly detached from your main application and allows to organize them.

Server.Router();

Example with Server.Router()

import Server from "server-express-tool";

const router = Server.Router();

router.get("/", (req, res) => res.send("Hello, World!"));

export default router;
2.3.2

2 years ago

2.3.1

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.0

2 years ago

2.2.5

2 years ago

2.2.2

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.5

2 years ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago