
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
@api.global/typedserver
Advanced tools
A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.
A TypeScript-based framework for serving static files with advanced features including live reloading, compression, and type-safe API requests. Part of the @api.global ecosystem, it integrates seamlessly with @api.global/typedrequest for type-safe HTTP requests and @api.global/typedsocket for WebSocket communication.
ts/)ts_web_serviceworker/)CacheManager: Advanced caching strategiesNetworkManager: Request/response handlingUpdateManager: Cache invalidation and updatesServiceWorker: Core service worker implementationts_edgeworker/)ts_web_inject/)npm install @api.global/typedserver
import { TypedServer } from '@api.global/typedserver';
const server = new TypedServer({
port: 3000,
serveDir: './public',
watch: true,
compression: true
});
server.start();
import { TypedRequest } from '@api.global/typedrequest';
// Define your request/response interface
interface IUserRequest {
method: 'getUser';
request: { userId: string };
response: { username: string; email: string; };
}
// Create and use a typed request
const getUserRequest = new TypedRequest<IUserRequest>('/api/users', 'getUser');
const user = await getUserRequest.fire({ userId: '123' });
import { TypedSocket } from '@api.global/typedsocket';
// Server setup
const typedRouter = new TypedRouter();
const server = await TypedSocket.createServer(typedRouter);
// Client connection
const client = await TypedSocket.createClient(typedRouter, 'ws://localhost:3000');
// Type-safe real-time messaging
interface IChatMessage {
method: 'sendMessage';
request: { text: string };
response: { id: string; timestamp: number; };
}
import { ServiceWorker } from '@api.global/typedserver/web_serviceworker';
const sw = new ServiceWorker({
cacheStrategy: 'network-first',
offlineSupport: true
});
sw.register();
import { EdgeWorker } from '@api.global/typedserver/edgeworker';
const edge = new EdgeWorker({
transforms: ['compress', 'minify'],
caching: true
});
interface IServerOptions {
port?: number;
host?: string;
serveDir: string;
watch?: boolean;
compression?: boolean;
cors?: boolean | CorsOptions;
cache?: CacheOptions;
}
type CacheStrategy =
| 'network-first'
| 'cache-first'
| 'stale-while-revalidate';
See API Documentation for detailed API reference.
MIT License - see LICENSE for details.
Task Venture Capital GmbH © 2024
// Define a request type
interface MyCustomRequest {
userId: string;
}
// Define a response type
interface MyCustomResponse {
userName: string;
}
Next, set up a route to handle requests using these types:
import { TypedRouter, TypedHandler } from '@api.global/typedrequest';
// Instantiate a TypedRouter
const typedRouter = new TypedRouter();
// Register a route with request and response types
typedRouter.addTypedHandler<MyCustomRequest, MyCustomResponse>(
new TypedHandler('getUser', async (requestData) => {
// Implement your logic here. For example, fetch user data from a database.
const userData = { userName: 'John Doe' }; // Dummy implementation
return { response: userData };
})
);
// Bind the typed router to the server
typedServer.useTypedRouter(typedRouter);
// Now, the route is set up to handle requests with type checking
This example shows defining types for requests and responses, creating a TypedRouter, and adding a route with typed handling. This feature brings the benefits of TypeScript's static type checking to server-side logic, improving the development experience.
To enable SSL/TLS, configure the TypedServer with the SSL options, including the paths to your SSL certificate and key files:
const serverOptions = {
port: 443,
serveDir: 'public',
watch: true,
injectReload: true,
cors: true,
privateKey: fs.readFileSync('path/to/ssl/private.key'),
publicKey: fs.readFileSync('path/to/ssl/certificate.crt')
};
const typedServer = new TypedServer(serverOptions);
startServer().catch(console.error);
Replace 'path/to/ssl/private.key' and 'path/to/ssl/certificate.crt' with the actual paths to your SSL key and certificate files. This setup ensures that your server communicates over HTTPS, encrypting the data transmitted between the client and the server.
@api.global/typedserver offers a streamlined way to set up a web server with TypeScript, featuring static file serving, live reloading, typed request/response handling, and SSL support. This guide covers the basic usage, but TypedServer is highly configurable, catering to various hosting and development needs.
For a deeper dive into the API and more advanced configurations, refer to the official documentation and type definitions included in the package.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
FAQs
A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.
The npm package @api.global/typedserver receives a total of 44 weekly downloads. As such, @api.global/typedserver popularity was classified as not popular.
We found that @api.global/typedserver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.