1.1.14 • Published 4 years ago

api-inti v1.1.14

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

API INTI

API core for Node.js using express framework and mongodb NoSQL database.

Using for:

  • Nodejs
  • Expressjs
  • MongoDB
  • Mongoose

List of Api parent class:

  • this.list(q, population)
  • this.show(q, population)
  • this.create(input)
  • this.update(q, input, opts)
  • this.delete(q, opts)
  • this.softDelete(q, opts)
  • this.paginate(q, population, opts)

List of Controller parent class:

  • this.success({code, msg, data, meta})
  • this.error({code, msg})

How to use:

Import in base project file to connect with database. Example:

  • root file
...
require("api-inti").connection(process.env.MONGODB_HOST)
...

Import as parent class or function. For example:

  • actions file
const { Api } = require("api-inti")
const TestModel = require("models/test.model.js")

class Test extends Api {
    constructor() {
        super(TestModel)
    }

    async exec(params, populate) {
        try {
            return await this.list(params, populate)
        } catch(err) {
            throw err
        }
    }
}

module.exports = new Test()
  • controllers file
const { Controller } = require("api-inti")
const TestAction = require("actions/test.action.js")

class TestController extends Controller {
    constructor() {
        super()
    }

    async index(req, res) {
        try {
            let params = {}
            let data = await TestAction.exec(params)

            return res.send(
                this.success({
                    message: "Get test list",
                    data
                })
            )
        } catch(err) {
            return res.send(
                this.error({
                    error: err.message
                })
            )
        }
    }

    ...
}

module.exports = new TestController()
1.1.14

4 years ago

1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.6-0

4 years ago

1.1.5-0

4 years ago

1.1.3

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago