0.0.9 • Published 6 years ago

api-rest v0.0.9

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

create folder api

mkdir myapi
cd myapi
npm install api-rest

main.js

const rest = require('api-rest');

// simple database only develop test
const MyDB = new rest.Database("./mydb.json");

const config = {
    "port": "8080",
    "public": "/path/to/public_files"
}

// sample the CRUD api
const person = {
    auth: true,
    database: MyDB,
    model: {
        id: 0,
        name: {
            max_length: 20,
            null: false,
            verbose_name: 'Name',
            default: undefined,
            type: 'string'
        }
    }
}

rest.Server
    // set config
    .config(config)
    
    // register routers
    .route('/api/person/', pessoa)
    .route('/path/to/api', 'get', (req, res)=>{
        res.send('ok');
    })
	
    // start server
    .start();

start api

node main.js

list of registered api

http://localhost:8080/
0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago