Skip to content
Merged
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
18 changes: 9 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: "\U0001F41B Bug Report"
description: "If something isn't working as expected \U0001F914"
title: "[Bug]: "
labels: ["Bug 🪲"]
assignees: ["mr-mkz"]
projects: ["AxonJsLabs/1"]
title: '[Bug]: '
labels: ['Bug 🪲']
assignees: ['mr-mkz']
projects: ['AxonJsLabs/1']
body:
- type: checkboxes
attributes:
label: "🤔 Is there an existing issue for this?"
description: "Please search [here](./?q=is%3Aissue) to see if an issue already exists for the bug you encountered"
label: '🤔 Is there an existing issue for this?'
description: 'Please search [here](./?q=is%3Aissue) to see if an issue already exists for the bug you encountered'
options:
- label: "I have searched the existing issues"
- label: 'I have searched the existing issues'
required: true

- type: textarea
validations:
required: true
attributes:
label: "📝 Discription"
label: '📝 Discription'
description: |
**Tip:** You can attach images, recordings or log files by clicking this area to highlight it and then dragging files in

Expand All @@ -32,7 +32,7 @@ body:
---
- type: textarea
attributes:
label: "Other"
label: 'Other'
description: |
Anything else relevant? eg: Logs, Browser, package manager, etc.
**Tip:** You can attach images, recordings or log files by clicking this area to highlight it and then dragging files in
18 changes: 9 additions & 9 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: "\U0001F680 Feature Request"
description: "I have a suggestion \U0001F63B!"
title: "[Feat]: "
labels: ["Enhancement 💡"]
assignees: ["mr-mkz"]
projects: ["AxonJsLabs/1"]
title: '[Feat]: '
labels: ['Enhancement 💡']
assignees: ['mr-mkz']
projects: ['AxonJsLabs/1']
body:
- type: checkboxes
attributes:
label: "Is there an existing issue that is already proposing this?"
description: "Please search [here](./?q=is%3Aissue) to see if an issue already exists for the feature you are requesting"
label: 'Is there an existing issue that is already proposing this?'
description: 'Please search [here](./?q=is%3Aissue) to see if an issue already exists for the feature you are requesting'
options:
- label: "I have searched the existing issues"
- label: 'I have searched the existing issues'
required: true

- type: textarea
validations:
required: true
attributes:
label: "🪄 describe your feature or idea"
description: "A clear and concise description of what you need to implement"
label: '🪄 describe your feature or idea'
description: 'A clear and concise description of what you need to implement'
placeholder: |
I have an idea ...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
docs
dist
/.idea
coverage
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ Latest change: (v0.13.0)
// Also you can register dependencies with name aliases
core.registerDependencyValue(['depClass', 'classDep', 'DB'], new DependencyClass());
```

- NeuronContainer service
Neuron Container is a service to create and handle dependency containers in your project.
Also Axon core is using Neuron Container for dependency injection feature.

```typescript
import { NeuronContainer } from "@axonlabs/core";
import { NeuronContainer } from '@axonlabs/core';

const container = new NeuronContainer();
container.registerValue();
Expand Down Expand Up @@ -87,12 +89,10 @@ You can checkout Axon benchmarks document and results from below link.

[Axon Benchmarks](./benchmarks/README.md)

| Name | Request | Response|
|---------|-----------|---------|
| Axon | 16146.45 | 42.79ms |
| Express | 8865.71 | 45.89ms |


| Name | Request | Response |
| ------- | -------- | -------- |
| Axon | 16146.45 | 42.79ms |
| Express | 8865.71 | 45.89ms |

## Badges 📛

Expand Down Expand Up @@ -162,7 +162,6 @@ You can checkout Axon benchmarks document and results from below link.
- Improve AxonCore
- Cleaner code


## Documentation 📚

