Skip to content

Commit 25578f7

Browse files
committed
initial push to vue branch
1 parent 7aaaf17 commit 25578f7

27 files changed

+1987
-330
lines changed

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
# php
111
database/config.php
212
notes.txt
313
sandbox.php
414
endpoint.php
15+
16+
node_modules
17+
dist
18+
dist-ssr
19+
*.local
20+
21+
# Editor directories and files
22+
.vscode/*
23+
!.vscode/extensions.json
24+
.idea
25+
.DS_Store
26+
*.suo
27+
*.ntvs*
28+
*.njsproj
29+
*.sln
30+
*.sw?

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Shortcode API Client
2+
3+
A URl shortening API with a minimal client.
4+
5+
## Stack
6+
- Backend: PHP, MySQL
7+
- Frontend: Vue + TypeScript

api/shorten.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
require "database/Database.php";
23
require "database/functions.php";
34
$config = require "database/config.php";
45
$db = new Database(

global.d.ts

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

index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<link
7+
rel="apple-touch-icon"
8+
sizes="180x180"
9+
href="/favicon/apple-touch-icon.png"
10+
/>
11+
<link
12+
rel="icon"
13+
type="image/png"
14+
sizes="32x32"
15+
href="/favicon/favicon-32x32.png"
16+
/>
17+
<link
18+
rel="icon"
19+
type="image/png"
20+
sizes="16x16"
21+
href="/favicon/favicon-16x16.png"
22+
/>
23+
<link rel="manifest" href="/favicon/site.webmanifest" />
24+
<title>Shortcode API Client</title>
25+
</head>
26+
<body>
27+
<div id="app"></div>
28+
<script type="module" src="/src/main.ts"></script>
29+
</body>
30+
</html>

index.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
<?php
2-
require "database/Database.php";
3-
require "./router.php";
2+
3+
$uri = parse_url($_SERVER["REQUEST_URI"])["path"];
4+
5+
// break down uri components
6+
$uri_components = $uri_components = explode("/", trim($uri, "/"));
7+
8+
// get the amount of paths (/foo/bar = pathSize of 2)
9+
$pathSize = count($uri_components);
10+
11+
// grab the value of the last path
12+
$last_path = $uri_components[$pathSize - 1];
13+
14+
switch ($pathSize) {
15+
case 1:
16+
// route to api to handle either POST for /shorten (via js) or GET for /{shortcode} (via address bar in browser)
17+
if ($last_path == "shorten") {
18+
require "api/shorten.php";
19+
}
20+
break;
21+
case 2:
22+
// route to api to handle GET, POST, PUT, and DELETE for /shorten/code
23+
$endpoint = $uri_components[0];
24+
require "api/{$endpoint}.php";
25+
break;
26+
case 3:
27+
// route to api to handle GET for /shorten/code/stats
28+
break;
29+
}

0 commit comments

Comments
 (0)