Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inuoshios/britannia
geass: a simple logger for your frameworks.
https://github.com/inuoshios/britannia
express-middleware expressjs koa logger logging-library middleware request
Last synced: 3 months ago
JSON representation
geass: a simple logger for your frameworks.
- Host: GitHub
- URL: https://github.com/inuoshios/britannia
- Owner: inuoshios
- License: mit
- Created: 2024-08-23T03:33:28.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-29T00:21:23.000Z (3 months ago)
- Last Synced: 2024-10-01T02:04:28.268Z (3 months ago)
- Topics: express-middleware, expressjs, koa, logger, logging-library, middleware, request
- Language: TypeScript
- Homepage:
- Size: 75.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Britannia (Shinsei Buritania Teikoku)
`britannia` is a simple logging middleware for Express.js (and any Node.js framework) that logs details of incoming HTTP requests and responses. It records the HTTP method, status code, request URL, response duration, and the date of the request.
## Features
- Logs HTTP method, status code, URL, response duration in milliseconds, and the current date.
- Easy to integrate with Express.js applications, and any other Node.js framework.
- Configurable options for future file logging support.## Installation
Install `britannia` via npm:
```bash
npm install britannia
```## Usage
### Basic Usage
To use `britannia` middleware in your Express.js application, import it and use it as middleware:
```js
import express from 'express';
import britannia from 'britannia';const app = express();
// Use the britannia middleware
app.use(britannia());app.get('/', (req, res) => {
res.send('Hello, world!');
});app.listen(3000, () => {
console.log('Server is running on port 3000');
});### Configuration Options
You can pass configuration options to `britannia`:
import express from 'express';
import britannia from 'britannia';const app = express();
// Configuration options
const options = {
writeToFile: false, // Currently not supported, future feature
fileName: 'logs.txt' // Currently not supported, future feature
};// Use the britannia middleware with options
app.use(britannia(options));app.get('/', (req, res) => {
res.send('Hello, world!');
});app.listen(3000, () => {
console.log('Server is running on port 3000');
});
```
## ContributingIf you would like to contribute to `britannia`, please fork the repository and submit a pull request. We welcome contributions of all kinds, including bug fixes, new features, and documentation improvements.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Contact
For any questions or issues, please open an issue on the GitHub repository or contact the maintainers at [[email protected]](mailto:[email protected]), or you can also contact via [X (Twitter)](https://x.com/inuoshios).