Giter Site home page Giter Site logo

serverhub-mvc's Introduction

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 [email protected] 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

Support

Thanks JetBrains, ServerHub Open Source Projects benifits from their kindness!

JetBrains

serverhub-mvc's People

Contributors

fossabot avatar zhongdongy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

serverhub-mvc's Issues

Document site migration

Thinking

I think the document sites are important part of open source project.I spent a few hours to read serverhub's doc. I think it will be better if you make a little change.

Example

Here is a live-demo for this issue.This static site based on VuePress that is a static html generator.It has the following advantages:

  • The sidebar has a clear index of the article section
  • Greater syntax hignlight
  • Good support for pictures and other elements
  • Better management of the draft document
    ·······

Usage

yarn global add vuepress # 或者:npm install -g vuepress
# create md
echo "# Hello VuePress!" > README.md
# write
vuepress dev .
# build
vuepress build .

For more information about this tool, view on this

Final

So, I'm glad to migrate this doc and maintain it if needed. lol...

PLEASE point it if it have any mistakes in this paragraph

TLS cert cannot be imported if a passphrase needed.

Describe the bug
When trying to load a self-signed certificate (signed with a passphrase secured private key), ServerHub may fail to start.

To Reproduce
Steps to reproduce the behavior:

  1. Generate a self-signed cert with passphrase secured private key.
  2. Load with ServerHub Run() method.
  3. Run instance.

Expected behavior
A way to provide passphrase.

Error message

>> 0 plugins loaded with no errors
!! Server cannot start and listen to 9997, 9996
   There might be another instance process of ServerHub. Please check and attempt to start later.
   Detailed error information:
Error: error:0907B068:PEM routines:PEM_read_bio_PrivateKey:bad password read
    at Object.createSecureContext (_tls_common.js:145:17)
    at Server (_tls_wrap.js:878:25)
    at new Server (https.js:62:14)
    at Object.createServer (https.js:83:10)
    at ports.forEach.p (/home/davidy/Documents/Personal/repositories/serverhub-mvc/index.js:256:36)
    at Array.forEach (<anonymous>)
    at Object.exports.Run (/home/davidy/Documents/Personal/repositories/serverhub-mvc/index.js:254:15)
    at Object.<anonymous> (/home/davidy/Documents/Personal/repositories/serverhub-mvc/playground/app.js:17:11)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)

Additional context

Info Detail
OS Ubuntu
Node version v10.0.0
ServerHub version v1.6.0

About the usage of serverhub-cli

I think the usage of serverhub-cli is not very convenient

the usage in README.md

npm i -g serverhub-cli
cd path/to/you/workspace/
npm init #ignore if you already done this
npm i --save serverhub-mvc
mkdir server && serverhub-cli init server -d #be sure to keep your files before add -h option to init command.

It's a little bit complicated , it could be modified like this

npm i -g serverhub-cli
cd path/to/you/workspace/
serverhub-cli init [projectName]

we should split the template into a new project rather than make some directory or files in index.js . In this way, we just need to download the template and replace the name . it can be decoupled .

Can I do this job ? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.