Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add beam js examples #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ __downloads__
.venv/
.vscode/launch.json
.secrets
node_modules/
4 changes: 4 additions & 0 deletions javascript/express/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Make sure you have BEAM_TOKEN set in your .env
`yarn start` to run server

To make a request to the example endpoint, run `curl http://localhost:3333`
17 changes: 17 additions & 0 deletions javascript/express/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const express = require("express");
const beam = require("@beamcloud/beam-js");
const app = express();
const port = 3333;

app.get("/deployment", async (req, res) => {
const client = await beam.init(process.env.BEAM_TOKEN);

const dep = await client.deployments.list();

const callResp = await dep[0].call();
res.send(callResp.data);
});

app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
17 changes: 17 additions & 0 deletions javascript/express/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "beam-express-server",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"@beamcloud/beam-js": "0.0.19",
"express": "^4.21.1",
"openai": "^4.69.0"
},
"devDependencies": {
"@types/node": "^22.8.4"
}
}
Loading