2.4.1 • Published 1 year ago
arche-core v2.4.1
arche-core
Arche-platform is a quick development platform written in node. This is the App core of it.
usage
set the app folder with base options. then the Arche object will automatically establishes the KOA applications.
app folder contents
- config- local.cjs : default if not set process.env.NODE_ENV
- {env}.cjs :choise by process.env.NODE_ENV
 
- controller- {folder}- {name}.cjs  :use /folder/nameurl to access
 
- {name}.cjs  :use 
 
- {folder}
- service- {folder}- {name}.cjs :optional
 
 
- {folder}
- static- {libs with version} :three-party libraries that do not change permanently
 
- view (页面)- {*}.html :html/js/css/img各类html静态资源
- {*}.cjs :run at server side to render dynamic page
- {*}.art :page template with art-template
 
- {*}.html :
controller usage
module.exports = class {
  // can be one async function. same to koa middleware
  async act_1(ctx) {
    // from querystring
    let { code } = ctx.query;
    // call service
    let srv_user = ctx.service('oa.user');
    let rows = await srv_user.check(code);
    ctx.body = rows;
  }
  // can be array of async function
  act_2 = [async (ctx, next) => {
    // do database query with card model
    let { rows } = await ctx.db.cardr('用户表', ['ID'], {
      filter: ['ID', '=', res.id]
    });
    ctx.something = rows;
    await next();
  }, async (ctx, next) => {
    ctx.body = ctx.something;
  }];
};service usage
module.exports = class {
  constructor(app) {
    this.app = app;
  }
  async list(id) {
    let { query } = this.app;
    return query.cardr('用户表', '*', id);
  }
};view usage
setp 1. in cjs file:
module.exports = async (ctx) => {
  ctx.render('user.home', data); // 渲染view中的./home.art模板文件
};setp 2. in user/home.art file:
<html>
<body>
<% var temp = data.sub.content; %>
</body>
</html>2.4.1
1 year ago
2.4.0
1 year ago
2.3.0
2 years ago
2.2.6
2 years ago
2.2.5
3 years ago
2.2.1
4 years ago
2.2.0
4 years ago
2.2.3
4 years ago
2.2.2
4 years ago
2.2.4
4 years ago
2.1.4
4 years ago
2.1.3
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.0
5 years ago
1.2.0
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago