Skip to content

Commit

Permalink
Refactor to use ES modules, add eslint, fix issues and CI (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr authored Jan 18, 2024
1 parent d4ba037 commit 151ba9a
Show file tree
Hide file tree
Showing 108 changed files with 802 additions and 749 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# EditorConfig is awesome: https://EditorConfig.org

[*.{js,json,yml}]
charset = utf-8
end_of_line = crlf
indent_style = tabs
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yaml,yml}]
charset = utf-8
end_of_line = crlf
indent_style = spaces
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
15 changes: 15 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
env:
node: true
extends:
- eslint:recommended
- plugin:n/recommended
parserOptions:
ecmaVersion: 2022
sourceType: module
globals:
ee: readonly
rules:
n/no-extraneous-import:
- error
- allowModules:
- restify-errors
16 changes: 12 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ on: [push, pull_request]
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 17 # minimum req. version right now
- lts/*
- latest
steps:
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '16'
- uses: actions/checkout@v2
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
- run: npm install
- run: npm test
- run: npm run lint
- run: npm run sync
- run: npm test
58 changes: 29 additions & 29 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"debug": true,
"hostname": "127.0.0.1",
"port": 8080,
"exposePort": null,
"apiPath": "/v1",
"ssl": {
"port": 443,
"exposePort": null,
"key": null,
"certificate": null
},
"serviceAccountCredentialsFile": "privatekey.json",
"googleProjectId": "",
"id": "openeo-earthengine-driver",
"title": "Google Earth Engine Proxy for openEO",
"description": "This is the Google Earth Engine Driver for openEO.\n\nGoogle Earth Engine is a planetary-scale platform for Earth science data & analysis. It is powered by Google's cloud infrastructure and combines a multi-petabyte catalog of satellite imagery and geospatial datasets with planetary-scale analysis capabilities. Google makes it available for scientists, researchers, and developers to detect changes, map trends, and quantify differences on the Earth's surface. Google Earth Engine is free for research, education, and nonprofit use.",
"currency": "USD",
"plans": {
"default": "free",
"options": [
{
"name": "free",
"description": "Earth Engine is free for research, education, and nonprofit use. For commercial applications, Google offers paid commercial licenses. Please contact [email protected] for details.",
"paid": false
}
]
},
"otherVersions": []
}
"debug": true,
"hostname": "127.0.0.1",
"port": 8080,
"exposePort": null,
"apiPath": "/v1",
"ssl": {
"port": 443,
"exposePort": null,
"key": null,
"certificate": null
},
"serviceAccountCredentialsFile": "privatekey.json",
"googleProjectId": "",
"id": "openeo-earthengine-driver",
"title": "Google Earth Engine Proxy for openEO",
"description": "This is the Google Earth Engine Driver for openEO.\n\nGoogle Earth Engine is a planetary-scale platform for Earth science data & analysis. It is powered by Google's cloud infrastructure and combines a multi-petabyte catalog of satellite imagery and geospatial datasets with planetary-scale analysis capabilities. Google makes it available for scientists, researchers, and developers to detect changes, map trends, and quantify differences on the Earth's surface. Google Earth Engine is free for research, education, and nonprofit use.",
"currency": "USD",
"plans": {
"default": "free",
"options": [
{
"name": "free",
"description": "Earth Engine is free for research, education, and nonprofit use. For commercial applications, Google offers paid commercial licenses. Please contact [email protected] for details.",
"paid": false
}
]
},
"otherVersions": []
}
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
version: '3'
services:
openeo-gee-driver:
build:
context: .
dockerfile: DOCKERFILE
image: openeo-gee:0.3.0
container_name: openeo-earthengine-driver
ports:
- "80:80"
- "443:443"
openeo-gee-driver:
build:
context: .
dockerfile: DOCKERFILE
image: openeo-gee:0.3.0
container_name: openeo-earthengine-driver
ports:
- "80:80"
- "443:443"
20 changes: 0 additions & 20 deletions jest.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"testEnvironment": "node",
"collectCoverage": true,
"coverageDirectory": "coverage",
"errorOnDeprecated": true,
"reporters": [
"default",
[
"./node_modules/jest-html-reporter",
{ "pageTitle": "Test Report for openeo-earthengine-driver" }
]
],
"transform": {},
"fakeTimers": {
"enableGlobally": true
}
}
110 changes: 57 additions & 53 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,59 @@
{
"name": "@openeo/earthengine-driver",
"version": "1.1.0-dev20240116",
"stac_version": "1.0.0",
"description": "An openEO driver for Google Earth Engine.",
"main": "src/server.js",
"scripts": {
"dev": "nodemon src/server.js --trace-warnings",
"up": "npm run sync && pm2 start src/server.js",
"down": "pm2 stop src/server.js",
"sync": "node src/sync.js",
"adduser": "node src/adduser.js",
"test": "jest --env=node",
"debug": "node --nolazy --inspect src/server.js"
},
"author": "Matthias Mohr",
"license": "Apache-2.0",
"homepage": "http://openeo.org",
"bugs": {
"url": "https://github.com/Open-EO/openeo-earthengine-editor/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Open-EO/openeo-earthengine-editor.git"
},
"devDependencies": {
"jest": "^29.7.0",
"jest-html-reporter": "^3.10.2",
"nodemon": "^3.0.2",
"pm2": "^5.3.0"
},
"dependencies": {
"@google-cloud/storage": "^7.7.0",
"@google/earthengine": "^0.1.385",
"@openeo/js-commons": "^1.4.1",
"@openeo/js-processgraphs": "^1.3.0",
"@seald-io/nedb": "^4.0.4",
"ajv": "^6.12.6",
"axios": "^1.6.5",
"check-disk-space": "^3.4.0",
"epsg-index": "^2.0.0",
"fs-extra": "^11.2.0",
"proj4": "^2.10.0",
"restify": "^11.1.0"
},
"engines" : {
"node" : ">=17.0.0"
},
"nodemonConfig": {
"watch": [
"src/",
"server.js"
]
}
"name": "@openeo/earthengine-driver",
"version": "1.1.0-dev20240116",
"stac_version": "1.0.0",
"description": "An openEO driver for Google Earth Engine.",
"main": "src/server.js",
"type": "module",
"scripts": {
"dev": "nodemon src/server.js --trace-warnings",
"up": "npm run sync && pm2 start src/server.js",
"down": "pm2 stop src/server.js",
"sync": "node src/sync.js",
"adduser": "node src/adduser.js",
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --detectOpenHandles",
"debug": "node --nolazy --inspect src/server.js",
"lint": "eslint src/"
},
"author": "Matthias Mohr",
"license": "Apache-2.0",
"homepage": "http://openeo.org",
"bugs": {
"url": "https://github.com/Open-EO/openeo-earthengine-editor/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Open-EO/openeo-earthengine-editor.git"
},
"devDependencies": {
"eslint": "^8.56.0",
"eslint-plugin-n": "^16.6.2",
"jest": "^29.7.0",
"jest-html-reporter": "^3.10.2",
"nodemon": "^3.0.2",
"pm2": "^5.3.0"
},
"dependencies": {
"@google-cloud/storage": "^7.7.0",
"@google/earthengine": "^0.1.385",
"@openeo/js-commons": "^1.4.1",
"@openeo/js-processgraphs": "^1.3.0",
"@seald-io/nedb": "^4.0.4",
"ajv": "^6.12.6",
"axios": "^1.6.5",
"check-disk-space": "^3.4.0",
"epsg-index": "^2.0.0",
"fs-extra": "^11.2.0",
"proj4": "^2.10.0",
"restify": "^11.1.0"
},
"engines": {
"node": ">=17.0.0"
},
"nodemonConfig": {
"watch": [
"src/",
"server.js"
]
}
}
73 changes: 35 additions & 38 deletions src/adduser.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
const ServerContext = require("./servercontext");
const { createInterface } = require('node:readline/promises');
/*eslint n/no-process-exit: "off"*/
import ServerContext from "./utils/servercontext.js";
import { createInterface } from 'node:readline/promises';

