add basic readme and expand tests a little (#3)

This commit is contained in:
Kurt Hutten
2022-08-02 13:43:49 +10:00
committed by GitHub
parent 29a74f5b8c
commit 08b50ee5a2
4 changed files with 2010 additions and 1 deletions

View File

@ -0,0 +1,38 @@
![image](https://user-images.githubusercontent.com/19377312/165883233-3bdbc9fb-ddf9-4173-8cf2-d1b70ab7127d.png)
# 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();
```

View File

@ -22,3 +22,16 @@ describe('Testing create_file_execution', () => {
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

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,23 @@
{
"name": "@kittycad/lib",
"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": {
".": {
"types": "./dist/types/src",