23.47.2 • Published 5 months ago

@digital-alchemy/server v23.47.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@digital-alchemy/server

Description

This library enables webserver functionality for apps based off of @digital-alchemy, binding configuration variables to Nest and automatically setting up common middleware.

Dev note

The general goals of this library will stick around in the future, but some parts of the code are tuned to my specific uses. Since web isn't a primary focus for @digital-alchemy right now, cleaning everything up hasn't been a high priority. These elements are opt-in (like the Nest auth guards), so they should not have an effect unless explicitly used. If you have opinions on what you'd like to see from this library, open an issue

Enabling webserver functionality

1) Enable http in bootstrap

The options provided to @QuickScript(options), and Bootstrap(module,options) have http?: boolean as an option. This is set to false by default. Enabling will request the bootstrap process set up nest with an express server

2) Import module

Add ServerModule to list of imports.

What this does

After configuration, this library is intended to not have be interacted with by the developer. Everything should happen automagically, and leave the app in a good to go & open for business state.

Middleware

The following middleware is automatically set up

  • csurf
  • cors
  • compression
  • nest validation pipe
  • cookie parser
  • json body parser

Automatic request logging

Every request is assigned a unique id, and will get logged upon completion

Express configuration

Open up ports for listening after the application has confirmed initilization. Has built in support for ssl certs, just provide file path to load from.

Auth flow

The built in auth flow is mostly intended for local development and other non-public production uses. Adding @AuthStack annotation to a controller will attach the guards.

The built in AdminKeyGuard looks for the x-admin-key header, and will compare that value with the one provided in the configuration

Configuration options

The following configuration options are utilized by this library.

; default configuration
[libs.server]
  BODY_SIZE=100kb
  COMPRESSION=true
  CSURF=false
  ; 1 billion, then reset to 0
  MAX_REQUEST_ID=1000000000
  PORT=7000

ADMIN_KEY

default value: ""

Leave blank to disable. If this value is provided via x-admin-key header, the request will be authorized

BODY_SIZE

default value: "100kb"

Max json body size for incoming requests

COMPRESSION

default: true

Wire in compression middleware

CORS

default value: ""

CORS origin for the server. Set to blank to disable middleware

MAX_REQUEST_ID

default value: 1_000_000_000

Rollover point for request ids

PORT

default value: 7000

Port to attach webserver to

SSL_CERT

default value: undefined

File path, required if SSL_PORT is active

SSL_KEY

default value: undefined

File path, required if SSL_PORT is active

SSL_PORT

default value: undefined

23.34.2

8 months ago

23.40.0

7 months ago

23.40.2

7 months ago

23.40.3

7 months ago

23.40.5

7 months ago

23.40.6

7 months ago

23.27.1

10 months ago

23.27.0

10 months ago

23.39.0

7 months ago

23.39.2

7 months ago

23.39.1

7 months ago

23.47.0

5 months ago

23.47.1

5 months ago

23.47.2

5 months ago

23.28.0

10 months ago

23.28.1

10 months ago

23.17.0

1 year ago

23.16.1

1 year ago

23.16.0

1 year ago

23.19.0

12 months ago

23.17.2

1 year ago

23.16.3

1 year ago

23.18.0

12 months ago

23.17.1

1 year ago

23.16.2

1 year ago

23.17.4

1 year ago

23.19.1

12 months ago

23.17.3

1 year ago

23.16.4

1 year ago

23.17.5

1 year ago

23.19.1-dev.0

12 months ago

23.19.1-dev.1

12 months ago

23.20.0

12 months ago

23.21.0

11 months ago

23.25.0

11 months ago

23.13.1

1 year ago

23.13.2

1 year ago

23.15.0

1 year ago

23.14.1

1 year ago

23.14.0

1 year ago

23.14.3

1 year ago

23.14.2

1 year ago

23.13.3

1 year ago

23.14.4

1 year ago

23.13.4

1 year ago

23.13.0

1 year ago

23.12.4

1 year ago

23.12.3

1 year ago

23.12.2

1 year ago

23.12.1

1 year ago

23.12.0

1 year ago