@ubio/ac-static-server
TypeScript icon, indicating that this package has built-in type declarations

5.1.2 • Public • Published

ubio AC Static server Actions Status

Server for static websites - This library intends to serve static files and provide a retrieve of configuration functionality over a HTTP request through an endpoint.

Features

  • Run static project backed by a server (Node.js application)
  • Exposes an endpoint to filter and provide configuration based on environment variables, from a static project
  • Let static project customize server arguments: exposed port and root folder to static files

Installation

Using npm package manager

npm install --save @ubio/ac-static-server

After installing locally, you can use the command line npx serve-static --path <FOLDER_TO_STATIC_FILES_PATH>

Commands

This CLI provides a few commands to get started.

Serving static files commands

Command Description Required
port Valid TCP port to run the server No (default: 8081)
path Path to static files to be served. If static files not found, application will skip serving such files (only API). Yes

Exposed environment variables

Environment variables are exposed over a HTTP endpoint. A simple request to GET /api/StaticConfig/findConfigs and a JSON response will be given in the following format:

{
    "success": true,
    "data": {
        ...
    }
}

Although, variables must be defined for the environment where this application will be running (or simply through a .env file), they also need to be prepended with AC_PUBLIC_ENV_ to be considered as exposable by this API. For example, we could have the following variables defined for the current environment, when runnig this application:

NODE_ENV=production
PORT=8080
PATH=...
HOME=...
SHELL=...
AC_PUBLIC_ENV_API_URL=...
AC_PUBLIC_ENV_API_KEY=...
AC_PUBLIC_ENV_REPORT_API_KEY=...
AC_PUBLIC_ENV_REPORT_PROJECT_ID=...
AC_PUBLIC_ENV_VAULT_URL=...

We surely don't want to and it's meaningless for the served application (frontend project) to load such data. So, env variables will be filtered and the prefix of variables to be exposed will be removed from the their names, when formatting the response object. An example of the returned response, based on the previous variables defined, would be:

{
    "success": true,
    "data": {
        "API_URL": "...",
        "API_KEY": "...",
        "REPORT_API_KEY": "...",
        "REPORT_PROJECT_ID": "...",
        "VAULT_URL": "..."
    }
}

License

UBIO Limited © 2023

Readme

Keywords

none

Package Sidebar

Install

npm i @ubio/ac-static-server

Weekly Downloads

30

Version

5.1.2

License

private

Unpacked Size

52.5 kB

Total Files

76

Last publish

Collaborators

  • danielolaviobr
  • hyuko21
  • dleibner
  • mihon
  • khard
  • inca
  • randunel
  • alisapsee
  • nicck
  • andrew-waters
  • anatoliy
  • mgubio