Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Chat on Discord](https://img.shields.io/discord/939641163265232947?color=404eed&label=discord)](https://discord.gg/N5sEpsuhh9)

| repo | version |
|-----------------------------------------------------|-----------------------------|
|-----------------------------------------------------|------------------------------|
| [cli](https://github.com/jamsocket/forevervm) | [![npm](https://img.shields.io/npm/v/forevervm)](https://www.npmjs.com/package/forevervm) |
| [sdk](https://github.com/jamsocket/forevervm) | [![npm](https://img.shields.io/npm/v/@forevervm/sdk)](https://www.npmjs.com/package/@forevervm/sdk) |

Expand Down Expand Up @@ -106,3 +106,15 @@ const productionMachines = await fvm.listMachines({
tags: { env: 'production' }
})
```

Memory Limits
----------------

You can create machines with memory limits by specifying the memory size in megabytes:

```typescript
// Create a machine with 512MB memory limit
const machineResponse = await fvm.createMachine({
memory_mb: 512,
})
```
16 changes: 16 additions & 0 deletions javascript/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,20 @@ plt.show()`
expect(filteredMachines.machines.length).toBe(1)
expect(filteredMachines.machines[0].tags?.unique).toBe(uniqueTag)
})

test('createMachine with memory limit', async () => {
const fvm = new ForeverVM({ token: FOREVERVM_TOKEN, baseUrl: FOREVERVM_API_BASE })

// Create machine with memory limit
const machine = await fvm.createMachine({
memory_mb: 512,
})
expect(machine.machine_name).toBeDefined()

// Verify the machine was created (note: we can't directly verify the memory limit
// through the API as it doesn't return this value in machine details)
const machines = await fvm.listMachines()
const found = machines.machines.find(({ name }) => name === machine.machine_name)
expect(found).toBeDefined()
})
}
4 changes: 4 additions & 0 deletions javascript/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export interface WhoamiResponse {

export interface CreateMachineRequest {
tags?: Record<string, string>
/**
* Memory size in MB. If not specified, a default value will be used.
*/
memory_mb?: number
}

export interface CreateMachineResponse {
Expand Down