8000 Added an example to start a rest api server · tools-utils/odoo-api@edbe605 · GitHub
[go: up one dir, main page]

Skip to content

Commit edbe605

Browse files
committed
Added an example to start a rest api server
1 parent d4d2fb3 commit edbe605

File tree

6 files changed

+2424
-0
lines changed

6 files changed

+2424
-0
lines changed

examples/.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
9+
}
10+
]
11+
],
12+
"plugins": ["@babel/plugin-transform-async-to-generator"]
13+
}
14+

examples/README

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Usage
2+
3+
```
4+
5+
```
6+
```
7+
yarn build
8+
9+
node lib/index.js
10+
11+
ODOO_HOST=http://0.0.0.0:8069 node lib/index.js
12+
```
13+
14+
# Test
15+
16+
```
17+
curl -d '{"db": "odoo", "login": "a.user", "password": "secret" }' -H 'Content-Type: application/json' http://localhost:9000/auth
18+
```

examples/lib/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use strict";
2+
3+
var _odoo = _interopRequireDefault(require("@tools-utils/odoo"));
4+
5+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6+
7+
const port = 9000;
8+
9+
_odoo.default.api.listen(port);
10+
11+
console.log('Starting Odoo REST API...', port);

examples/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "examples",
3+
"version": "1.0.0",
4+
"description": "Odoo REST API Server",
5+
"main": "lib/index.js",
6+
"license": "MIT",
7+
"scripts": {
8+
"build": "./node_modules/.bin/babel src -d lib"
9+
},
10+
"dependencies": {
11+
"@tools-utils/odoo": "git+https://github.com/tools-utils/odoo-api.git"
12+
},
13+
"devDependencies": {
14+
"@babel/cli": "^7.8.3",
15+
"@babel/core": "^7.8.3",
16+
"@babel/plugin-transform-async-to-generator": "^7.8.3",
17+
"@babel/preset-env": "^7.8.3"
18+
}
19+
}

examples/src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import odoo from '@tools-utils/odoo'
2+
3+
const port = 9000
4+
odoo.api.listen(port)
5+
6+
console.log('Starting Odoo REST API...', port)

0 commit comments

Comments
 (0)
0