Skip to content

Commit c103001

Browse files
committed
docs: update code for functions example
1 parent ecdd6c8 commit c103001

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

site/src/content/docs/functions.mdx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cd my-rivet-function
2121

2222
# Setup NPM
2323
npm init -y
24-
npm install hono
24+
npm install hono@4 @hono/node-server@1
2525
```
2626

2727
Add the following files:
@@ -39,31 +39,25 @@ Add the following files:
3939
```
4040

4141
```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+
4445
const app = new Hono();
4546
const port = process.env.PORT_HTTP || 8080;
4647

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!");
5650
});
5751

5852
console.log(`Server running on port ${port}`);
5953
serve({
60-
fetch: app.fetch,
61-
port
54+
fetch: app.fetch,
55+
port,
6256
});
6357
```
6458

6559
```dockerfile {{ "title": "Dockerfile" }}
66-
FROM node:18-alpine
60+
FROM node:22-alpine
6761

6862
RUN addgroup -S rivet && adduser -S rivet -G rivet
6963

@@ -76,8 +70,6 @@ COPY . .
7670
RUN chown -R rivet:rivet /app
7771
USER rivet
7872

79-
EXPOSE 8080
80-
8173
CMD ["node", "index.js"]
8274
```
8375

0 commit comments

Comments
 (0)