lexpress
NodeJS + Express based light framework.
Last updated a year ago by ivangabriele .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install lexpress 
SYNC missed versions from official npm registry.

lexpress

Light Express framework for NodeJS.

The MIT License npm Travis David David

Description

Lexpress is a featherlight microframework based on Express providing a ready-to-use base controller inluding :

  • A JSON Schema validation for GET, POST, PUT and DELETE requests.
  • An easy-to-use cache middleware.
  • A clean JSON error response.

Typescript definitions are also included.

Getting Started

Installation

npm i lexpress

Basic Web & Api Example

index.ts

import { Lexpress } from 'lexpress'

import routes from './routes'

const lexpress = new Lexpress({
  routes,
  viewsEngine: 'pug',
  viewsPath: 'src/views'
})

lexpress.start()

src/routes.ts

import { Route } from 'lexpress'

import ApiHelloWorldController from './controllers/api/HelloYouController'
import WebHelloWorldController from './controllers/web/HelloYouController'

const routes: Route[] = [
  {
    path: '/:name',
    controller: WebHelloWorldController,
    method: 'get',
  },
  {
    path: '/api/hello',
    controller: ApiHelloWorldController,
    method: 'get',
  }
]

export default routes

src/controllers/api/HelloYouController.ts

import { BaseController } from 'lexpress'

export default class HelloYouController extends BaseController {
  public get() {
    const schema = {
      type: 'object',
      properties: {
        email: {
          type: 'string',
          minLength: 1,
        },
      },
      required: ['name'],
    }

    this.validateJsonSchema(schema, () => {
      this.res
        .status(200)
        // Let's keep this response in cache for 24h
        .cache(86400000)
        .json({
          message: `Hello ${this.req.query.name} !`,
          name: this.req.query.name,
        })
    })
  }
}

src/controllers/web/HelloYouController.ts

import { BaseController } from 'lexpress'

export default class HelloYouController extends BaseController {
  public get() {
    this.res
      // Let's keep this response in cache for 24h
      .cache(86400000)
      .render('hello-you', {
        name: this.req.params.name,
      })
  }
}

src/views/hello-you.pug

h1 Hello #{name} !

Licenses

FOSSA Status

Current Tags

  • 0.41.9                                ...           latest (a year ago)

109 Versions

  • 0.41.9                                ...           a year ago
  • 0.41.8                                ...           a year ago
  • 0.41.7                                ...           a year ago
  • 0.41.6                                ...           a year ago
  • 0.41.5                                ...           a year ago
  • 0.41.4                                ...           a year ago
  • 0.41.3                                ...           a year ago
  • 0.41.2                                ...           a year ago
  • 0.41.1                                ...           a year ago
  • 0.41.0                                ...           a year ago
  • 0.40.0                                ...           a year ago
  • 0.39.6                                ...           2 years ago
  • 0.39.5                                ...           2 years ago
  • 0.39.4                                ...           2 years ago
  • 0.39.3                                ...           2 years ago
  • 0.39.2                                ...           2 years ago
  • 0.39.1                                ...           2 years ago
  • 0.39.0                                ...           2 years ago
  • 0.38.1                                ...           2 years ago
  • 0.38.0                                ...           2 years ago
  • 0.37.0                                ...           2 years ago
  • 0.36.0                                ...           2 years ago
  • 0.35.3                                ...           2 years ago
  • 0.35.2                                ...           2 years ago
  • 0.35.1                                ...           2 years ago
  • 0.35.0                                ...           2 years ago
  • 0.34.3                                ...           2 years ago
  • 0.34.2                                ...           2 years ago
  • 0.34.1                                ...           2 years ago
  • 0.34.0                                ...           2 years ago
  • 0.33.1                                ...           2 years ago
  • 0.33.0                                ...           2 years ago
  • 0.32.0                                ...           2 years ago
  • 0.31.2                                ...           2 years ago
  • 0.31.1                                ...           2 years ago
  • 0.31.0                                ...           2 years ago
  • 0.30.2                                ...           2 years ago
  • 0.30.1                                ...           2 years ago
  • 0.30.0                                ...           2 years ago
  • 0.29.0                                ...           2 years ago
  • 0.28.1                                ...           2 years ago
  • 0.28.0                                ...           2 years ago
  • 0.27.0                                ...           2 years ago
  • 0.26.0                                ...           2 years ago
  • 0.25.0                                ...           2 years ago
  • 0.24.1                                ...           2 years ago
  • 0.24.0                                ...           2 years ago
  • 0.23.1                                ...           2 years ago
  • 0.23.0                                ...           2 years ago
  • 0.22.4                                ...           2 years ago
  • 0.22.3                                ...           2 years ago
  • 0.22.2                                ...           2 years ago
  • 0.22.1                                ...           2 years ago
  • 0.22.0                                ...           2 years ago
  • 0.21.6                                ...           2 years ago
  • 0.21.5                                ...           2 years ago
  • 0.21.4                                ...           2 years ago
  • 0.21.3                                ...           2 years ago
  • 0.21.2                                ...           2 years ago
  • 0.21.1                                ...           2 years ago
  • 0.21.0                                ...           2 years ago
  • 0.20.0                                ...           2 years ago
  • 0.19.2                                ...           2 years ago
  • 0.19.1                                ...           2 years ago
  • 0.19.0                                ...           2 years ago
  • 0.18.0                                ...           2 years ago
  • 0.17.3                                ...           2 years ago
  • 0.17.1                                ...           2 years ago
  • 0.17.0                                ...           2 years ago
  • 0.16.0                                ...           2 years ago
  • 0.15.1                                ...           2 years ago
  • 0.15.0                                ...           2 years ago
  • 0.14.0                                ...           2 years ago
  • 0.13.1                                ...           2 years ago
  • 0.13.0                                ...           2 years ago
  • 0.12.0                                ...           2 years ago
  • 0.11.4                                ...           2 years ago
  • 0.11.3                                ...           2 years ago
  • 0.11.2                                ...           2 years ago
  • 0.11.1                                ...           2 years ago
  • 0.11.0                                ...           2 years ago
  • 0.10.0                                ...           2 years ago
  • 0.9.1                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.5                                ...           2 years ago
  • 0.8.4                                ...           2 years ago
  • 0.8.3                                ...           2 years ago
  • 0.8.2                                ...           2 years ago
  • 0.8.1                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.6.5                                ...           2 years ago
  • 0.6.4                                ...           2 years ago
  • 0.6.3                                ...           2 years ago
  • 0.6.2                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.5                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 1
Dependencies (28)
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |