Skip to content

Commit e56eb6f

Browse files
committed
chore: update Next.js example
1 parent 4281976 commit e56eb6f

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

examples/nextjs/api/rust.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use serde_json::json;
2-
use std::time::Instant;
2+
use std::time::{Instant, SystemTime};
33
use vercel_runtime::{run, Body, Error, Request, Response, StatusCode};
44

55
#[tokio::main]
@@ -10,7 +10,11 @@ async fn main() -> Result<(), Error> {
1010
pub async fn handler(_req: Request) -> Result<Response<Body>, Error> {
1111
let start = Instant::now();
1212

13-
let seed = 42;
13+
let seed = SystemTime::now()
14+
.duration_since(SystemTime::UNIX_EPOCH)
15+
.unwrap()
16+
.as_secs();
17+
1418
let mut rng = oorandom::Rand32::new(seed);
1519

1620
const RADIUS: u64 = 424242;

examples/nextjs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@types/node": "18.15.3",
1414
"@types/react": "18.0.28",
1515
"@types/react-dom": "18.0.11",
16+
"@vercel/analytics": "^0.1.11",
1617
"clsx": "^1.2.1",
1718
"eslint": "8.36.0",
1819
"eslint-config-next": "13.2.4",

examples/nextjs/pages/_app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import '@/styles/globals.css';
22
import type { AppProps } from 'next/app';
33
import { Inter } from 'next/font/google';
4+
import { Analytics } from '@vercel/analytics/react';
45

56
const inter = Inter({ subsets: ['latin'] });
67

78
export default function App({ Component, pageProps }: AppProps) {
89
return (
910
<main className={inter.className}>
1011
<Component {...pageProps} />
12+
<Analytics />
1113
</main>
1214
);
1315
}

examples/nextjs/pages/api/nodejs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export default function handler(
1515
): void {
1616
const t0 = performance.now();
1717

18-
const seed = 42;
18+
const seed = Math.floor(Date.now() / 1000);
19+
1920
random.use(shishua(seed));
2021

2122
const radius = 424242;

examples/nextjs/pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)