Skip to content

Commit f3e35db

Browse files
authored
Merge pull request #3 from kolawoletech/master
Added What 3 words API
2 parents a0671b6 + 31d872f commit f3e35db

124 files changed

Lines changed: 335 additions & 9365 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,116 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# Snowpack dependency directory (https://snowpack.dev/)
45+
web_modules/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
172
.env
2-
node_modules/
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
.parcel-cache
78+
79+
# Next.js build output
80+
.next
81+
out
82+
83+
# Nuxt.js build / generate output
84+
.nuxt
85+
dist
86+
87+
# Gatsby files
88+
.cache/
89+
# Comment in the public line in if your project uses Gatsby and not Next.js
90+
# https://nextjs.org/blog/next-9-1#public-directory-support
91+
# public
92+
93+
# vuepress build output
94+
.vuepress/dist
95+
96+
# Serverless directories
97+
.serverless/
98+
99+
# FuseBox cache
100+
.fusebox/
101+
102+
# DynamoDB Local files
103+
.dynamodb/
104+
105+
# TernJS port file
106+
.tern-port
107+
108+
# Stores VSCode versions used for testing VSCode extensions
109+
.vscode-test
110+
111+
# yarn v2
112+
.yarn/cache
113+
.yarn/unplugged
114+
.yarn/build-state.yml
115+
.yarn/install-state.gz
116+
.pnp.*

index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,51 @@ require('dotenv').config()
44

55
api.setOptions({ key: process.env.WHATTHREEWORDS});
66

7+
const express = require('express');
8+
const bodyParser = require('body-parser');
9+
const cors = require('cors');
10+
const helmet = require('helmet');
11+
const morgan = require('morgan');
712

13+
// defining the Express app
14+
const app = express();
15+
16+
app.use(helmet());
17+
18+
// using bodyParser to parse JSON bodies into JS objects
19+
app.use(bodyParser.json());
20+
21+
// enabling CORS for all requests
22+
app.use(cors());
23+
24+
// adding morgan to log HTTP requests
25+
app.use(morgan('combined'));
26+
27+
// defining an endpoint to return all ads
28+
app.get('/', (req, res) => {
29+
res.send(ads);
30+
});
31+
32+
app.get('/convertLatLong/:lat/:long', (req, res) => {
33+
let latitude = req.params.lat;
34+
let longitude = req.params.long;
35+
api.convertTo3wa({lat:latitude, lng:longitude })
36+
.then(data =>
37+
{
38+
res.send(ads);
39+
console.log(data)
40+
}
41+
42+
43+
);
44+
45+
46+
});
47+
48+
api.convertTo3wa({lat:51.520847, lng:-0.195521})
49+
.then(data => console.log(data));
50+
51+
// starting the server
52+
app.listen(3001, () => {
53+
console.log('listening on port 3001');
54+
});

node_modules/@what3words/api/README.md

Lines changed: 0 additions & 146 deletions
This file was deleted.

node_modules/@what3words/api/es2015/fetch.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

node_modules/@what3words/api/es2015/fetch.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

node_modules/@what3words/api/es2015/index.d.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

node_modules/@what3words/api/es2015/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

node_modules/@what3words/api/es2015/requests/autosuggest.d.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)