-
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.
Updated deploy process and some config
- Loading branch information
Mark Hanna
committed
Dec 16, 2023
1 parent
79fe0b7
commit 72e1d09
Showing
11 changed files
with
195 additions
and
69 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules\\typescript\\lib" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Page not found</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="robots" content="noindex"> | ||
|
||
|
||
<link rel="stylesheet" href="/assets/css/main.css"> | ||
</head> | ||
<body> | ||
<h1>Page not found</h1> | ||
</body> | ||
</html> |
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,27 +1,51 @@ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
import { dirname, join } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
import dotenv from 'dotenv'; | ||
import express from 'express'; | ||
|
||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
||
dotenv.config(); | ||
const app = express(); | ||
|
||
const port = process.env.PORT; | ||
const projectName = process.env.PROJECT_NAME; | ||
|
||
app.use(express.static('app')); | ||
|
||
if (projectName) { | ||
// GitHub Pages publishes projects to <username>.github.io/<projectname> | ||
// This breaks root-relative URLs, so instead use "/projectname/path/" locally | ||
// and resolve it by redirecting it here to a root relative path. | ||
const ghPagesPathPattern = new RegExp(`^/${projectName}(/|$)`, 'i'); | ||
|
||
const ghPagesPathPattern = new RegExp(`^/${projectName}/`, 'i'); | ||
app.get(ghPagesPathPattern, (req, res) => { | ||
const path = req.url.replace(ghPagesPathPattern, '/'); | ||
const url = `http://${req.headers.host}${path}`; | ||
app.use((request, response, next) => { | ||
if (!ghPagesPathPattern.test(request.url)) { | ||
response.status(404); | ||
response.send(`<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Error</title> | ||
</head> | ||
<body> | ||
<pre>Cannot GET ${request.url} | ||
Did you mean <a href="/${projectName}${request.url}">/${projectName}${request.url}</a>?</pre> | ||
</body> | ||
</html>`); | ||
return; | ||
} | ||
|
||
res.redirect(url); | ||
request.url = request.url.replace(ghPagesPathPattern, '/'); | ||
next(); | ||
}); | ||
} | ||
|
||
app.use(express.static('app')); | ||
|
||
// Anything not already handled is a 404 | ||
app.get('*', (request, response, next) => { | ||
response.status(404).sendFile(join(__dirname, '../app/404.html')); | ||
}); | ||
|
||
app.listen(port, () => {}); | ||
console.log(`Listening on port ${port}`); |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { beforeAll } from '@jest/globals'; | ||
|
||
beforeAll(() => { | ||
// Any test setup, such as polyfilling features not supported by jsdom, can go here | ||
}); |
Oops, something went wrong.