1.0.7 • Published 4 years ago

@oauthanon/serve v1.0.7

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
4 years ago

OAuthAnon: Serve

Collection of utilities for serving HTTP(S) content.

Function: sigintServer

Add a SIGINT handler which gracefully closes a server.

import { sigintServer } from '@oauthanon/utils';

const app = express();
const server = app.listen();

sigintServer(server);

Function: spa

Simple SPA server based on Express.

  • Prints out server static directory and port.
  • Prints out morgan combined logging.
  • Serves index.html in instead of returning 404s.
  • Uses PORT environment variable if no port is given.
  • Gracefully shutdown on SIGINT.
import { spa } from '@oauthanon/utils';

spa(
  // Optional root directory - Defaults to process.cwd()
  `${__dirname}/static`,
  // Optional port - Defaults to process.env.PORT or 8080
  8080,
  // Optional hostname - Defaults to "0.0.0.0"
  '0.0.0.0',
);

CLI: spa [root]

Simple CLI wrapper for the spa function. Accepts one optional argument for the content root path.

yarn run spa ./build
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago