New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lark-mvc

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lark-mvc

MVC for building web service

  • 3.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
3
Weekly downloads
 
Created
Source

MVC for building web server using lark.js

NPM version build status

Lark-MVC

A manager for MVC design.

How to use

First define some module, then dispatch works.

Define a controller class inherits from LarkMVC.Controller, then implements the method main.

class ShowIntroduction extends LarkMVC.Controller {
    async main(ctx, next) {
        const person = new this.model.Person('Sun Haohao');
        ctx.body = await this.view().render(person);
        return;
    }
}

Define a model Person

class Person extends LarkMVC.Model {
    constructor(name) {
        super();
        this.name = name;
    }
    async introduction() {
        return new Promise(resolve => setTimeout(() => resolve(`Hello, I am ${this.name}`), 1000));
    }
}

Define a view

class MyView extends LarkMVC.View {
    async render(person) {
        return await person.introduction();
    }
}

Register them

const app = new Koa();
const mvc = new LarkMVC();

mvc.use(ShowIntroduction).use(Person).use(MyView);
app.use(async (...args) => await mvc.dispatch('ShowIntroduction', ...args)).listen(3000);

Keywords

FAQs

Package last updated on 12 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc