Arche-platform is a quick development platform written in node. This is the App core of it.
set the app folder with base
options. then the Arche
object will automatically establishes the KOA applications.
- 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
- {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 :
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;
}];
};
module.exports = class {
constructor(app) {
this.app = app;
}
async list(id) {
let { query } = this.app;
return query.cardr('用户表', '*', id);
}
};
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>