add basic readme and expand tests a little (#3)
This commit is contained in:
38
README.md
38
README.md
@ -0,0 +1,38 @@
|
|||||||
|

|
||||||
|
|
||||||
|
# KittyCAD JS/TS API library
|
||||||
|
|
||||||
|
`Socials::` - [blog](https://kittycad.io/blog) • [twitter](http://twitter.com/kittycadinc) • [linkedin](https://linkedin.com/company/kittycad) • [instagram](http://instagram.com/kittycadinc) • [youtube](https://www.youtube.com/channel/UCe_nbF3CBjbQRZoH_4xuNJA) • [discord](https://discord.com/invite/Bee65eqawJ)
|
||||||
|
|
||||||
|
## WIP, docs will be added to [kittycad.io/docs](https://kittycad.io/docs/api) soon
|
||||||
|
|
||||||
|
### Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @kittycad/lib
|
||||||
|
# or
|
||||||
|
yarn add @kittycad/lib
|
||||||
|
|
||||||
|
## set your token
|
||||||
|
export KITTYCAD_TOKEN=<your token>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic example
|
||||||
|
```typescript
|
||||||
|
import { file } from '@kittycad/lib';
|
||||||
|
import type { Models } from '@kittycad/lib';
|
||||||
|
import fsp from 'fs/promises';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const { status, mass } = (await file.create_file_mass({
|
||||||
|
src_format: 'obj',
|
||||||
|
material_density: '0.007',
|
||||||
|
body: await fsp.readFile('./example.obj', 'base64'),
|
||||||
|
})) as Models['FileMass_type'];
|
||||||
|
|
||||||
|
console.log(status, mass);
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
```
|
||||||
|
|
||||||
|
@ -22,3 +22,16 @@ describe('Testing create_file_execution', () => {
|
|||||||
expect(true).toBe(true);
|
expect(true).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('Testing create_file_mass', () => {
|
||||||
|
it("shouldn't throw", async () => {
|
||||||
|
const { status, mass } = (await file.create_file_mass({
|
||||||
|
src_format: 'obj',
|
||||||
|
material_density: '0.007',
|
||||||
|
body: await fsp.readFile('./example.obj', 'base64'),
|
||||||
|
})) as Models['FileMass_type'];
|
||||||
|
expect(mass).toBe(0.7063786);
|
||||||
|
expect(status).toBe('Completed');
|
||||||
|
|
||||||
|
expect(true).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
1942
example.obj
Normal file
1942
example.obj
Normal file
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -1,7 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "@kittycad/lib",
|
"name": "@kittycad/lib",
|
||||||
"version": "0.0.14",
|
"version": "0.0.14",
|
||||||
"description": "ts lib",
|
"description": "Javascript library for KittyCAD API",
|
||||||
|
"keywords": [
|
||||||
|
"hardward",
|
||||||
|
"library",
|
||||||
|
"CAD",
|
||||||
|
"Computer aided design",
|
||||||
|
"mechanical engineering",
|
||||||
|
"typescript"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/KittyCAD/kittycad.ts#readme",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/KittyCAD/kittycad.ts/issues"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/KittyCAD/kittycad.ts.git"
|
||||||
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"types": "./dist/types/src",
|
"types": "./dist/types/src",
|
||||||
|
Reference in New Issue
Block a user