@mcflyjs/fastify 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayo Ayco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ <p align="center">
2
+ <img width="250" src="https://git.sr.ht/~ayoayco/mcfly/blob/main/assets/mcfly-logo-sm.png" alt="McFly Logo" />
3
+ </p>
4
+
5
+ <h1 align="center">McFly Fastify Adapter</h1>
6
+
7
+ Use fastify as a server framework in McFly
8
+
9
+ ```
10
+ npm create mcfly@latest
11
+ ```
12
+
13
+ <p align="center"><strong>McFly</strong> is a no-framework framework<br />that assists in building on the Web</p>
14
+
15
+ <p align="center">
16
+ <img src="https://img.shields.io/badge/from-the_future-blue?style=flat" />
17
+ <img src="https://img.shields.io/badge/status-legit-purple?style=flat" />
18
+ <a href="https://mc-fly.vercel.app/demo" target="_blank"><img src="https://img.shields.io/badge/see-the_demo_↗️-blue?style=flat&colorB=28CF8D" /></a>
19
+ </p>
20
+
21
+ ## Features
22
+
23
+ The time has come for vanilla Web tech. 🎉
24
+
25
+ ✅ Create web apps with vanilla custom elements<br>
26
+ ✅ Write real .HTML files<br>
27
+ ✅ Have no frameworks or reactivity libraries on the browser<br>
28
+ ✅ Use server-side rendering<br>
29
+ ✅ Deploy anywhere<br>
30
+
31
+ ## Special directories
32
+
33
+ **1. `./src/pages/`**
34
+
35
+ - file-based routing for `.html` files
36
+ - directly use custom elements & static fragments (no imports or registry maintenance needed)
37
+ - use `<script server:setup>` to define logic that runs on the server, which then gets stripped away
38
+
39
+ **2. `./src/components/`**
40
+
41
+ - custom element constructor files (only `.js` files for now)
42
+ - all components are automatically registered using their file names; a `hello-world.js` component can be used as `<hello-world>`
43
+ - static `.html` fragments; a `my-header.html` fragment can be directly used as `<my-header>`
44
+
45
+ **3. `./src/api/`**
46
+
47
+ - file-based routing for REST API endpoints
48
+ - e.g., `./src/api/users.ts` can be accessed via `http://<domain>/api/users`
49
+ - TypeScript or JavaScript welcome!
50
+
51
+ ## McFly config
52
+
53
+ To tell McFly you want to use components, pass the mode (only `"js"` for now) to the `components` prop mcfly.config.ts
54
+
55
+ ```js
56
+ import defineConfig from './packages/define-config'
57
+
58
+ export default defineConfig({
59
+ components: 'js',
60
+ })
61
+ ```
62
+
63
+ ## More info
64
+
65
+ This framework is a result of [an exploration](https://social.ayco.io/@ayo/111195315785886977) for using [**Nitro**](https://nitro.unjs.io) and vanilla JS custom elements using a minimal [**Web Component Base**](https://WebComponent.io) class.
66
+
67
+ **Nitro** is the same production-grade web server powering [**Nuxt**](https://nuxt.com/)
68
+
69
+ ---
70
+
71
+ _Just keep building_<br />
72
+ _A project by [Ayo](https://ayco.io)_
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import serve from './serve'
2
+
3
+ export default () => {
4
+ return {
5
+ serve,
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@mcflyjs/fastify",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "@fastify/autoload": "6.3.1",
14
+ "fastify": "5.8.5"
15
+ }
16
+ }
package/serve.js ADDED
@@ -0,0 +1,22 @@
1
+ import Fastify from 'fastify'
2
+ import AutoLoad from '@fastify/autoload'
3
+ import path from 'node:path'
4
+
5
+ export default ({ rootDir, apiDir, logger, port }) => {
6
+ const server = Fastify()
7
+ const portNumber = port ?? 3000
8
+
9
+ server.register(AutoLoad, {
10
+ dir: path.join(rootDir, apiDir),
11
+ options: {
12
+ prefix: apiDir,
13
+ },
14
+ })
15
+
16
+ server
17
+ .listen({ port: portNumber })
18
+ .then(() => {
19
+ logger.log(`API now serving at http://localhost:${portNumber}${apiDir}`)
20
+ })
21
+ .catch((err) => logger.error(err))
22
+ }