@niledatabase/server 2.2.1-alpha.0 → 2.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -6
- package/dist/Server.d.ts +4 -3
- package/dist/index.d.ts +3 -2
- package/dist/server.cjs.development.js +34 -7
- package/dist/server.cjs.development.js.map +1 -1
- package/dist/server.cjs.production.min.js +1 -1
- package/dist/server.cjs.production.min.js.map +1 -1
- package/dist/server.esm.js +33 -7
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,13 +9,11 @@ Consolidates the API and DB for working with Nile.
|
|
|
9
9
|
```ts
|
|
10
10
|
import Nile from '@niledatabase/server';
|
|
11
11
|
|
|
12
|
-
const nile =
|
|
12
|
+
const nile = await Nile({
|
|
13
13
|
user: 'username',
|
|
14
14
|
password: 'password',
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
await nile.init();
|
|
18
|
-
|
|
19
17
|
await nile.api.createTenant({ name: 'name' });
|
|
20
18
|
|
|
21
19
|
await nile.db.query('select * from todo');
|
|
@@ -31,9 +29,7 @@ NILEDB_PASSWORD=password
|
|
|
31
29
|
```ts
|
|
32
30
|
import Nile from '@niledatabase/server';
|
|
33
31
|
|
|
34
|
-
const nile =
|
|
35
|
-
|
|
36
|
-
await nile.init();
|
|
32
|
+
const nile = await Nile();
|
|
37
33
|
|
|
38
34
|
await nile.api.createTenant({ name: 'name' });
|
|
39
35
|
|
package/dist/Server.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ type Api = {
|
|
|
9
9
|
users: Users;
|
|
10
10
|
tenants: Tenants;
|
|
11
11
|
};
|
|
12
|
-
declare class Server {
|
|
12
|
+
export declare class Server {
|
|
13
13
|
config: Config;
|
|
14
14
|
api: Api;
|
|
15
15
|
private manager;
|
|
16
16
|
private servers;
|
|
17
17
|
constructor(config?: ServerConfig);
|
|
18
18
|
setConfig(cfg: Config): void;
|
|
19
|
-
init(cfg?: Config): Promise<
|
|
19
|
+
init(cfg?: Config): Promise<this>;
|
|
20
20
|
set databaseId(val: string | void);
|
|
21
21
|
get userId(): string | undefined | null;
|
|
22
22
|
set userId(userId: string | undefined | null);
|
|
@@ -32,4 +32,5 @@ declare class Server {
|
|
|
32
32
|
*/
|
|
33
33
|
getInstance(config: ServerConfig): Server;
|
|
34
34
|
}
|
|
35
|
-
export
|
|
35
|
+
export declare function create(config?: ServerConfig): Promise<Server>;
|
|
36
|
+
export default create;
|
package/dist/index.d.ts
CHANGED
|
@@ -1794,10 +1794,13 @@ function createProxyForPool(pool, config) {
|
|
|
1794
1794
|
return new Proxy(pool, {
|
|
1795
1795
|
get: function get(target, property) {
|
|
1796
1796
|
if (property === 'query') {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1797
|
+
// give connection string a pass for these problems
|
|
1798
|
+
if (!config.db.connectionString) {
|
|
1799
|
+
if (!config.user || !config.password) {
|
|
1800
|
+
error('Cannot connect to the database. User and/or password are missing. Generate them at https://console.thenile.dev');
|
|
1801
|
+
} else if (!config.db.database) {
|
|
1802
|
+
error('Database name is missing from the config. Call `nile.init()` or set NILEDB_ID in your .env');
|
|
1803
|
+
}
|
|
1801
1804
|
}
|
|
1802
1805
|
var caller = target[property];
|
|
1803
1806
|
return function query() {
|
|
@@ -2043,7 +2046,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
2043
2046
|
this.setConfig(updatedConfig);
|
|
2044
2047
|
this.manager = new DBManager(this.config);
|
|
2045
2048
|
this.api = _init(updatedConfig);
|
|
2046
|
-
|
|
2049
|
+
return _context.abrupt("return", this);
|
|
2050
|
+
case 7:
|
|
2047
2051
|
case "end":
|
|
2048
2052
|
return _context.stop();
|
|
2049
2053
|
}
|
|
@@ -2143,8 +2147,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
2143
2147
|
}
|
|
2144
2148
|
}]);
|
|
2145
2149
|
}();
|
|
2150
|
+
function create(_x2) {
|
|
2151
|
+
return _create.apply(this, arguments);
|
|
2152
|
+
}
|
|
2153
|
+
function _create() {
|
|
2154
|
+
_create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config) {
|
|
2155
|
+
var server;
|
|
2156
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
2157
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
2158
|
+
case 0:
|
|
2159
|
+
server = new Server(config);
|
|
2160
|
+
_context2.next = 3;
|
|
2161
|
+
return server.init();
|
|
2162
|
+
case 3:
|
|
2163
|
+
return _context2.abrupt("return", _context2.sent);
|
|
2164
|
+
case 4:
|
|
2165
|
+
case "end":
|
|
2166
|
+
return _context2.stop();
|
|
2167
|
+
}
|
|
2168
|
+
}, _callee2);
|
|
2169
|
+
}));
|
|
2170
|
+
return _create.apply(this, arguments);
|
|
2171
|
+
}
|
|
2146
2172
|
|
|
2147
|
-
module.exports =
|
|
2173
|
+
module.exports = create;
|
|
2148
2174
|
|
|
2149
|
-
exports.
|
|
2175
|
+
exports.Server = Server;
|
|
2176
|
+
exports.default = create;
|
|
2150
2177
|
//# sourceMappingURL=server.cjs.development.js.map
|