Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EDU-4054] add fs sample project #34

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
11 changes: 11 additions & 0 deletions samples/polyfills/fs/.edge/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"routes": [
{
"from": "/",
"to": ".edge/worker.js",
"priority": 1,
"type": "compute"
}
],
"fs": []
}
2 changes: 2 additions & 0 deletions samples/polyfills/fs/.edge/worker.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions samples/polyfills/fs/.edge/worker.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
6 changes: 6 additions & 0 deletions samples/polyfills/fs/.vulcan
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
preset=javascript
builder=webpack
entry=main.js
mode=compute
useNodePolyfills=true
useOwnWorker=false
1 change: 1 addition & 0 deletions samples/polyfills/fs/azion/args.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions samples/polyfills/fs/azion/azion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
12 changes: 12 additions & 0 deletions samples/polyfills/fs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { readFileSync } from 'fs';

export default function myWorker(event) {
const data = readFileSync('static-html/index.html','utf8')

return new Response(data, {
headers: {
"content-type": "text/html;charset=UTF-8",
},
});
}

55 changes: 55 additions & 0 deletions samples/polyfills/fs/static-html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
color: orange;
font-family: monospace;
font-size: 12px;
text-align: center;
margin: 0;
padding: 50px;
}

pre {
white-space: pre;
}
</style>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: black;
color: orange;
font-family: monospace;
font-size: 12px;
text-align: center;
margin: 0;
padding: 50px;
}

pre {
white-space: pre;
}
</style>
</head>
<body>
<pre>

# # #### # # ###### ##### #### ##### # # ###### ###### ##### #### ######
## ## # # # # # # # # # # # # # # # # # #
# ## # # # # # ##### # # # # ###### ##### ##### # # # #####
# # # # # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # # # #
# # #### ## ###### # #### # # # ###### ###### ##### #### ######


</pre>
</body>
</html>
8 changes: 8 additions & 0 deletions samples/polyfills/fs/vulcan.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
entry: 'main.js',
builder: 'webpack',
useNodePolyfills: true,
memoryFS:{
injectionDirs: ['static-html'],
}
}