aok.js
reverse the koa , ROP resource oriented program
phil(哲学)
about version
v2.0.0
- add .aokignore just like .gitignore
- 默认忽略扫描node_modules/的文件
- ext 扩展功能,详见 ext 参考下面的csv.aok
- 支持csv扩展 csv.aok
just step by step to understand aok
npm i -g aok.js mkdir tempcd temp cat << EOF > data.jsonEOF aok . # try visit by http #GET : http://localhost:11540/data?node=hello #POST : http://localhost:11540/data #PUT : http://localhost:11540/data?node= #DELETE : http://localhost:11540/data?node=
参数说明: what is aok
-
暴露出去的资源方法,同时支持同步及异步方法
{// return {}// return []return Promise}"@post" : async {// return {}// return []return Promise} -
也支持其他形式
"@delete" : 'test delete success'"@put" :hello : 'good good day' -
方法参数说明
params : get时 ctx.query 其他methods 时 取 ctx.request.body
ctx : 请求上下文
options : 程序启动的options,应用直接获取做一些特殊处理
-
文件上传支持
采用koa-body方式上传文件,ctx.request.files直接获取
use
cli
npm i -g aok.js aok -h aok [yourDir] -s [yourStaticDir] -p [yourport]
amazing using
npm i -g lisa.dl aok https://github.com/apporoad/aok.js/blob/master/example/example.zip?raw=true --type zip # more in aok -h aok https://github.com/apporoad/pnote.git --type git -r api -s static -w pnote -d
code
npm i --save aok.js
const aok = aok
how to debug
debug use debug
# LINUX DEBUG=* aok xxx xxx #windows powershell $env:DEBUG = "*,-not_this"
how to deploy
npm i -g pm2npm i -g aok.js pm2 start --name yourApp aok -- . -p 11540
ps
we use '_any_' as '*' with your fileName
you can :
_any_.js => /*
abc/_any_.js => /abc/*
// .json support json node operations
you can :
GET http://localhost:11540/?node=abc.hello
PUT http://localhost:11540/?node=abc.hello
DELETE http://localhost:11540/?node=abc.hello
just try it
docker
how to debug
推荐做法是直接采用本地引用,直接调用方式
一些情况必须启动aok,vscode 采用如下配置方式: