Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ES5 compatible #80

Merged
merged 14 commits into from
May 20, 2022
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
],
"plugins": [
[
"@babel/plugin-transform-runtime"
]
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ node_modules/
# the built documentation
out/

# the ES5 build
dist/

# GeoPackage
*gpkg-shm
*gpkg-wal
Expand Down
9 changes: 9 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hooks": {
"before:init": "npm run lint",
"after:bump": "npm run build"
},
"github": {
"release": false
}
}
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ Compatible with [GeoServer](https://geoserver.org)
- v2.18.x (no more maintained and officially deprecated)
- v2.17.x (no more maintained and officially deprecated)


### Usage

```shell
npm i geoserver-node-client
```

usage with require (ES5):
```js
const grcImport = require('geoserver-node-client');
const GeoServerRestClient = grcImport.GeoServerRestClient;

const url = 'http://localhost:8080/geoserver/rest/';
const user = 'admin';
const pw = 'geoserver';
const grc = new GeoServerRestClient(url, user, pw);

async function main () {
const result = await grc.about.exists();
console.log(result);
};

main();
```

usage as ES module (ES6)
```js
import {GeoServerRestClient} from 'geoserver-node-client';

const url = 'http://localhost:8080/geoserver/rest/';
const user = 'admin';
const pw = 'geoserver';
const grc = new GeoServerRestClient(url, user, pw);

async function main () {
const result = await grc.about.exists();
console.log(result);
};

main();
```

### Setup

Run as local checkout (mainly for development purposes)
Expand Down
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GeoServerRestClient from '../geoserver-rest-client.js';
import { GeoServerRestClient } from '../geoserver-rest-client.js';

const url = 'http://localhost:8080/geoserver/rest/';
const user = 'admin';
Expand Down
2 changes: 1 addition & 1 deletion geoserver-rest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import AboutClient from './src/about.js';
*
* @module GeoServerRestClient
*/
export default class GeoServerRestClient {
export class GeoServerRestClient {
/**
* Creates a GeoServerRestClient instance.
*
Expand Down
Loading