Official repository of the SDK used in the "Api Doc" project, this SDK consists of an abstraction of the Api-Doc rules, it contains Knex as a base, and has migration encapsulated within itself, with that, the user will be free to be an independent project from Expressjs, which is the base where the official Api Rest was built
See Full Documentation
$ npm install api-doc-js-sdk
or
$ yarn add install api-doc-js-sdk
The "Api Doc - SDK" uses the knex as a base, so the whole mechanism behind it is based on knex, including its settings format.
import ApiDoc from "api-doc-js-doc";
const config = {
dev: {
client: "pg",
connection: {
port: process.env.PORTDB,
host: process.env.HOSTDB,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
},
pool: { min: 0, max: 10, idleTimeoutMillis: 500 },
},
};
export default new ApiDoc(config.dev, "TheApiSecretKey");
import apiDoc from "../config/api";
const name = "name";
const email = "[email protected]";
const password = "passwordTest";
// Async Await / Try Catch
async function newUserAsyncAwait() {
try {
const user = await apiDoc.userRegister(name, email, password);
console.log(user); // return new user
} catch (error) {
console.log(error.message); // return an eventual error
}
}
// Then Catch
apiDoc
.userRegister(name, email, password)
.then((newUser) => {
console.log(newUser); // return new user
})
.catch((err) => {
console.log(err); // return an eventual error
});
All other examples can be seen in the Api Doc, there the SDK is 100% used.