2.0.0 • Published 1 month ago

hiroki v2.0.0

Weekly downloads
9
License
MIT
Repository
github
Last release
1 month ago

Hiroki NPM version Build Status

build REST APIs faster than ever using the open source tools and standards you and your team already know.

read the documentation here.

Getting Started

Step by step example Getting Starter.

Installation:

npm install --save hiroki

Create simple rest api:

this is a basic example, keep in mind you may need body-parser library.

const express = require('express');
const hiroki = require('hiroki');
const mongoose = require('mongoose');
const app = express();

// Model definition
const UsersSchema = new mongoose.Schema({name: String});
mongoose.model('Users', UsersSchema);

// Importing model
hiroki.importModel(UsersSchema);

// Bodyparser added
app.use(bodyParser.urlencoded());

app.use(bodyParser.json());


// Api route to pass data to hiroki
app.use('/api/*', async(req, res) => {
    const path = req.originalUrl;
    const resp = await hiroki.process(path, {
        method: req.method,
        body: req.body
    });
    res.status(resp.status || 200).json(resp);
});

app.listen(8012);

Build config:

it is possible to change the route that hiroki uses

hiroki.setConfig({ 
    basePath: '/api/v2' // default /api
});

Changelog

  • v2.0.0:
    • hiroki should be now backend agnostic. Express removed as dependency.
    • mongoose version updated
    • share will be removed for this version. Check if this would be usefull. Full Changelog
2.0.0

1 month ago

0.2.9

4 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago