Skip to content

Commit b4b5f9f

Browse files
committed
refactor: update Node.js module imports and improve content type handling in simple-server
- Changed imports for http, fs, and path to use Node.js built-in module syntax - Enhanced content type handling by formatting the contentType object for better readability - Removed unnecessary whitespace for cleaner code structure
1 parent 226f7e2 commit b4b5f9f

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

apps/docs/simple-server.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const http = require('http');
2-
const fs = require('fs');
3-
const path = require('path');
1+
const http = require('node:http');
2+
const fs = require('node:fs');
3+
const path = require('node:path');
44

55
const server = http.createServer((req, res) => {
66
// Add CORS headers
@@ -9,24 +9,25 @@ const server = http.createServer((req, res) => {
99
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
1010

1111
let filePath = path.join(__dirname, 'storybook-static', req.url === '/' ? 'index.html' : req.url);
12-
12+
1313
// If file doesn't exist, serve index.html for SPA routing
1414
if (!fs.existsSync(filePath)) {
1515
filePath = path.join(__dirname, 'storybook-static', 'index.html');
1616
}
17-
17+
1818
const ext = path.extname(filePath);
19-
const contentType = {
20-
'.html': 'text/html',
21-
'.js': 'text/javascript',
22-
'.css': 'text/css',
23-
'.json': 'application/json',
24-
'.png': 'image/png',
25-
'.jpg': 'image/jpeg',
26-
'.gif': 'image/gif',
27-
'.svg': 'image/svg+xml'
28-
}[ext] || 'text/plain';
29-
19+
const contentType =
20+
{
21+
'.html': 'text/html',
22+
'.js': 'text/javascript',
23+
'.css': 'text/css',
24+
'.json': 'application/json',
25+
'.png': 'image/png',
26+
'.jpg': 'image/jpeg',
27+
'.gif': 'image/gif',
28+
'.svg': 'image/svg+xml',
29+
}[ext] || 'text/plain';
30+
3031
fs.readFile(filePath, (err, content) => {
3132
if (err) {
3233
console.error('Error reading file:', filePath, err);
@@ -43,4 +44,3 @@ const PORT = 45678;
4344
server.listen(PORT, () => {
4445
console.log(`Server running on http://127.0.0.1:${PORT}`);
4546
});
46-

apps/docs/src/remix-hook-form/checkbox-list.stories.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Checkbox } from '@lambdacurry/forms/remix-hook-form/checkbox';
33
import { FormMessage } from '@lambdacurry/forms/remix-hook-form/form';
44
import { Button } from '@lambdacurry/forms/ui/button';
55
import type { Meta, StoryObj } from '@storybook/react-vite';
6-
import { expect, userEvent, within } from '@storybook/test';
6+
import { expect, userEvent, type within } from '@storybook/test';
77
import { type ActionFunctionArgs, Form, useFetcher } from 'react-router';
8-
import { RemixFormProvider, getValidatedFormData, useRemixForm } from 'remix-hook-form';
8+
import { RemixFormProvider, createFormData, getValidatedFormData, useRemixForm } from 'remix-hook-form';
99
import { z } from 'zod';
1010
import { withReactRouterStubDecorator } from '../lib/storybook/react-router-stub';
1111

@@ -137,6 +137,10 @@ const meta: Meta<typeof Checkbox> = {
137137
export default meta;
138138
type Story = StoryObj<typeof meta>;
139139

140+
interface StoryContext {
141+
canvas: ReturnType<typeof within>;
142+
}
143+
140144
const testDefaultValues = ({ canvas }: StoryContext) => {
141145
AVAILABLE_COLORS.forEach(({ label }) => {
142146
const checkbox = canvas.getByLabelText(label);

0 commit comments

Comments
 (0)