Projektstart

This commit is contained in:
2026-01-22 15:49:12 +01:00
parent 7212eb6f7a
commit 57e5f652f8
10637 changed files with 2598792 additions and 64 deletions

View File

@@ -0,0 +1 @@
{"hello": "world"}

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -0,0 +1,9 @@
#my-button {
position: absolute;
top: 50%;
left: 50%;
width: 200px;
height: 28px;
margin-top: -14px;
margin-left: -100px;
}

View File

@@ -0,0 +1,11 @@
<html>
<head>
<script src="index.js"></script>
<link rel="stylesheet" type="text/css" href="index.css"></link>
</head>
<body>
<button id="my-button">
The button
</button>
</body>
</html>

View File

@@ -0,0 +1,8 @@
'use strict'
window.onload = function () {
const b = document.getElementById('my-button')
b.onclick = function () {
window.alert('foo')
}
}

View File

@@ -0,0 +1,4 @@
body {
background-color: black;
color: white;
}

View File

@@ -0,0 +1,8 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="test.css"></link>
</head>
<body>
<h1>Test 2</h1>
</body>
</html>

View File

@@ -0,0 +1,15 @@
'use strict'
const path = require('node:path')
const fastify = require('fastify')({ logger: { level: 'trace' } })
fastify
// Compress everything.
.register(require('@fastify/compress'), { threshold: 0 })
.register(require('../'), {
// An absolute path containing static files to serve.
root: path.join(__dirname, '/public')
})
.listen({ port: 3000 }, err => {
if (err) throw err
})

View File

@@ -0,0 +1,49 @@
'use strict'
const path = require('node:path')
const Handlebars = require('handlebars')
const fastify = require('fastify')({ logger: { level: 'trace' } })
// Handlebar template for listing files and directories.
const template = `
<html>
<body>
dirs
<ul>
{{#dirs}}
<li><a href="{{href}}">{{name}}</a></li>
{{/dirs}}
</ul>
list
<ul>
{{#files}}
<li><a href="{{href}}" target="_blank">{{name}}</a></li>
{{/files}}
</ul>
</body>
</html>
`
const handlebarTemplate = Handlebars.compile(template)
fastify
.register(require('..'), {
// An absolute path containing static files to serve.
root: path.join(__dirname, '/public'),
// Do not append a trailing slash to prefixes.
prefixAvoidTrailingSlash: true,
// Return a directory listing with a handlebar template.
list: {
// html or json response? html requires a render method.
format: 'html',
// A list of filenames that trigger a directory list response.
names: ['index', 'index.html', 'index.htm', '/'],
// You can provide your own render method as needed.
render: (dirs, files) => handlebarTemplate({ dirs, files })
}
})
.listen({ port: 3000 }, err => {
if (err) throw err
})

View File

@@ -0,0 +1,15 @@
'use strict'
const path = require('node:path')
const fastify = require('fastify')({ logger: { level: 'trace' } })
fastify
.register(require('../'), {
// An absolute path containing static files to serve.
root: path.join(__dirname, '/public'),
wildcard: false,
serveDotFiles: true
})
.listen({ port: 3000 }, err => {
if (err) throw err
})

13
backend/node_modules/@fastify/static/example/server.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
'use strict'
const path = require('node:path')
const fastify = require('fastify')({ logger: { level: 'trace' } })
fastify
.register(require('../'), {
// An absolute path containing static files to serve.
root: path.join(__dirname, '/public')
})
.listen({ port: 3000 }, err => {
if (err) throw err
})