-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
154 additions
and
5,285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,8 @@ | ||
# Kandilli API | ||
|
||
[Kandilli Rasathanesi ve Deprem Araştırma Enstitüsü](http://www.koeri.boun.edu.tr/scripts/lst1.asp)'nün son depremler listesinin REST API halidir. Vercel REST API desteği üctretsiz olduğu sürece ücretsizdir. Hiçbir ticari amaç için kullanılmamaktadır. İletişim için [mail adresim](mailto:[email protected]). | ||
[Kandilli Rasathanesi ve Deprem Araştırma Enstitüsü](http://www.koeri.boun.edu.tr/scripts/lst1.asp)'nün son depremler listesinin REST API biçimidir. Ticari | ||
amaçlarla kullanılmaması gerekmektedir. İletişim için [mail adresim](mailto:[email protected]) üzerinden ulaşabilirsiniz. | ||
|
||
## Son 100 deprem | ||
## Son 500 deprem | ||
|
||
[https://kandilli-api.vercel.app/api](https://kandilli-api.vercel.app/api) | ||
|
||
## Örnek Sorgu URL | ||
|
||
[https://kandilli-api.vercel.app/api?sort=ml&minml=4&sehir=ELAZIG&limit=500](https://kandilli-api.vercel.app/api?sort=ml&minml=4&sehir=ELAZIG&limit=500) | ||
|
||
500 deprem arasından ELAZIG şehrindeki minimum 4 büyüklüğündeki depremleri deprem büyüklüğüne göre sıralaması için bir sorgu. | ||
|
||
## Filtrelemeler | ||
|
||
Daha iyi veriler elde etmeniz için birkaç filtreleme ekledim. | ||
|
||
### ?sehir= | ||
|
||
Büyük harflerle ve ingilizce karakterlere uygun bir şekilde türkiyedeki şehirlerden herhangi birisine göre verileri sıralatabilirsiniz. | ||
|
||
### ?limit= | ||
|
||
`10` büyük ve `500` küçük olacak şekilde istediğiniz sayıda veri getirebilirsiniz. Varsayılan ```100```. | ||
|
||
### ?sort= | ||
|
||
En büyükten en küçüğe olacak şekilde sıralmasını istediğiniz anahtar değeri yazarasnız ona göre sıralar. | ||
|
||
### ?minml= | ||
|
||
Depremin büyüklük değeri olan ml nin minumum değerine göre verileri getirebilirsiniz. | ||
[https://kandilli.deno.dev/](https://kandilli.deno.dev/) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"lock": false, | ||
"tasks": { | ||
"dev": "deno run --allow-all --watch main.ts", | ||
"check": "deno check **/*.ts", | ||
"deploy": "deployctl deploy", | ||
"deploy:prod": "deployctl deploy --prod" | ||
}, | ||
"fmt": { | ||
"semiColons": true, | ||
"singleQuote": true, | ||
"lineWidth": 160 | ||
}, | ||
"compilerOptions": { | ||
"strict": true | ||
}, | ||
"lint": { | ||
"rules": { | ||
"exclude": ["no-explicit-any"] | ||
} | ||
}, | ||
"imports": { | ||
"deno-dom": "jsr:@b-fuze/deno-dom", | ||
"hono": "jsr:@hono/hono" | ||
}, | ||
"deploy": { | ||
"project": "e10af582-079f-402c-be3c-407adf702279", | ||
"exclude": ["**/node_modules"], | ||
"include": [], | ||
"entrypoint": "main.ts" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Hono } from 'hono'; | ||
import { cors } from 'hono/cors'; | ||
import { logger } from 'hono/logger'; | ||
import { prettyJSON } from 'hono/pretty-json'; | ||
import { secureHeaders } from 'hono/secure-headers'; | ||
import indexRouter from './routes/index.ts'; | ||
|
||
const app = new Hono(); | ||
|
||
// Middlewares | ||
app.use('*', logger(), cors(), prettyJSON(), secureHeaders()); | ||
|
||
// Routes | ||
app.route('/', indexRouter); | ||
|
||
app.notFound((c) => { | ||
return c.json({ | ||
message: '404 Not Found', | ||
}); | ||
}); | ||
|
||
app.onError((error, c) => { | ||
return c.json(error); | ||
}); | ||
|
||
const PORT = Number.parseInt(Deno.env.get('PORT') || '8000'); | ||
|
||
Deno.serve({ | ||
port: PORT, | ||
onListen: ({ port }) => { | ||
console.info(`Listening on http://localhost:${port}`); | ||
}, | ||
}, app.fetch); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,11 @@ | ||
import express, {type Request, type Response} from 'express'; | ||
import {type Earthquake} from '../types/kandilli.js'; | ||
import getEarthquakeList from '../utilities/kandilli.js'; | ||
import { Hono } from 'hono'; | ||
import fetchEarthquakeData from '../utilities/kandilli.ts'; | ||
|
||
const indexRouter = express.Router(); | ||
const indexRouter = new Hono(); | ||
|
||
indexRouter.get('/', async (request: Request, response: Response) => { | ||
try { | ||
const earthquakeList: Earthquake[] | undefined = await getEarthquakeList(); | ||
let responseData: Earthquake[] | undefined = earthquakeList; | ||
if (request.query.sehir) { | ||
responseData = responseData?.filter( | ||
(deprem: Earthquake) => deprem.sehir === request.query.sehir, | ||
); | ||
} | ||
|
||
if ( | ||
request.query.limit | ||
&& Number(request.query.limit) >= 10 | ||
&& Number(request.query.limit) <= 500 | ||
) { | ||
responseData = responseData?.slice(0, Number(request.query.limit)); | ||
} else { | ||
responseData = responseData?.slice(0, 100); | ||
} | ||
|
||
if (request.query.minml && Number(request.query.minml) > 0) { | ||
responseData = responseData?.filter( | ||
(deprem: Earthquake) => | ||
Number.parseFloat(deprem.ml) > Number(request.query.minml), | ||
); | ||
} | ||
|
||
if (request.query.sort) { | ||
const sortedBy: any = request.query.sort.toString(); | ||
// @ts-expect-error | ||
responseData = responseData?.sort((a, b) => b[sortedBy] - a[sortedBy]); | ||
} | ||
|
||
response.status(200).json(responseData); | ||
} catch (error: any) { | ||
response.status(400).end(error.toString()); | ||
} | ||
indexRouter.get('/', async (c) => { | ||
const earthquakeList = await fetchEarthquakeData(); | ||
return c.json(earthquakeList, 200); | ||
}); | ||
|
||
export default indexRouter; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
export type Earthquake = { | ||
id: string; | ||
tarih: string; | ||
saat: string; | ||
enlem: string; | ||
boylam: string; | ||
derinlik: string; | ||
md: string; | ||
ml: string; | ||
mw: string; | ||
yer: string; | ||
sehir: string; | ||
bolge: string; | ||
nitelik: string; | ||
date: string; | ||
time: string; | ||
latitude: string; | ||
longitude: string; | ||
depth: string; | ||
md: string; | ||
ml: string; | ||
mw: string; | ||
location: string; | ||
city?: string; | ||
region: string; | ||
quality: string; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.