@tim-code/server
v1.0.3
Published
``` npm install @tim-code/server ```
Readme
server
npm install @tim-code/serverA wrapper around Express that exposes commonly used functionality to a CLI
CLI
The CLI of server is a wrapper around Nodemon
Options
const args = commandLineArgs([
{ name: "headers", alias: "h", type: JSON.parse },
{ name: "headersPath", type: resolve },
{ name: "port", alias: "p", type: Number },
{ name: "forbid", type: String },
{ name: "log", type: Boolean },
{ name: "frontend", type: resolve },
{ name: "routes", type: resolve, defaultOption: true },
{ name: "postSize", type: String },
{ name: "host", type: String },
{ name: "expressRoute", type: Boolean },
{ name: "spa", type: String },
])Command line arguments for nodemon can also be used such as --env-file=.env.
Typical Usage
server --log --routes backend --watch package-lock.jsonNote that --routes folder is automatically watched if specified.
If no --port is specified, then Node will randomly assign one. If --log is specified, a message including the port will be printed to the console in addition to the normal output logged.
By default, routes cannot contain two "/" so subdirectories with the routes folder cannot be accessed. This can changed by specifying a different "forbid" regex string.
Serve Folder
server --frontend dist --port 4000Environment Variables
server does not make use of environment variables directly but code executed via the routes folder can make use of them.
