Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
presets: [require.resolve('@docusaurus/core/lib/babel/preset')]
}
76 changes: 38 additions & 38 deletions doc/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { themes as prismThemes } from 'prism-react-renderer';
import { themes as prismThemes } from 'prism-react-renderer'

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand All @@ -18,7 +18,7 @@ const config = {

i18n: {
defaultLocale: 'en',
locales: ['en'],
locales: ['en']
},

presets: [
Expand All @@ -28,24 +28,24 @@ const config = {
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://github.com/IntegerAlex/hasty-server/tree/master/doc',
editUrl: 'https://github.com/IntegerAlex/hasty-server/tree/master/doc'
},
blog: {
showReadingTime: true,
feedOptions: {
type: ['rss', 'atom'],
xslt: true,
xslt: true
},
editUrl: 'https://github.com/IntegerAlex/hasty-server.git',
onInlineTags: 'warn',
onInlineAuthors: 'warn',
onUntruncatedBlogPosts: 'warn',
onUntruncatedBlogPosts: 'warn'
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
}),
],
customCss: require.resolve('./src/css/custom.css')
}
})
]
],

themeConfig:
Expand All @@ -54,34 +54,34 @@ const config = {
colorMode: {
defaultMode: 'dark',
disableSwitch: false,
respectPrefersColorScheme: true,
respectPrefersColorScheme: true
},
announcementBar: {
id: 'welcome',
content: '🚀 Welcome to Hasty Server Docs! Explore and build amazing web servers.',
backgroundColor: '#4f46e5',
textColor: '#ffffff',
isCloseable: true,
isCloseable: true
},
navbar: {
title: 'Hasty Server',
logo: {
alt: 'Hasty Server Logo',
src: 'img/logo.svg',
src: 'img/logo.svg'
},
items: [
{
type: 'docSidebar',
sidebarId: 'docsSidebar',
position: 'left',
label: 'Docs',
label: 'Docs'
},
{
href: 'https://github.com/IntegerAlex/hasty-server',
label: 'GitHub',
position: 'right',
},
],
position: 'right'
}
]
},
footer: {
style: 'dark',
Expand All @@ -91,56 +91,56 @@ const config = {
items: [
{
label: 'Docs',
to: '/docs/intro',
},
],
to: '/docs/intro'
}
]
},
{
title: 'Community',
items: [
{
label: 'GitHub',
href: 'https://github.com/IntegerAlex/hasty-server.git',
},
],
href: 'https://github.com/IntegerAlex/hasty-server.git'
}
]
},
{
title: 'More',
items: [
{
label: 'GitHub',
href: 'https://github.com/IntegerAlex/hasty-server',
},
],
},
href: 'https://github.com/IntegerAlex/hasty-server'
}
]
}
],
copyright: `Copyright © ${new Date().getFullYear()} Hasty Server.`,
copyright: `Copyright © ${new Date().getFullYear()} Hasty Server.`
},
prism: {
theme: {
...prismThemes.github,
plain: {
...prismThemes.github.plain,
backgroundColor: '#f8fafc',
},
backgroundColor: '#f8fafc'
}
},
darkTheme: {
...prismThemes.dracula,
plain: {
...prismThemes.dracula.plain,
backgroundColor: '#1e293b',
},
backgroundColor: '#1e293b'
}
},
additionalLanguages: ['http', 'bash', 'json'],
additionalLanguages: ['http', 'bash', 'json']
},
docs: {
sidebar: {
hideable: true,
autoCollapseCategories: true,
},
autoCollapseCategories: true
}
},
image: 'img/social-card.png',
}),
};
image: 'img/social-card.png'
})
}

export default config;
export default config
22 changes: 11 additions & 11 deletions doc/sidebars.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Sidebar configuration for Hasty Server documentation
*
*
* This file defines the navigation structure for the documentation site.
* The sidebar is organized into logical sections for easy navigation.
*/
Expand All @@ -18,10 +18,10 @@ const sidebars = {
collapsible: true,
collapsed: false,
items: [
'getting-started/quick-start',
],
'getting-started/quick-start'
]
},

// Guides section
{
type: 'category',
Expand All @@ -33,13 +33,13 @@ const sidebars = {

'guides/static-files',
'guides/error-handling',
'guides/limitations',
],
'guides/limitations'
]
},

// Additional standalone pages
'index',
],
};
'index'
]
}

export default sidebars;
export default sidebars
42 changes: 21 additions & 21 deletions doc/src/components/HomepageFeatures/index.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import clsx from 'clsx';
import Heading from '@theme/Heading';
import styles from './styles.module.css';
import clsx from 'clsx'
import Heading from '@theme/Heading'
import styles from './styles.module.css'

