iijs 一个基于nodejs+koa2构建的简单轻量级MVC框架

网友投稿 883 2022-11-01

iijs 一个基于nodejs+koa2构建的简单轻量级MVC框架

iijs 一个基于nodejs+koa2构建的简单轻量级MVC框架

iijs

A simple and lightweight MVC framework built on nodejs+koa2

项目介绍

一个基于nodejs+koa2构建的简单轻量级MVC框架,最低依赖仅仅koa和koa-router。

项目地址:https://github.com/yafoo/iijs

开发手册:https://me.i-i.me/iijs/

安装

npm i iijs

基本使用

const {app, Controller, Model, Db, Pagination, View, Ctx, Context, Logger} = require('iijs');

应用结构

├── app //应用目录 (非必需,可更改)│ ├── controller //控制器目录 (非必需,可更改)│ │ └── index.js //控制器│ ├── view //模板目录 (非必需,可更改)│ │ └── index //index控制器模板目录 (非必需,可更改)│ │ └── index.htm //模板│ ├── model //模型目录 (非必需,可更改)│ ├── logic //逻辑目录 (非必需,可更改)│ ├── pagination //分页目录 (非必需,可更改)│ └── **** //其他目录 (非必需,可更改)├── app2 //应用2目录 (非必需,可更改)├── common //公共应用目录 (非必需,可更改)├── config //配置目录 (非必需,不可更改)│ ├── app.js //APP配置 (非必需,不可更改)│ ├── db.js //数据库配置 (非必需,不可更改)│ ├── routes.js //路由配置 (非必需,不可更改)│ └── **** //其他配置 (非必需,可更改)├── public //静态访问目录 (非必需,可更改)│ └── static //css image文件目录 (非必需,可更改)├── node_modules //nodejs模块目录├── server.js //应用入口文件 (必需,可更改)└── package.json //npm package.json

应用入口

// server.jsconst {app} = require('iijs');app.run(3000, '127.0.0.1', function(err){ if(!err) console.log('http server is ready on 3000');});

Hello world !

// app/controller/index.jsconst {Controller} = require('iijs');class Index extends Controller { async index() { await this.display('Hello iijs, hello world !'); }}module.exports = Index;

浏览器访问地址:http://127.0.0.1:3000,页面输出:Hello iijs, hello world !

使用手册

开发手册:https://me.i-i.me/iijs/

应用案例

melog

Nginx代理

location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}

License

MIT

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Hikyuu Quant Framework 基于C++/Python的开源量化交易研究框架
下一篇:Swift的MsgPack序列化和反序列化器
相关文章

 发表评论

暂时没有评论,来抢沙发吧~