1.0.5 • Published 3 years ago

kozmo v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Kozmo.js

kozmo js is a minimalist open source API framework for building simple web APIs

Installation

$ yarn add kozmo

Example App

const Kozmo = require('kozmo');
const app = new Kozmo();

// response
app.get('/hello', (req, res) => {
	res.end('Hello World');
});

app.get('/html-site', (req, res) => {
	res.html('<h1>Example App</h1>');
});

app.get('/api/products', (req, res) => {
	res.json({ price: 300 });
});

app.post('/api/products', (req, res) => {
	products.push(req.body);
	res.json({ msg: 'success' });
});

app.listen(3000, console.log('running on port 3000!'));

Using Middleware

For example here is a usage of the morgan logger middleware

const morgan = require('morgan');
const Kozmo = require('kozmo');
const app = new Kozmo();

app.use(morgan('dev'));

// response
app.get('/', (req, res) => {
	res.end('Hello World');
});

app.listen(3000, console.log('running on port 3000 with morgan!'));

Contact

you can contact me on okirshen@gmail.com

you can also join the discord server

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago