npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@genx/server

v2.3.0

Published

Gen-X web application framework based on koa for node.js

Downloads

2

Readme

@genx/server

A full-stack (aimed to be full-stack) web/mobile application framework based on koa2. (ES7 required) https://github.com/genx-tech/gx-server

GitHub last commit

1. Concepts

Server

A genx server is a standalone node server acting as a hosting container for web applications. It mounts applications to configured routes either under the same hostname or different hostnames. A server will dispatch a http request to hosted applications according to the server routing settings. It may have server-wide middlewares touching every requests before dispatching them to the right application.

Application

A genx web application is a web module hosted by a genx server. It mounts controllers or middlewares to configured routes. Currenlty, an application is not running in a totally separate sandbox in the hosting environment.

Controller

A genx web controller is a plain object exported by a JavaScript module containing several actions to handle web requests and response to the reqeusting client.

Action

A genx web action is a koa2-styled action which is a async function and handles one client request at a time. Besides all the koa context, the code in a genx server action can also access the appModule object which represents the instance of the application.

async (ctx, next) => {
	...
}

Feature

A feature is a configuratin-driven functional module of the server or an application. Built-in features include bootstrap, loggers, middlewares, koa, routing, i18n, and etc. Every feature is a top-level config item in the server configuraiton file or application configuration file.

Starting Phrase

The starting of a server or an application include 5 consecutive phrases:

1). Initial Phrase

2). Service Registration Phrase

3). Engine Configuration Phrase

4). Middleware Registration Phrase

5). Routing Configuration Phrase (The starting process of an application starts within the server's routing configuration phrase)

A feature mentioned above is designed to be activated in a certain phrase which is specified in the feature definition file.

Middleware

A genx web middleware actually should be called a middleware factory. It is a function creating a koa-styled middleware. The middleware factory can be configured in the section of "middlewares" feature of the configuration file or as an option in the setting of a certain router.

Router

TBD.

Oolong

Oolong is an embeded domain specific language (DSL) in genx server. The oolong dsl engine will build database scripts, database access models and data-related UI according to oolong entity definition files. It also shipped with a CLI tool to do automatic deployment of the database structure.

2. Project Structure

  • /conf - server or application configuration files
  • /client - client-side source code
  • /server - server-side source code
    • /server/bootstrap - default path of bootstrap scripts (if boot feature is enabled in server or application config)
    • /server/models - backend model files
    • /server/controllers - backend controller files
    • /server/views - backend view files
  • /app_modules - child applications
  • /server/db - database initial scripts including test data
  • /server/models - database access models (usually automatically generated by oolong DSL)
  • /oolong - oolong entity definition files
  • /public - default path of static files (if serveStatic middleware is enabled)
  • /middlewares - middlewares extension
  • /features - features extension

3. Get Started

Configurations

1) Server Configuration

  • Environment specific configuration
    • /conf/server.default.json
    • /conf/server.development.json - Development specific configuration, overrides server.default.json
    • /conf/server.production.json - Production specific configuration, overrides server.default.json

2) App Module Configuration

  • Environment specific configuration
    • /app_modules/<module name>/conf/app.default.json
    • /app_modules/<module name>/conf/app.development.json - Development specific configuration, overrides app.default.json
    • /app_modules/<module name>/conf/app.production.json - Production specific configuration, overrides app.default.json

3) Feature Configuration

  • Each top-level key-value pair in the configuration file is the config of a feature, e.g. loggers, koa, mysql
    • Key is the feature name
    • Value is the feature's own config

4. Built-in Features

Bootstrap

Specify a path containing scripts to be executed during initial phrase.

Options:

[path] - Bootstrap scripts path, default: ./server/bootstrap

5. Convention

Design by contract

Refer to: https://www.npmjs.com/package/babel-plugin-contract

Action

  • this context
    • appModule - the webModule instance
    • state - the default view state for view renderer
      • _self - Current landing url
      • __ - i18n interface
      • _makePath(relativePath, query)
      • _makeUrl(relativePath, query)
      • _csrf - if csrf middleware attached

License

MIT