diff --git a/.gitignore b/.gitignore index 40b878d..504afef 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules/ \ No newline at end of file +node_modules/ +package-lock.json diff --git a/config.json b/config.json new file mode 100644 index 0000000..2c42b4f --- /dev/null +++ b/config.json @@ -0,0 +1,6 @@ +{ + "host": "localhost", + "user": "maps", + "password": "maps", + "database": "maps" +} \ No newline at end of file diff --git a/index.js b/index.js index 0480dfe..989c128 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,21 @@ +const mysql = require('mysql'); const express = require('express'); +const config = require('./config.json'); const app = express(); +const con = mysql.createConnection(config); + +con.connect(function(err) { + if (err) throw err; + con.query("SELECT * FROM points", function (err, result, fields) { + if (err) throw err; + console.log(result); + app.get('/points', function (req, res) { + res.send(result) + }) + }); +}); + app.use(express.static('public')); app.listen(3000, function () { diff --git a/maps.sql b/maps.sql new file mode 100644 index 0000000..0fef427 --- /dev/null +++ b/maps.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS `points`; +CREATE TABLE `points` ( + `id` int(11) NOT NULL, + `name` varchar(16) NOT NULL, + `lat` float NOT NULL, + `lng` float NOT NULL, + `info` varchar(256) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +LOCK TABLES `points` WRITE; +INSERT INTO `points` VALUES (1,'WroTest',51,17,'test test test'); +UNLOCK TABLES; diff --git a/package.json b/package.json index ee64430..4b1843e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "homepage": "https://github.com/dynak-net/super-simple-maps#readme", "dependencies": { - "express": "^4.15.3" + "express": "^4.15.3", + "mysql": "^2.13.0" } } diff --git a/public/index.html b/public/index.html index 9dbd904..5ae2db1 100644 --- a/public/index.html +++ b/public/index.html @@ -11,7 +11,8 @@
- +