在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:ria-com/node-koajs-rest-skeleton开源软件地址:https://github.com/ria-com/node-koajs-rest-skeleton开源编程语言:JavaScript 95.8%开源软件介绍:node-koajs-rest-skeleton v3.5.3A simple Koajs 2.7.0 Application REST Skeleton This version based on koa 2.7.0. quick startCheckout node-koajs-rest-skeleton: $ git clone https://github.com/ria-com/node-koajs-rest-skeleton Make your own new project: $ mv node-koajs-rest-skeleton my_new_project
$ cd my_new_project
$ rm -rf .git Edit package.json: $ vi package.json Edit config/ files:* $ vi config/default.js Install modules $ npm install Start app: $ node ./index.js testingMake your own Spec-files for testing and start test In this skeleton for automatic testing was used jasmine-nodie & Frisby (REST API testing framework). I wrote several tests that you can use as examples. All tests should be placed in the ./spec folder. The name of each test file must end with *Spec.js To run the tests, use $ cd my_new_project
$ npm test Manual testing your REST service: You can also manual check the serviceability of your service with bash and curl get user id 1$ curl -XGET "http://localhost:8081/users/1" get all users$ curl -XGET "http://localhost:8081/users" add new user$ curl -XPOST "http://localhost:8081/users" -d '{"name":"New record 1"}' -H 'Content-Type: application/json' edit user id 3$ curl -XPUT "http://localhost:8081/users/3" -d '{"name":"New record 3"}' -H 'Content-Type: application/json' delete user id 3$ curl -XDELETE "http://localhost:8081/users/3" console apiUsage: /usr/bin/node ./console.js --section [string] [--action [string]] [--opt [object]]
Options:
--opt, --options example --opt.app=mobile --opt.s=1 [default: {}]
--section [required]
--action [default: "index"] For example $ ./console.js --section=default --opt.hello=world
Hello world defaultController & index action with options: {"hello":"world"} rabbitmq apiUsage: NODE_WORKER_NAME=[worker_name] NODE_QUEUE_NAME=[queue_name] /usr/bin/node --harmony ./worker.js For example $ NODE_WORKER_NAME=example NODE_QUEUE_NAME=example /usr/bin/node --harmony ./worker.js kubernetes apiSeveral new features have been added that can be used in conjunction with kubernetes
In order to avoid cluttering the minimal code of our REST-service, additional functionality will be available when running the app via index.kubernetes.js: $ node ./index.kubernetes.js history
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论