Skip to content

Commit

Permalink
Fix broken windows
Browse files Browse the repository at this point in the history
Includes:

Update dependencies
Switch to GitHub Workflow

PR: #85
  • Loading branch information
wavded authored Jul 7, 2020
1 parent b55edf4 commit 335a946
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 33 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": true,
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"node": true,
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: build
on: push
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: ['10', '12']
name: Node v${{ matrix.node }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: sudo apt-get install gdal-bin
- run: yarn install
- run: yarn lint
- run: yarn test
4 changes: 1 addition & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": false,
"printWidth": 80
"bracketSpacing": false
}
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function enableCors(req, res, next) {
}

function optionsHandler(methods) {
return function(req, res) {
return function (req, res) {
res.header('Allow', methods)
res.send(methods)
}
Expand All @@ -34,7 +34,7 @@ function safelyParseJson(json) {

function noop() {}

exports.createServer = function(opts) {
exports.createServer = function (opts) {
if (!opts) opts = {}

let app = express()
Expand All @@ -45,14 +45,14 @@ exports.createServer = function(opts) {
app.options('/convertJson', enableCors, optionsHandler('POST'))

app.use(express.static(join(__dirname, '/public')))
app.get('/', function(req, res) {
app.get('/', function (req, res) {
res.render('home')
})

app.use(urlencoded({extended: false, limit: 3000000})) // 3mb
app.use(multiparty({maxFilesSize: 100000000})) // 100mb

app.post('/convert', enableCors, function(req, res, next) {
app.post('/convert', enableCors, function (req, res, next) {
if (!req.files.upload || !req.files.upload.name) {
res.status(400).json({error: true, msg: 'No file provided'})
return
Expand Down Expand Up @@ -87,7 +87,7 @@ exports.createServer = function(opts) {
res.attachment()
}

ogr.exec(function(er, data) {
ogr.exec(function (er, data) {
fs.unlink(req.files.upload.path, noop)

if (isOgreFailureError(er)) {
Expand All @@ -105,7 +105,7 @@ exports.createServer = function(opts) {
})
})

app.post('/convertJson', enableCors, function(req, res, next) {
app.post('/convertJson', enableCors, function (req, res, next) {
if (!req.body.jsonUrl && !req.body.json)
return res.status(400).json({error: true, msg: 'No json provided'})

Expand Down Expand Up @@ -136,7 +136,7 @@ exports.createServer = function(opts) {

let format = req.body.format || 'shp'

ogr.format(format).exec(function(er, buf) {
ogr.format(format).exec(function (er, buf) {
if (isOgreFailureError(er))
return res
.status(400)
Expand All @@ -152,7 +152,7 @@ exports.createServer = function(opts) {
})

/* eslint no-unused-vars: [0, { "args": "none" }] */
app.use(function(er, req, res, next) {
app.use(function (er, req, res, next) {
console.error(er.stack)
res.header('Content-Type', 'application/json')
res.status(500).json({error: true, msg: er.message})
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@
"connect-multiparty": "^2.0.0",
"express": "^4.10.2",
"ogr2ogr": "^2.0.0",
"pug": "^2.0.0-rc.3"
"pug": "^3.0.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"supertest": "^4.0.2",
"tape": "^4.8.0"
"tape": "^5.0.1"
},
"engines": {
"node": ">=10"
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://jenkins.adc4gis.com/buildStatus/icon?job=ogre)](https://jenkins.adc4gis.com/job/ogre/) [![NPM](https://img.shields.io/npm/v/ogre.svg)](https://npmjs.com/package/ogre) ![NPM Downloads](https://img.shields.io/npm/dt/ogre.svg)
![Build Status](https://github.com/wavded/ogre/workflows/build/badge.svg?branch=master) [![NPM](https://img.shields.io/npm/v/ogre.svg)](https://npmjs.com/package/ogre) ![NPM Downloads](https://img.shields.io/npm/dt/ogre.svg)

The instructions below are only if you are interested in running the project locally. For help on how to use the web service, visit the [Ogre homepage](http://ogre.adc4gis.com). Ogre makes use of the [ogr2ogr](https://github.com/wavded/ogr2ogr) module.

Expand Down Expand Up @@ -44,7 +44,7 @@ Options:

(The MIT License)

Copyright (c) 2016 Marc Harter <[email protected]>
Copyright (c) 2020 Marc Harter <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
32 changes: 16 additions & 16 deletions test/api-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ const request = require('supertest')
const join = require('path').join
let server

test('create server', function(t) {
test('create server', function (t) {
let app = ogre.createServer()
t.ok(app.request, 'is express')
server = app.listen(9876)
t.ok(server.close, 'is http server')
t.end()
})

test('convert', function(t) {
test('convert', function (t) {
t.plan(7)

request(server)
.post('/convert')
.attach('upload', join(__dirname, '/samples/sample.shp.zip'))
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er

let data = res.body
Expand All @@ -31,7 +31,7 @@ test('convert', function(t) {
.field('targetSrs', 'EPSG:3857')
.attach('upload', join(__dirname, '/samples/sample.shp.zip'))
.expect('Content-Type', 'application/json; charset=utf-8')
.end(function(er, res) {
.end(function (er, res) {
t.notOk(er, 'no error', {error: er})
if (res.body.crs)
// testable on gdal 0.10.x or greater
Expand All @@ -44,7 +44,7 @@ test('convert', function(t) {
.field('forcePlainText', '')
.attach('upload', join(__dirname, '/samples/sample.shp.zip'))
.expect('Content-Type', 'text/plain; charset=utf-8')
.end(function(er) {
.end(function (er) {
t.notOk(er, 'no error', {error: er})
})

Expand All @@ -56,7 +56,7 @@ test('convert', function(t) {
.expect('Allow', 'POST')
.expect('Content-Type', 'text/html; charset=utf-8')
.expect('POST')
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res, 'responded')
})
Expand All @@ -65,7 +65,7 @@ test('convert', function(t) {
.post('/convert')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(400, {error: true, msg: 'No file provided'})
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res, 'bad request when no file uploaded')
})
Expand All @@ -75,13 +75,13 @@ test('convert', function(t) {
.attach('upload', join(__dirname, '/samples/sample.bad'))
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(400)
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res.body.errors.length > 0, 'bad request on failure')
})
})

test('convertJson', function(t) {
test('convertJson', function (t) {
t.plan(5)
request(server)
.post('/convertJson')
Expand All @@ -90,7 +90,7 @@ test('convertJson', function(t) {
jsonUrl:
'https://gist.github.com/wavded/7376428/raw/6dd3ad3de8157956b40f1cf09633e78bbdb1af18/test-single.geojson',
})
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er

let buf = res.text
Expand All @@ -105,7 +105,7 @@ test('convertJson', function(t) {
.expect('Allow', 'POST')
.expect('Content-Type', 'text/html; charset=utf-8')
.expect('POST')
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res, 'responded')
})
Expand All @@ -114,7 +114,7 @@ test('convertJson', function(t) {
.post('/convertJson')
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(400, {error: true, msg: 'No json provided'})
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res, 'bad request when no json sent')
})
Expand All @@ -125,7 +125,7 @@ test('convertJson', function(t) {
.send({json: '{'})
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(400, {error: true, msg: 'Invalid json provided'})
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res, 'bad request on invalid json')
})
Expand All @@ -136,14 +136,14 @@ test('convertJson', function(t) {
.send({json: '{ "invalid": "geojson" }'})
.expect('Content-Type', 'application/json; charset=utf-8')
.expect(400)
.end(function(er, res) {
.end(function (er, res) {
if (er) throw er
t.ok(res.body.errors.length > 0, 'bad request on failure')
})
})

test('close server', function(t) {
server.close(function() {
test('close server', function (t) {
server.close(function () {
t.end()
})
})

0 comments on commit 335a946

Please sign in to comment.