0.4.2 • Published 7 years ago

epii-server v0.4.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

epii-server

epii-node-server

Build Status Coverage Status

A koa-based server with preset MVC model.

Please upgrade to v3+ for node 8 !!!

  • koa-router for controller
  • koa-send for static files
  • koa-body for body parse & file upload
  • epii-html5 for main document

Features

MVC pipeline

(Request)
  => Middleware => Controller => View =>
(Response)

ASP.net-liked

Different ActionResult makes different response.

// controller
module.exports = [
  {
    path: '/',
    verb: 'get',
    body: async function () {
      // response text/plain
      return this.epii.text('text output')

      // response application/json
      return this.epii.json({ state: true })

      // response text/html by ViewRender
      return this.epii.view({ name: 'Li Lei' })

      // response application/octet-stream
      return this.epii.file('dataset.csv')
    }
  }
]

support custom layout

// client/index.meta.js
module.exports = {
  base: 'simple', // inherit simple layout
  head: {
    styles: 'client/index.css'
  },
  body: {
    holder: 'client/index.html',
    scripts: 'client/index.js'
  }
}

// layout/simple.meta.js
module.exports = {
  head: {
    title: 'EPII Avatar',
    metas: [],
    styles: 'reset.css',
    icon: 'epii-icon.png'
  },
  body: {
    scripts: 'jquery-2.2.2.min.js'
  }
}

Or you maybe want to write HTML directly.

// client/index.meta.js
module.exports = {
  html: 'client/index.html'
}

See also epii-html5.

Usage

project like this

(root)
├── layout
│   └── simple.meta.js
├── client
│   ├── ViewA
│   │   └── index.meta.js
│   └── ViewB
│       └── index.meta.js
├── server
│   ├── middleware
│   │   └── $order.js
│   └── controller
│       └── index.js
└── static

install as dependency

npm install --save epii-server@latest

use api to start server

const epiiServer = require('epii-server')

epiiServer([{
  name: 'YOUR-APP-NAME',
  port: 8080,
  path: {
    root: __dirname,
    server: {
      controller: 'server/controller',
      middleware: 'server/middleware'
    },
    client: 'client',
    layout: 'layout',
    static: 'static',
    upload: 'upload'
  },
  prefix: {
    static: '__static'
  }
}])
0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

8 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago