@technicity/data-service-generator
v0.19.1
Published
Generate a TypeScript SDK from a MySQL or SQL Server database.
Downloads
573
Readme
data-service-generator
Generate a TypeScript SDK from a MySQL or SQL Server database.
Usage
const { generate } = require("@technicity/data-service-generator");
main()
.then(() => {
process.exit(0);
})
.catch((error) => {
console.error(error);
process.exit(1);
});
async function main() {
await generate({
outdir: __dirname,
dialect: "mysql",
database: "MY_DATABASE",
user: "MY_USER",
password: "MY_PASSWORD"
});
}
API
generate
Options
| Option | Required | Default | Description | | ------------- | -------- | ------------ | --------------------------------------------------------------- | | outdir | Yes | | The output directory for the SDK. | | dialect | Yes | | "mysql" | "sqlite" | | database | Yes | | Database name | | user | Yes | | Database user | | password | No | | Database password | | host | No | "localhost" | Database host | | port | No | 3306 | 1433 | Database port. Defaults to 3306 for MySQL, 1433 for SQL Server. | | tables | No | | An array of database tables to process (allowlist). | | excludeTables | No | | An array of database tables to not process (denylist). |
Running Tests
yarn test
Unit Tests
Comment out globalSetup
in jest.config.js
, then:
yarn test:unit
See comment in ./test/globalSetup.ts
for why this is necessary.