All Projects → bertolo1988 → saco

bertolo1988 / saco

Licence: MIT license
A pre customized, express server for single page web apps that aims to be production ready.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to saco

Libz.jl
Fast, flexible zlib bindings.
Stars: ✭ 26 (+18.18%)
Mutual labels:  gzip
blog
Ideas Technical-points 2017-2-22 blog
Stars: ✭ 13 (-40.91%)
Mutual labels:  front-end
Bulletproof-Front-End-Resource-List
All the resources you will need to learn and become a professional Front-End Developer!
Stars: ✭ 108 (+390.91%)
Mutual labels:  front-end
gzipped
Replacement for golang http.FileServer which supports precompressed static assets.
Stars: ✭ 86 (+290.91%)
Mutual labels:  gzip
loco-rails
Rails is awesome, but modern web needs Loco-motive.
Stars: ✭ 53 (+140.91%)
Mutual labels:  front-end
laravel-docker-template
A production-ready docker template for Laravel applications.
Stars: ✭ 30 (+36.36%)
Mutual labels:  production-ready
jekyll-favicon
Favicon generator and tag for Jekyll.
Stars: ✭ 17 (-22.73%)
Mutual labels:  favicon
framework
Data handling framework complementary to backend active record systems.
Stars: ✭ 30 (+36.36%)
Mutual labels:  front-end
koochak
A minimal & lightweight CSS framework
Stars: ✭ 15 (-31.82%)
Mutual labels:  front-end
clappr-plugins
Main plugins for the Clappr project
Stars: ✭ 22 (+0%)
Mutual labels:  favicon
webApi-angularjs
⚓ Definitely simplifies your work with server side & organizes webApi layout to further managing.
Stars: ✭ 15 (-31.82%)
Mutual labels:  front-end
vagas
🤝 Venha fazer parte do nosso time
Stars: ✭ 15 (-31.82%)
Mutual labels:  front-end
x
Commerce Search & Discovery frontend web components
Stars: ✭ 54 (+145.45%)
Mutual labels:  front-end
web-curriculum
Breakdown of classes for curriculum topics
Stars: ✭ 117 (+431.82%)
Mutual labels:  front-end
cocktails
UI for browsing IBA cocktails
Stars: ✭ 106 (+381.82%)
Mutual labels:  front-end
desafios-bootcamps-dio
Desafios em C#, Java, JavaScript, Kotlin, Python e Ruby dos Bootcamps da Digital Innovation One
Stars: ✭ 442 (+1909.09%)
Mutual labels:  front-end
zzlib
zlib-compressed file depacking library in Lua
Stars: ✭ 44 (+100%)
Mutual labels:  gzip
AmpShell
A WinForms-based, lean and fast DOSBox frontend, for Windows (Linux and Mac coming soon !)
Stars: ✭ 29 (+31.82%)
Mutual labels:  front-end
react-native-animated-radio-button
Fully customizable animated radio button for React Native
Stars: ✭ 25 (+13.64%)
Mutual labels:  front-end
front-end-world
前端入门知识框架
Stars: ✭ 47 (+113.64%)
Mutual labels:  front-end

Saco

A pre customized, express server for single page web apps that aims to be production ready. Saco promotes separation of concerns, quality, best practices and testability when deploying front end single page web apps.

dependencies Status devDependencies Status npm version Build Status Maintainability

By using Saco

...you avoid the following common mistakes:

  • using development servers in production
  • poluting your front end project with extra dependencies
  • having your front end app on the same server of your back end server
  • using non nodejs solutions
  • incomplete production configuration

and benefit from having:

Demo

npm run http-demo, npm run https-demo or npm run cluster-https-demo

How to use

  1. Create a folder mkdir my-saco-launcher and cd into it.

  2. Start new npm project with npm init -y and drag your single page web app files inside.

  3. npm i --save saco

  4. Create a script such as:

const path = require("path");
const Saco = require("saco");
new Saco.Server({ rootPath: path.join(__dirname, "/dist") }).start();
  1. Run it as: cross-env NODE_ENV=production DEBUG=saco:* node my-script.js.

Notice that we used cross-env to set the environment variables. You may use another method.

How does it work exactly?

Well... Take a look at the code, its not much.

Behind a proxy

If your saco instance is behind proxy such as nginx, in order to have the request ip properly shown in the console do not forget to set the option behindProxy to true.

This will configure our server to trust a proxy and behave as explained here.

If your reverse proxy is Nginx you can add this proxy_set_header X-Forwarded-For $remote_addr; in your .conf file.

This will allow redefining or appending fields to the request header passed to the proxied server.

Inside Docker

Inside docker you need to define ip as '0.0.0.0'.

Server API

constructor(options: ServerOptions)
// returnes a promise that resolves only after all workers
// have sent ClusterMessage.WORKER_LISTENING to the master
start(): Promise<number>
// returnes a promise that resolves only after all
// workers have send 'exit' event to the master
stop(): Promise<any>

Options

Saco server supports the following options:

Link to ServerOptions.ts.

Remember values with ? are optional.

In order to have an https server key and cert paths must be defined.

Workers has a default and maximum value equal to the number of cores of your processor.

option What it does
name Just a string to easily identify the server in the log.
port Where the server is going to listen.
ip The address where the server will be. For most cases this should be either 'localhost or '0.0.0.0'.
cors Set to true if you want to allow cross origin requests.
dateformat String describing logs dateformat. Must be supported by dateformat npm package.
verbose Set to true if you want to have logs in the console.
key HTTPS key.
cert HTTPS certificate.
workers Number of forks. Default value depends on number of processor cores.
maxAge Specifies, in milliseconds, for how long should resources stay in client cache.
behindProxy Enables trust proxy header.
rootPath Specify the path where the resources will be in the server local hard drive.
index Expects an object with url and path. Path is the relative path from rootPath until the file and url is the default url used by the server.
assets Same as index but for the assets used by the page.
favicon Same as index but for favicon file.

Linting

npm run lint

Testing

npm run test

Logging

Use DEBUG=saco:* npm run your-launcher.js to have the logs printed on your console.

Contributing

Contributions will be highly appreciated.

Feel free to open any issues on any related matter.

Recommended versions

  • node : v8.11.2

  • npm: 5.6.0

  • typescript: 2.8.3

LICENSE

Code released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].