1.6.3-1 • Published 5 years ago

serverhub-mvc v1.6.3-1

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

npm.io

Project introductions, documents and tutorials, see serverhub.io.

Build Status FOSSA Status Coverage Status

我们为中国大陆,中国香港、澳门和中国台湾和其他国家地区使用简体中文的开发者提供了中文说明文档

For developers using simplified Chinese in China (including Mainland China, Hongkong and Macau Special Administrative Regions, and Taiwan, Province of China) and any other countries or regions, we provide Simplified Chinese version of README as well.

ServerHub is the collection of a Node.js framework, a CLI tool and a template using the latest stable features.

ServerHub MVC (serverhub-mvc) is a fast and light MVC web server framework that runs on Nodejs.

For details of the CLI tool, checkout serverhub-cli or serverhub-cli under our orgnization repositories.

What Can ServerHub Do

ServerHub can do a lot of things now. No matter you want to start a static website or build a dynamic web service, it is super convenient. Let's see some things most people would like to do with ServerHub:

  1. Static website: Support downloading and caching. Your frequently used resources will be cached in memory. Once they are changed, ServerHub will automatically refresh the cache and make sure they are the lastest.
  2. Dynamic website: Support MVC architecture. With custom route, all requests will be send to corresponding handlers.
  3. WebAPIs: Inspired by ASP.NET, ServerHub can also be used to provide WebAPI service for your applications.
  4. WebSocket: WebSocket is now supported for both HTTP and HTTPS. You may need to make sure your TLS certificate is valid (self generated may not work).
  5. Proxy*: (To be tested).

Latest Updates

v1.6.0 adds WebSocket support. v1.5.0 adds middleware system to the master/dev branch and now ready to release, with the ability to rewrite URL of resources. v1.4.1 updated the runtime log and fix some unclear annotations. v1.3.0 updated route rules and engine. v1.2.0 supports runtime and error log service. They are available through global object. v1.1.0 supports auto-redirect HTTP traffic to HTTPS. Asynchronous plugins are supported since v1.0.8. TLS supported since v1.0.6, you can use your self-signed or verified certificate to hold an HTTPS connection for your websites. Module style of ServerHub controllers now supported (since v1.0.4). You can import your own libraries in your controllers now. Legacy ways of scripting controllers will also be supported. But a little workaround should be taken into consideration (deprecated usage).

Detailed update information could be found on CHANGELOG.md (English only).

Install

npm i --save serverhub-mvc

or install a template with serverhub-cli, run

npm i -g serverhub-cli
cd path/to/you/workspace/
serverhub-cli init [project-name] # This will generate a new directory for you project.

Usage

In your entry script:

const serverhub = require('serverhub-mvc');

serverhub.Run({
    BaseDir: __dirname // BaseDir is required.
});

Run() has 2 parameters (the 2rd one is not required since v0.0.91):

  1. config: Object

    The config file defines base directory of the server, which is current of app.js. There's a Controller property that specifies which controller to register. And then ServerHub will try to search and parse under controller file. When you are writing, you may check this document or search under node_modules/serverhub-mvc/index.d.ts file along with all your dependecies, which I've already provided the type definitions there.

  2. route?: Function (callback) (no more required since v0.0.91)

    This function will have one parameter that refers to server route object, you can register custom route rule or ignore certain matches (I've not finished developing that feature).

Notice: If you are using macOS or Linux systems like Ubuntu or Debian, then port under 1024 needs root privilege. So you may need sudo (or anything like this) to run the node app.js command.

Documents

We've provided documents/tutorials for both English and Chinese

Feel Free to Contact

Question us through serverhub.contact@gmail.com or tweet to DevChache on twitter.

Leave an issue if you find any bugs. But please notice, DO comment, send pull request or anythings like that IN ENGLISH. But I do have a Chinese version of README file under doc/, you may check it out. Thank you very much.

If you are willing to receive more information, stories, tutorials and release information, please subscribe our newsletter with your favorite mail address.

License

MIT

FOSSA Status

1.6.3-1

5 years ago

1.6.3

5 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0-beta

6 years ago

1.0.0-alpha

6 years ago

0.0.97

6 years ago

0.0.96-b

6 years ago

0.0.96

6 years ago

0.0.95

6 years ago

0.0.94

6 years ago

0.0.93

6 years ago

0.0.92-patch-1

6 years ago

0.0.92

6 years ago

0.0.91

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1-b

6 years ago

0.0.1-a

6 years ago

0.0.1

6 years ago