๐Ÿ“ฆ ibakaidov / methodjs

Framework for create server rest API.

โ˜… 1 stars โ‘‚ 1 forks ๐Ÿ‘ 1 watching
๐Ÿ“ฅ Clone https://github.com/ibakaidov/methodjs.git
HTTPS git clone https://github.com/ibakaidov/methodjs.git
SSH git clone git@github.com:ibakaidov/methodjs.git
CLI gh repo clone ibakaidov/methodjs
Ivan Bakaidov Ivan Bakaidov 0.0.1 fix path var 32a1e8a 8 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ tests
๐Ÿ“„ .gitignore
๐Ÿ“„ index.js
๐Ÿ“„ package-lock.json
๐Ÿ“„ package.json
๐Ÿ“„ README.MD
๐Ÿ“„ README.md

Methodjs

Framework for create server rest API.

Install

`` bash npm install --save methodjs %%CODEBLOCK0%% javascript const methodjs = require('methodjs').getInstance(); methodjs.eco.db = require('./libs/somedb'); //add your db module to ecosystem methodjs.loadTreeFromDir(__durname+'/methods/'); // load all modules from dir methodjs.express(app); //register urls for methods in your express.js app %%CODEBLOCK1%% bash mkdir methods # create dir for method files mkdir methods/time # create time object touch methods/time/current.js # create file for time.current method %%CODEBLOCK2%%javascript const methodjs = require('methodjs').getInstance(); const app = express(); methodjs.registerRead('time', {}, function current({req, res}) { return new Promise(function (resolve, reject) { resolve({ time: new Date().toLocaleTimeString() }); }) }); %%CODEBLOCK3%% bash curl 127.0.0.1:3000/time/current ``