WebGIS CRUD server in Node.js

In order to expose our crud API, we will need some storage for our features, so let's start with creating a table of the geometries first:

create table webgis.crud (id serial NOT NULL, geom geometry); 

Once this is ready, we will need a simple web server to handle our CRUD operations. Let's take care of that.

First, we need to put some packages in place:

npm install express --savenpm install body-parser --savenpm install pg --save

Once the appropriate packages are installed, let's create our server:

const pg = require("pg"); const express = require('express'); const app = express(); const bodyParser = require('body-parser'); // configure app to use bodyParser() so we can get data from POST & PUT app.use(bodyParser.urlencoded({ ...

Get Mastering PostGIS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.