Installations
npm install @medishn/gland
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>= 20
Node Version
22.3.0
NPM Version
10.8.1
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.85%)
Shell (1.15%)
Developer
Download Statistics
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
GitHub Statistics
5 Stars
164 Commits
1 Branches
2 Contributors
Package Meta Information
Latest Version
1.1.1
Package Id
@medishn/gland@1.1.1
Unpacked Size
51.22 kB
Size
12.28 kB
File Count
29
NPM Version
10.8.1
Node Version
22.3.0
Publised On
16 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
0
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Gland
Gland
is a lightweight and extensible web server framework for Node.js. It provides a flexible and modular approach to building web applications, including support for middleware, routing, logging, and SQL query execution.
Features
- Modular Configuration: Load and configure modules dynamically.
- Middleware Support: Easily add and manage middleware functions.
- Routing: Define routes using decorators for different HTTP methods.
Installation
You can install @medishn/gland
via npm:
1npm install @medishn/gland
Basic Usage
To get started with @medishn/gland
, follow these steps:
-
Create a Basic Server
1import path from 'path'; 2import gland from '@medishn/gland'; 3 4const g = new gland(); 5g.load(path.join(__dirname, '.confmodule')); 6g.init(3000, () => { 7 console.log('Server running on port 3000'); 8});
-
Define Routes and Handlers Create a
.confmodule
file to configure your routes, caching, and file-watching behavior. This file allows you to dynamically load and configure modules in your application. Below is an example configuration file:
1path = path.join(__dirname, 'router'); 2router { 3 [0]: 'index.ts'; 4 [1]: 'test.ts'; 5} 6cache = true; 7watch = true;
- Create Router:(/router/example.ts)
1import { Context, Get, Route } from '@medishn/gland'; 2 3@Route('/') 4export class Test { 5 @Get() 6 test(ctx: Context) { 7 ctx.write('hello world'); 8 ctx.end(); 9 } 10}
Middleware
You can add middleware functions to your Gland instance:
1import gland, { Context,NxtFunction } from '@medishn/gland'; 2 3const g = new gland(); 4 5const myMiddleware = async (ctx: Context, next: NxtFunction) => { 6 // Middleware logic here 7 await next(); 8}; 9 10g.use(myMiddleware);
Routing
Define routes using decorators:
1import { Context, Get, Post, Route } from '@medishn/gland'; 2 3@Route('/example') 4export class Example { 5 @Get() 6 getExample(ctx: Context) { 7 ctx.write('GET request'); 8 ctx.end(); 9 } 10 11 @Post() 12 postExample(ctx: Context) { 13 ctx.write('POST request'); 14 ctx.end(); 15 } 16}
Contributing
We welcome contributions to the Gland project. Please follow these steps:
- Fork the repository.
- Clone your fork and create a new branch.
- Make your changes and write tests.
- Commit your changes with a descriptive message.
- Push your changes and create a pull request.
For more details, see the CONTRIBUTING.md.
Security
For information on security practices and reporting vulnerabilities, please refer to SECURITY.md.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For any questions or further assistance, please reach out to us at bitsgenix@gmail.com.
No vulnerabilities found.
No security vulnerabilities found.