Fix #1079 404 error on home page

This commit is contained in:
typicode
2020-02-23 10:15:53 +01:00
parent d945126702
commit f67677fb24
5 changed files with 1 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

View File

@ -1,85 +0,0 @@
<html>
<head>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="style.css" />
<title>JSON Server</title>
</head>
<body>
<header>
<div class="container">
<nav>
<ul>
<li class="title">
JSON Server
</li>
<li>
<a href="https://github.com/users/typicode/sponsorship">
<i class="fas fa-heart"></i>GitHub Sponsors
</a>
</li>
<li>
<a href="https://my-json-server.typicode.com">
<i class="fas fa-burn"></i>My JSON Server
</a>
</li>
<li>
<a href="https://thanks.typicode.com">
<i class="far fa-laugh"></i>Supporters
</a>
</li>
</ul>
</nav>
</div>
</header>
<main>
<div class="container">
<h1>Congrats!</h1>
<p>
You're successfully running JSON Server
<br />
✧*。٩(ˊᗜˋ*)و✧*。
</p>
<div id="resources"></div>
<p>
To access and modify resources, you can use any HTTP method:
</p>
<p>
<code>GET</code>
<code>POST</code>
<code>PUT</code>
<code>PATCH</code>
<code>DELETE</code>
<code>OPTIONS</code>
</p>
<div id="custom-routes"></div>
<h1>Documentation</h1>
<p>
<a href="https://github.com/typicode/json-server">
README
</a>
</p>
</div>
</main>
<footer>
<div class="container">
<p>
To replace this page, create a
<code>./public/index.html</code> file.
</p>
</div>
</footer>
<script src="script.js"></script>
</body>
</html>

View File

@ -1,76 +0,0 @@
function ResourceItem({ name, length }) {
return `
<li>
<a href="${name}">/${name}</a>
<sup>${length ? `${length}x` : 'object'}</sup>
</li>
`
}
function ResourceList({ db }) {
return `
<ul>
${Object.keys(db)
.map(name =>
ResourceItem({
name,
length: Array.isArray(db[name]) && db[name].length
})
)
.join('')}
</ul>
`
}
function NoResources() {
return `<p>No resources found</p>`
}
function ResourcesBlock({ db }) {
return `
<div>
<h1>Resources</h1>
${Object.keys(db).length ? ResourceList({ db }) : NoResources()}
</div>
`
}
window
.fetch('db')
.then(response => response.json())
.then(
db =>
(document.getElementById('resources').innerHTML = ResourcesBlock({ db }))
)
function CustomRoutesBlock({ customRoutes }) {
const rules = Object.keys(customRoutes)
if (rules.length) {
return `
<div>
<h1>Custom Routes</h1>
<table>
${rules
.map(
rule =>
`<tr>
<td>${rule}</td>
<td><code>⇢</code> ${customRoutes[rule]}</td>
</tr>`
)
.join('')}
</table>
</div>
`
}
}
window
.fetch('__rules')
.then(response => response.json())
.then(
customRoutes =>
(document.getElementById('custom-routes').innerHTML = CustomRoutesBlock({
customRoutes
}))
)

View File

@ -1,113 +0,0 @@
body {
display: flex;
min-height: 100vh;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
flex-direction: column;
padding: 0;
margin: 0;
color: #3b4252;
letter-spacing: 0;
}
.container {
max-width: 960px;
margin: auto;
padding: 1rem;
}
header {
border-bottom: 1px solid #eee;
}
header a {
color: inherit;
text-decoration: none;
}
header a:hover {
text-decoration: underline;
}
nav ul {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
}
nav li.title {
flex-grow: 5;
text-align: left;
font-weight: bold;
font-size: 1.4rem;
color: #3b4252;
}
nav li {
flex-grow: 1;
align-self: center;
text-align: right;
color: #4c566a;
}
.fa-heart {
color: deeppink;
}
main {
flex: 1;
}
footer {
margin-top: 4rem;
border-top: 1px solid #eee;
}
h1 {
margin-top: 4rem;
font-weight: normal;
}
i {
margin-right: 0.5rem;
}
a {
color: #5e81ac;
}
a:hover {
color: #81a1c1;
text-decoration: underline;
}
table {
margin-left: 0;
}
td {
border: 0;
padding: 0 1em 0.5em 0;
}
td:first-child {
width: 1%;
white-space: nowrap;
}
ul {
list-style-position: inside;
padding-left: 0;
}
li {
list-style-type: none;
margin-bottom: 0.2rem;
}
code {
padding: 0.2rem;
margin: 0rem 0.2rem;
border-radius: 0.2rem;
background: #e5e9f0;
}

View File

@ -9,7 +9,7 @@ const bodyParser = require('./body-parser')
module.exports = function(opts) {
const userDir = path.join(process.cwd(), 'public')
const defaultDir = path.join(__dirname, '../front')
const defaultDir = path.join(__dirname, '../../public')
const staticDir = fs.existsSync(userDir) ? userDir : defaultDir
opts = Object.assign({ logger: true, static: staticDir }, opts)