Skip to content

nodeboot/nodeboot-spa-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodeboot-spa-server

http server for any spa developed with react, angular, vue, etc with some few useful features

Requirements

  • nodejs >= 10

Usage

If you have the result of your spa build, you just need install this server

npm install nodeboot-spa-server --save"

and add this script to you package.json

"start" : "nodeboot-spa-server dist"

Where dist is the folder where your build assets were created:

  • angular and vue
    • dist
  • react
    • build

If you are using another framework, just set any folder that you need. This folder should be in the default workspace

Features

/settings.json

Read this in section "The Limitations.." to understand why all the SPAs(angular, react, vue, etc) needs a build for any environment. I mean if one build was tested for Q&A team, another build is required to production.

How we solve this? Get your settings from an http endpoint which is exposed by this framework, ready to use. Values are from environment variables, exactly like create-react-app but for general purpose.

Just export some variables with prefix: SPA_VAR_

export SPA_VAR_FOO=foo_value
export SPA_VAR_BAR=bar_value

Then in your spa, at the beginning, you could consume this get endpoint with ajax in order to get your settings, instead

  • .env
  • environment.prod.ts
  • hardcoded values in constants.js, config.js

Then the result could be exposed to the entire spa with:

  • localStorage
  • some global variable like global._settings
  • some javascript module or class
  • store or another advanced approach

License

MIT

Contributors


JRichardsz

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published