const FeatureList = [
{
title: 'High Performance',
description: 'Hasty Server is designed for speed. It’s built using low-level networking APIs, ensuring minimal overhead and high concurrency. This makes it capable of handling thousands of requests per second with ease, perfect for high-traffic applications.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
},
{
title: 'Developer Friendly',
description: 'It offers a simple and intuitive API, inspired by Express.js. Whether you’re a beginner or an experienced developer, the clear structure and easy-to-use syntax allow you to build applications faster and with fewer bugs.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
},
{
title: 'Built-in Security',
description: 'Security is a top priority. Hasty Server includes built-in protections against common vulnerabilities such as XSS (Cross-Site Scripting), CSRF (Cross-Site Request Forgery), and SQL injection, helping you create secure applications without extra effort.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
},
{
title: 'Extensible Architecture',
description: 'With its middleware-based architecture, Hasty Server allows you to add custom plugins and middlewares. You can extend its functionality by adding your own handlers or integrating third-party libraries with ease.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
},
{
title: 'Lightweight & Minimal',
description: 'Despite its powerful features, Hasty Server remains lightweight and efficient. It minimizes resource consumption, making it ideal for resource-constrained environments such as microservices or serverless applications.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
},
{
title: 'Flexible Routing',
description: 'Hasty Server provides a flexible routing system, allowing you to define routes for different HTTP methods (GET, POST, PUT, DELETE, etc.). You can also create dynamic routes with parameters for even more customization.',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
},
];
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default
}
]

function Feature({Svg, title, description}) {
function Feature ({ Svg, title, description }) {
return (
<div className={clsx('col col--4')}>
<div className="text--center">
<Svg className={styles.featureSvg} role="img" />
<div className='text--center'>
<Svg className={styles.featureSvg} role='img' />
</div>
<div className="text--center padding-horiz--md">
<Heading as="h3">{title}</Heading>
<div className='text--center padding-horiz--md'>
<Heading as='h3'>{title}</Heading>
<p>{description}</p>
</div>
</div>
);
)
}

export default function HomepageFeatures() {
export default function HomepageFeatures () {
return (
<section className={styles.features}>
<div className="container">
<div className="row">
<div className='container'>
<div className='row'>
{FeatureList.map((props, idx) => (
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
);
)
}
24 changes: 12 additions & 12 deletions src/lib/cors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DEFAULT_CORS_HEADERS = {
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
'Access-Control-Max-Age': '86400', // 24 hours
'Access-Control-Allow-Credentials': 'true'
};
}

/**
* Applies CORS headers to a response
Expand All @@ -25,17 +25,17 @@ const DEFAULT_CORS_HEADERS = {
* @param {Object} [customHeaders] - Custom CORS headers to merge with defaults
* @returns {void}
*/
function applyCorsHeaders(response, enabled = true, customHeaders = {}) {
if (!enabled) return;
function applyCorsHeaders (response, enabled = true, customHeaders = {}) {
if (!enabled) return

const headers = { ...DEFAULT_CORS_HEADERS, ...customHeaders };
const headers = { ...DEFAULT_CORS_HEADERS, ...customHeaders }

Object.entries(headers).forEach(([key, value]) => {
// Only set if explicitly provided in customHeaders or if not already set
if (customHeaders[key] || !response.headers[key]) {
response.setHeader(key, value);
response.setHeader(key, value)
}
});
})
}

/**
Expand All @@ -45,24 +45,24 @@ function applyCorsHeaders(response, enabled = true, customHeaders = {}) {
* @param {boolean} [enabled=true] - Whether CORS is enabled
* @returns {boolean} - True if this was a preflight request that was handled
*/
function handlePreflight(request, response, enabled = true) {
function handlePreflight (request, response, enabled = true) {
if (!enabled || request.method !== 'OPTIONS') {
return false;
return false
}

applyCorsHeaders(response, true, {
'Access-Control-Allow-Methods': request.headers['access-control-request-method'] ||
DEFAULT_CORS_HEADERS['Access-Control-Allow-Methods'],
'Access-Control-Allow-Headers': request.headers['access-control-request-headers'] ||
DEFAULT_CORS_HEADERS['Access-Control-Allow-Headers']
});
})

response.status(204).send('');
return true;
response.status(204).send('')
return true
}

module.exports = {
applyCorsHeaders,
handlePreflight,
DEFAULT_CORS_HEADERS
};
}
Loading
Loading