better-express
v1.1.8
Published
Better Express is an NPM module for creating a custom environment with extra features for Express development.
Downloads
2
Maintainers
Readme
Better Express
Better Express is an NPM module for creating a custom environment with extra features for Express Server development.
Installation
Globally install Better Express
npm install -g better-express
Create your project!
npx better-express app-name
Usage
Once you installed the template project you can start up the express server using the following command:
npm start
Requirements
Better express requires you to have the following software installed:
Adding Routes
You can create a new route by creating a new .js file inside the ./routes/
folder with a default export that equals to a new router.
This file should look something like this:
import express from 'express';
const router = express.Router();
router.get('/', (req, res) => {
res.send('Hello World!');
});
export default router;
Every file in the ./routes/
folder would automaticly be imported and used in the main express server.
If you want to change the name of the route you can also add an additional export with variable called routeName that should equal to the route name.
This should look something like this:
import express from 'express';
const router = express.Router();
router.get('/', (req, res) => {
res.send('Hello World!');
});
export default router;
export const routeName = 'routeName';
If a routeName is not defined the Better Express would use the file name as the route name.
Ex:
if the file name is hello.js
the route is going to be /hello
.
Public Folder
Every file in the public folder will be public and available through the /public
route.
Nodemon
Better Express uses an NPM module called Nodemon for restarting the server on save(Documentation).
If you have a file that you don't want nodemon to restart when it saves you can add its path to the ignore array on the nodemon.json
file.
About Props
You can customize your Better Express experience by changing the props! (the props are basically like settings)
In the main directory, you can find a props folder, if you open the file called default.json
you can see all of the properties for the application.
Props
Here is a list of all of the props and what they do. In parentheses after each prop is its type, and after that in italics you can see if it is required or not. (Required means you can't leave it blank or as an empty string because it has no default value)
Port (Int) Required - This is the port the Better Express application is going use.
logRequests (Bool) Required - This lets the application to notify you when the server gets a request.
logEvents (Bool) Required - This notfies you when events get triggered (like crash, restart, exit etc).
logRestartCause (Bool) Required - This notfies you when more information about a restart event.
openTabOnStart (Bool) Not Required - This opens a tab of the Better Express application automaticly when the application starts. Default value:
true
consoleTxtColor (String) Not Required - This is the color of normal text from Better Express in the console. Default value:
"cyan"
consoleVarColor (String) Not Required - This is the color of variables from Better Express in the console.
Default value:
"green"
consoleAlertColor (String) Not Required - This is the color of alerts from Better Express in the console.
Default value:
"white"
consoleErrorColor (String) Not Required - This is the color of error messages from Better Express in the console.
Default value:
"red"