1.0.1 • Published 1 year ago

express-bootup v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Express-Bootup

Express-Bootup is a simple NPM package that helps you boot up an Express server using fewer lines of code. It exports an Express app and a function named bootServer which takes a port number as an argument and starts the server on that port.

Installation

To install the package, run:

npm install express-bootup

Usage

Important Configuration

To use this package, you need to use ES6 import statements. Ensure you have "type": "module" in your package.json file:

{
  "name": "your-project-name",
  "version": "1.0.0",
  "main": "index.js",
  "type": "module",
  "dependencies": {
    "express-bootup": "^1.0.0"
  }
}

Importing the Package

First, import the package in your JavaScript file:

import { app, bootServer } from 'express-bootup';

Defining Routes

Next, define your routes using the app object:

app.get('/', (req, res) => {
  res.send('Hello World!');
});

Booting the Server

Finally, boot the server using the bootServer function and pass the port number as an argument:

bootServer(3000);

Complete Example

Here is a complete example of setting up an Express server using Express Server Booter:

import { app, bootServer } from 'express-bootup';

// Define your routes
app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.get('/api', (req, res) => {
  res.json({ message: 'Welcome to the API!' });
});

// Boot the server on port 3000
bootServer(3000);

API

app

The Express application instance. Use this to define your routes, middleware, etc.

bootServer(port: number)

A function to start the server on the specified port.

  • port: The port number on which the server should run.

License

MIT

1.0.1

1 year ago

1.0.0

1 year ago