File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ cd my-rivet-function
21
21
22
22
# Setup NPM
23
23
npm init -y
24
- npm install hono
24
+ npm install hono@4 @hono/node-server@1
25
25
```
26
26
27
27
Add the following files:
@@ -39,31 +39,25 @@ Add the following files:
39
39
```
40
40
41
41
``` javascript {{ "title": "index.js" }}
42
- const { Hono } = require (' hono' );
43
- const { serve } = require (' hono/node-server' );
42
+ import { Hono } from " hono" ;
43
+ import { serve } from " @hono/node-server" ;
44
+
44
45
const app = new Hono ();
45
46
const port = process .env .PORT_HTTP || 8080 ;
46
47
47
- app .get (' /' , (c ) => {
48
- return c .text (' Hello from Rivet Functions!' );
49
- });
50
-
51
- app .get (' /api/data' , (c ) => {
52
- return c .json ({
53
- message: ' This is data from your Rivet Function' ,
54
- timestamp: new Date ().toISOString ()
55
- });
48
+ app .get (" /" , (c ) => {
49
+ return c .text (" Hello from Rivet Functions!" );
56
50
});
57
51
58
52
console .log (` Server running on port ${ port} ` );
59
53
serve ({
60
- fetch: app .fetch ,
61
- port
54
+ fetch: app .fetch ,
55
+ port,
62
56
});
63
57
```
64
58
65
59
``` dockerfile {{ "title": "Dockerfile" }}
66
- FROM node:18 -alpine
60
+ FROM node:22 -alpine
67
61
68
62
RUN addgroup -S rivet && adduser -S rivet -G rivet
69
63
@@ -76,8 +70,6 @@ COPY . .
76
70
RUN chown -R rivet:rivet /app
77
71
USER rivet
78
72
79
- EXPOSE 8080
80
-
81
73
CMD ["node" , "index.js" ]
82
74
```
83
75
You can’t perform that action at this time.
0 commit comments