async function run() {
const serverContext = new ServerContext();
const users = serverContext.users();
const serverContext = new ServerContext();
const users = serverContext.users();

const rl = createInterface({
input: process.stdin,
output: process.stdout
});
const stop = (code) => {
rl.close();
process.exit(code);
}

const username = await rl.question('Enter a username: ');
if (username && username.length < 4) {
console.error("Username must be at least 4 characters long.");
stop(1);
}
const exists = await users.exists(username);
if (exists) {
console.error("User with the given name already exists.");
stop(1);
}
const rl = createInterface({
input: process.stdin,
output: process.stdout
});
const stop = (code) => {
rl.close();
process.exit(code);
}

const password = await rl.question('Enter a password: ');
if (password && password.length < 4) {
console.error("Password must be at least 4 characters long.");
stop(1);
}
const username = await rl.question('Enter a username: ');
if (username && username.length < 4) {
console.error("Username must be at least 4 characters long.");
stop(1);
}
const exists = await users.exists(username);
if (exists) {
console.error("User with the given name already exists.");
stop(1);
}

try {
await users.register(username, password);
console.log('User created!');
stop(0);
} catch (err) {
console.error(err);
stop(1);
}
const password = await rl.question('Enter a password: ');
if (password && password.length < 4) {
console.error("Password must be at least 4 characters long.");
stop(1);
}

run();
try {
await users.register(username, password);
console.log('User created!');
stop(0);
} catch (err) {
console.error(err);
stop(1);
}
8 changes: 4 additions & 4 deletions src/api/capabilities.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Utils = require('../utils/utils');
const packageInfo = require('../../package.json');
import Utils from '../utils/utils.js';
const packageInfo = Utils.require('../../package.json');

module.exports = class CapabilitiesAPI {
export default class CapabilitiesAPI {

constructor(context) {
this.endpoints = [];
Expand Down Expand Up @@ -134,4 +134,4 @@ module.exports = class CapabilitiesAPI {
output: this.context.outputFormats
});
}
};
}
Loading

0 comments on commit 151ba9a

Please sign in to comment.