Currently Axon has a main core and a router class which you can make instance from router class every where you want and then gave the router instance to core to load routes.
Expand Down Expand Up @@ -282,7 +281,7 @@ Example:
```js
const controller = async (req, res) => {
return res.status(200).body({
message: 'Hello, World'
message: 'Hello, World',
});
};
```
Expand All @@ -291,7 +290,7 @@ const controller = async (req, res) => {
class AuthController extends BaseController {
async index(req, res) {
return res.status(200).body({
message: 'Hello, World'
message: 'Hello, World',
});
}
}
Expand All @@ -301,10 +300,10 @@ Registering controllers:

```js
// function controller
router.get("/", controller);
router.get('/', controller);

// class controller
router.get("/auth", [AuthController, "index"]);
router.get('/auth', [AuthController, 'index']);
```

### Middleware 🚓
Expand All @@ -316,13 +315,13 @@ middleware is a function which runs before running controller for validations or
```js
router
.get('/', controller)
.middleware(async (req, res, next) => next(), timeout = 2000, critical = true);
.middleware(async (req, res, next) => next(), (timeout = 2000), (critical = true));
```
you can also use multiple middlewares for a route by repeating middleware function and middlewares will run in order.
2. loading middleware as a global middleware in Axon core.
- Example:
```js
core.globalMiddleware(async (req, res, next) => next(), timeout = 2000, critical = true);
core.globalMiddleware(async (req, res, next) => next(), (timeout = 2000), (critical = true));
```
you can also use multiple middlewares in this way by adding middleware functions into an array (suggested method) or repeating this line of code.

Expand All @@ -336,7 +335,7 @@ AxonJs has some types which can help you in developing your applications for aut

- `AxonCoreConfig`: Type of core config object for configuration Axon core as you want.
- `AxonResponseMessage`: Type of core config option RESPONSE_MESSAGES.
- `AxonCorsConfig`: Type of core config option CORS.
- `CorsOptions`: Type of core config option CORS.
- `AxonHttpsConfig`: Type of core config option HTTPS.
- `Request<Params>`: Type of controller request param. (IncomingMessage)
- `Response`: Type of controller response param. (ServerResponse)
Expand Down Expand Up @@ -401,7 +400,7 @@ Configs:
- `LOGGER`: boolean to set core logger on or off. (default true)
- `LOGGER_VERBOSE`: boolean to set core logger in verbose mode. (default false)
- `RESPONSE_MESSAGES`: object to change default value of some core responses. (type: AxonResponseMessage)
- `CORS`: object to change core cors settings. (type: AxonCorsConfig)
- `CORS`: object to change core cors settings. (type: CorsOptions)
- `HTTPS`: object to config server for https. (type: AxonHttpsConfig)
- `MIDDLEWARE_TIMEOUT`: variable to set global timeout of waiting for middleware to response or call next function. (ms, default 10000ms)
- `PROJECT_ENV`: Project environment type to manage features more secure and automatically in AxonCore.
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/log/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxonCore, axonLogger, AxonPlugin, Router } from '../../../src';
import { PluginMode } from '../../../src/types/PluginTypes';
import { PluginMode } from '../../../src/types/Plugin';
export class LogPluginTest implements AxonPlugin {
private logs: number;

Expand Down
30 changes: 23 additions & 7 deletions examples/routers/v1.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FuncController, Router, Request } from '../../src';

import { z } from 'zod';
import * as z3 from 'zod/v3';
import * as z4 from 'zod';
import * as yup from 'yup';
import Joi from 'joi';

Expand All @@ -27,10 +28,16 @@ const bodySchema = Joi.object({
age: Joi.number().integer().min(0).required(),
});

// --- Zod for QUERY validation ---
const querySchema = z.object({
search: z.string().min(1),
limit: z.coerce.number().min(1).max(100).default(10),
// --- Zod v3 for QUERY validation ---
const querySchema = z3.object({
search: z3.string().min(1),
limit: z3.number().min(1).max(100),
});

// --- Zod v4 for QUERY validation ---
const querySchemaZ4 = z4.object({
search: z4.string().min(10),
limit: z4.number().min(1).max(100).default(10),
});

// --- Yup for PARAMS validation ---
Expand Down Expand Up @@ -62,13 +69,22 @@ router
abortEarly: false,
} as Joi.ValidationOptions,
},
// Zod Schema using Zod v3
{
schema: querySchema,
target: 'query',
options: {
path: ['Query Schema'],
} as z.ParseParams,
path: ['Query Schema v3'],
} as z3.ParseParams,
},
// Zod Schema using Zod v4
// {
// schema: querySchemaZ4,
// target: 'query',
// options: {
// path: ['Query Schema v4']
// },
// },
{
schema: paramsSchema,
target: 'params',
Expand Down
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { createDefaultPreset } = require('ts-jest');

const tsJestTransformCfg = createDefaultPreset().transform;

/** @type {import("jest").Config} **/
module.exports = {
testEnvironment: 'node',
transform: {
...tsJestTransformCfg,
},
};
7 changes: 0 additions & 7 deletions jest.config.ts

This file was deleted.

Loading