2.1.2 • Published 3 years ago

datahub-restful-core v2.1.2

Weekly downloads
1
License
ISC
Repository
-
Last release
3 years ago

datahub-restful-core NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

export mysql as restful service on koa v1

中文版

Usage

const koa = require('koa');

const {DatahubRestfulCore} = require('../index');
let port = process.env.PORT || 3003;
let host = process.env.IP || '127.0.0.1';

const core = new DatahubRestfulCore({
    port, host,
    name: 'demo',
    endpoint: "/",
    options:
        {
            client: 'mysql',
            connection: {
                host: '127.0.0.1',
                user: 'root',
                password: '',
                database: 'datahub',
                supportBigNumbers: true,
                bigNumberStrings: true,
                multipleStatements: true
            },
            acquireConnectionTimeout: 60000,
            pool: {min: 0, max: 2}
        }
});

app = core.mount(koa());

app.listen(port, host, function () {
    console.log('Datahub started http://%s:%s', host, port);
});

//curl -v http://127.0.0.1:3003/demo/

features:-)

  • router rules
  • restful interfaces
  • POST/GET/PUT/DELETE
  • pagination
  • order by
  • composite primary keys
  • custom SQL
  • search
  • or condition
  • hooks
  • not
  • in,not in
  • between,not between
  • null,empty string
  • charset

misc

  • execute vm
  • export to xls file
  • import

URL schema

API

KnexHelper object

- getInternalApiUrl() get internal api url`http://${host}:${port}${endpoint}`
- * findConnectionByDbkey(dbkey) get the db id as `cdb_x`
- getDatabaseConnection(cdbId) get datbase raw connection object

Test

tnpm i -g mocha
tnpm run test
2.1.2

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-test.3

4 years ago

2.0.0-test.4

4 years ago

2.0.0-test.2

4 years ago

1.2.4

4 years ago

2.0.0-test.1

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.3.1

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.7-privilege7

5 years ago

1.1.8

5 years ago

1.1.8-beta1

5 years ago

1.1.7-beta1

5 years ago

1.1.7-privilege6

5 years ago

1.1.7-privilege5

5 years ago

1.1.7-privilege4

5 years ago

1.1.7-privilege3

5 years ago

1.1.7-privilege2

5 years ago

1.1.7-privilege1

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.5-beta2

5 years ago

1.1.5-beta

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.1-beta5

5 years ago

1.1.1-beta4

5 years ago

1.1.1-beta3

5 years ago

1.1.1-beta2

5 years ago

1.1.1-beta

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago