2.3.0 • Published 9 months ago

arche-core v2.3.0

Weekly downloads
10
License
ISC
Repository
github
Last release
9 months ago

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/name url to access
  • service
    • {folder}
      • {name}.cjs :optional
  • 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

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>

goto https://github.com/aui/art-template

2.3.0

9 months ago

2.2.6

11 months ago

2.2.5

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.4

2 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago