Skip to content

Commit

Permalink
Added the Open API Documentation (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanmishra29 authored Dec 11, 2023
1 parent 9b93e3c commit 78fcbe2
Show file tree
Hide file tree
Showing 9 changed files with 1,136 additions and 684 deletions.
789 changes: 105 additions & 684 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dependencies": {
"@maxmind/geoip2-node": "^4.2.0",
"express": "^4.18.2"
},
"name": "geoip",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
7 changes: 7 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import { Reader } from '@maxmind/geoip2-node';
import { Router } from '@stricjs/router';
import * as fs from 'fs';
import Bun from 'bun';
import express from 'express';
import swagger from './util/swagger';

const buffer = fs.readFileSync('./db.mmdb');
const reader = Reader.openBuffer(buffer);

const swaggerApp = express();

swagger(swaggerApp);

// format the success response data
const formatSuccessResponse = (data) => {
Expand Down Expand Up @@ -77,4 +82,6 @@ app.use(404, () => {
app.port = (process.env.PORT || 3000);
app.hostname = '0.0.0.0';


swaggerApp.listen(3001, () => console.log('Swagger listening on port 3000'))
app.listen();
Binary file modified server/bun.lockb
Binary file not shown.
4 changes: 4 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"dependencies": {
"@maxmind/geoip2-node": "^4.2.0",
"@stricjs/router": "^5.0.3",
"@types/swagger-jsdoc": "^6.0.1",
"@types/swagger-ui-express": "^4.1.4",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"bun": "^1.0.7",
"express": "^4.18.2",
"maxmind": "^4.3.16",
Expand Down
197 changes: 197 additions & 0 deletions server/schemas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
components:
schemas:
GeoLocationResponseObject:
type: object
properties:
continent:
type: object
properties:
code:
type: string
geonameId:
type: integer
names:
type: object
properties:
de:
type: string
en:
type: string
es:
type: string
fr:
type: string
ja:
type: string
pt-BR:
type: string
ru:
type: string
zh-CN:
type: string
country:
type: object
properties:
geonameId:
type: integer
isoCode:
type: string
names:
type: object
properties:
de:
type: string
en:
type: string
es:
type: string
fr:
type: string
ja:
type: string
pt-BR:
type: string
ru:
type: string
zh-CN:
type: string
registeredCountry:
type: object
properties:
geonameId:
type: integer
isoCode:
type: string
names:
type: object
properties:
de:
type: string
en:
type: string
es:
type: string
fr:
type: string
ja:
type: string
pt-BR:
type: string
ru:
type: string
zh-CN:
type: string
isInEuropeanUnion:
type: boolean
traits:
type: object
properties:
isAnonymous:
type: boolean
isAnonymousProxy:
type: boolean
isAnonymousVpn:
type: boolean
isHostingProvider:
type: boolean
isLegitimateProxy:
type: boolean
isPublicProxy:
type: boolean
isResidentialProxy:
type: boolean
isSatelliteProvider:
type: boolean
isTorExitNode:
type: boolean
ipAddress:
type: string
network:
type: string
city:
type: object
properties:
geonameId:
type: integer
names:
type: object
properties:
de:
type: string
en:
type: string
ru:
type: string
location:
type: object
properties:
accuracyRadius:
type: integer
latitude:
type: number
longitude:
type: number
timeZone:
type: string
postal:
type: object
properties:
code:
type: string
subdivisions:
type: array
items:
type: object
properties:
geonameId:
type: integer
isoCode:
type: string
names:
type: object
properties:
en:
type: string
fr:
type: string
ja:
type: string
pt-BR:
type: string
ru:
type: string
zh-CN:
type: string

BatchRequestObject:
oneOf:
- type: string
- type: object
properties:
query:
type: string
description: IPv4/IPv6 address (required)
fields:
type: string
description: Response fields (optional)
lang:
type: string
description: Response language (optional)

DnsResponseObject:
type: object
properties:
dns:
type: object
properties:
ip:
type: string
geo:
type: string
edns:
type: object
properties:
ip:
type: string
geo:
type: string
Loading

0 comments on commit 78fcbe2

Please sign in to comment.