Skip to content

Commit d135666

Browse files
committed
Updated package-lock.json
Added types to TypeScript code
1 parent b98db22 commit d135666

4 files changed

Lines changed: 2506 additions & 2061 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
.idea

index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Router } from 'itty-router';
1+
import { IRequest, Router } from 'itty-router';
22
import { getCoordinates } from './src/coordinates';
33

44
const router = Router();
55

6-
router.get('/coordinates', async (request) => {
6+
router.get('/coordinates', async (request:IRequest) => {
77
const json = await getCoordinates(request);
88
if (json === null) {
99
return new Response(JSON.stringify({ error: 'Bad Request' }), {
@@ -22,16 +22,17 @@ router.get('/coordinates', async (request) => {
2222
});
2323

2424
router
25-
.get('/redirect', async (request) => {
26-
let json = await getCoordinates(request);
27-
json = JSON.parse(json);
25+
.get('/redirect', async (request:IRequest) => {
26+
let json_raw:string = await getCoordinates(request);
27+
let json:any = JSON.parse(json_raw);
2828
const link = json.url.geo;
2929
return Response.redirect(link);
3030
})
3131

3232
.get('*', async (request) => {
3333
return new Response(JSON.stringify({ error: 'hey' }));
3434
});
35+
3536
addEventListener('fetch', (e) => {
3637
e.respondWith(router.handle(e.request));
3738
});

0 commit comments

Comments
 (0)